From 00e8d4c94324a7153c1d2bcc3a09d144954b0d45 Mon Sep 17 00:00:00 2001 From: andig Date: Sat, 6 Dec 2025 10:23:24 +0100 Subject: [PATCH] HomeAssistant: fix deprecated home parameter not rendered (#25849) --- templates/definition/charger/homeassistant-switch.yaml | 1 + templates/definition/meter/homeassistant.yaml | 1 + templates/definition/vehicle/homeassistant.yaml | 1 + util/templates/template.go | 5 ++--- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/templates/definition/charger/homeassistant-switch.yaml b/templates/definition/charger/homeassistant-switch.yaml index 90fe8ce0e..cb8c0f74e 100644 --- a/templates/definition/charger/homeassistant-switch.yaml +++ b/templates/definition/charger/homeassistant-switch.yaml @@ -42,6 +42,7 @@ params: render: | type: homeassistant-switch uri: {{ .uri }} + home: {{ .home }} # deprecated enable: {{ .switch }} power: {{ .power }} {{ include "switchsocket" . }} diff --git a/templates/definition/meter/homeassistant.yaml b/templates/definition/meter/homeassistant.yaml index 25884c7b0..2482e9c18 100644 --- a/templates/definition/meter/homeassistant.yaml +++ b/templates/definition/meter/homeassistant.yaml @@ -125,6 +125,7 @@ params: render: | type: homeassistant uri: {{ .uri }} + home: {{ .home }} # deprecated power: {{ .power }} energy: {{ .energy }} currents: diff --git a/templates/definition/vehicle/homeassistant.yaml b/templates/definition/vehicle/homeassistant.yaml index 2356acb06..4a5ea8ae7 100644 --- a/templates/definition/vehicle/homeassistant.yaml +++ b/templates/definition/vehicle/homeassistant.yaml @@ -100,6 +100,7 @@ render: | {{ include "vehicle-common" . }} {{ include "vehicle-features" . }} uri: {{ .uri }} + home: {{ .home }} # deprecated sensors: soc: {{ .soc }} range: {{ .range }} diff --git a/util/templates/template.go b/util/templates/template.go index eeb6c9605..10464e44e 100644 --- a/util/templates/template.go +++ b/util/templates/template.go @@ -311,7 +311,8 @@ func (t *Template) RenderResult(renderMode int, other map[string]any) ([]byte, m // The actual key name is taken from the parameter to make it unique. // Since predefined properties are not matched by actual parameters using // ParamByName(), the lower case key name is used instead. - // All keys *must* be assigned or rendering will create "" artifacts. + // All keys *must* be assigned or rendering will create "" artifacts. For this reason, + // deprecated parameters (that may still be rendered) must be evaluated, too. for key, val := range values { out := strings.ToLower(key) @@ -321,8 +322,6 @@ func (t *Template) RenderResult(renderMode int, other map[string]any) ([]byte, m if !slices.Contains(predefinedTemplateProperties, out) { return nil, values, fmt.Errorf("invalid key: %s", key) } - } else if p.IsDeprecated() { - continue } else { out = p.Name }