Messaging: add more vehicle properties (#13229)

This commit is contained in:
andig 2024-03-31 12:35:00 +02:00 • committed by GitHub
parent 18436a1d68
commit a11b9d04bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -79,6 +79,10 @@ func (h *Hub) apply(ev Event, tmpl string) (string, error) {
// add missing attributes
if name, ok := attr["vehicleName"].(string); ok {
if v, err := h.vehicles.ByName(name); err == nil {
attr["vehicleLimitSoc"] = v.GetLimitSoc()
attr["vehicleMinSoc"] = v.GetMinSoc()
attr["vehiclePlanTime"], attr["vehiclePlanSoc"] = v.GetPlanSoc()
instance := v.Instance()
attr["vehicleTitle"] = instance.Title()
attr["vehicleIcon"] = instance.Icon()