Planner: send notification when plan overrun is detected (#26054)

This commit is contained in:
Marcel Goerentz 2025-12-21 13:18:23 +01:00 • committed by GitHub
parent 97444e6241
commit 236cde95bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 12 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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