Planner: send notification when plan overrun is detected (#26054)
This commit is contained in:
parent
97444e6241
commit
236cde95bf
4 changed files with 12 additions and 0 deletions
|
|
@ -20,6 +20,9 @@
|
|||
# asleep:
|
||||
# title: Vehicle asleep
|
||||
# msg: Charge release, vehicle {{ if .vehicleTitle }}{{ .vehicleTitle }} {{ end }}not charging.
|
||||
# planoverrun:
|
||||
# title: Plan overrun
|
||||
# msg: "Plan {{- if .vehicleTitle }} for {{ .vehicleTitle }} will overrun.{{ else }} will overrun.{{end}}"
|
||||
|
||||
#services:
|
||||
#- type: pushover
|
||||
|
|
|
|||
|
|
@ -151,6 +151,7 @@ type Loadpoint struct {
|
|||
planEnergyOffset float64 // already charged energy in kWh when plan was set
|
||||
planSlotEnd time.Time // current plan slot end time
|
||||
planActive bool // charge plan exists and has a currently active slot
|
||||
planOverrunSent bool // notification has been sent already
|
||||
|
||||
// cached state
|
||||
status api.ChargeStatus // Charger status
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import (
|
|||
// setPlanActive updates plan active flag
|
||||
func (lp *Loadpoint) setPlanActive(active bool) {
|
||||
if !active {
|
||||
lp.planOverrunSent = false
|
||||
lp.planSlotEnd = time.Time{}
|
||||
}
|
||||
if lp.planActive != active {
|
||||
|
|
@ -154,6 +155,10 @@ func (lp *Loadpoint) plannerActive() (active bool) {
|
|||
if excessDuration := requiredDuration - lp.clock.Until(planTime); excessDuration > 0 {
|
||||
overrun = fmt.Sprintf("overruns by %v, ", excessDuration.Round(time.Second))
|
||||
planOverrun = excessDuration
|
||||
if !lp.planOverrunSent {
|
||||
lp.pushEvent("planoverrun")
|
||||
lp.planOverrunSent = true
|
||||
}
|
||||
}
|
||||
|
||||
planStart = planner.Start(plan)
|
||||
|
|
|
|||
|
|
@ -215,6 +215,9 @@ messaging:
|
|||
asleep: # vehicle doesn't start charging
|
||||
title: Vehicle asleep
|
||||
msg: Charge release, vehicle {{ if .vehicleTitle }}{{ .vehicleTitle }} {{ end }}not charging.
|
||||
planoverrun: # current plan is going to overrun
|
||||
title: Plan overrun
|
||||
msg: "Plan {{- if .vehicleTitle }} for {{ .vehicleTitle }} will overrun.{{ else }} will overrun.{{ end }}"
|
||||
services:
|
||||
# - type: pushover
|
||||
# app: # app id
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue