Hi
I have just updated my Hom Assistant to 2023.7.3 and now struggle to get my operation mode labels for my heater to work again.
I came from a version of Dec 2022/Jan 2023 and had following sensor definition to get a Human readable labels to my heater operation mode:
sensor:
- platform: template
sensors:
heizung_betriebsart_name:
friendly_name: "Heizung Betriebsart Name"
value_template: >-
{% set mapper = {
'1' : 'Standby',
'3' : 'Normal',
'4' : 'Absenk',
'5' : 'Sommer',
'11' : 'Programm 1',
'12' : 'Programm 2',
'13' : 'Programm 3',
'255' : 'Wie Leitstelle'
} %}
{% set state = states('sensor.heizung_betriebsart') %}
{{ mapper[state] if state in mapper else 'Unknown' }}
The integer value sensor.heizungbetriebsart comes via MQTT from a nodered shim which handles reading and writing to my Weishaupt Heater Setup.
This does now not longer work and in investigation this I tried to move this to the following select template
template:
- select:
- name: "Heizung Betriebsart Name"
unique_id: heizung_betriebsart_name
state: >
{% set opt = states('sensor.heizung_betriebsart') %}
{% set mapper = {
1 : 'Standby',
3 : 'Normal',
4 : 'Absenk',
5 : 'Sommer',
11 : 'Programm 1',
12 : 'Programm 2',
13 : 'Programm 3',
255 : 'Wie Leitstelle'
} %}
{{ mapper.get(opt) }}
options: "Standby,Normal,Absenk,Sommer,Programm 1,Programm 2,Programm 3,Wie Leitstelle,Unknown"
# options: "{{['Standby','Normal',Absenk','Sommer','Programm 1','Programm 2',Programm 3',Wie Leitstelle','Unknown']}}"
# options: "[Standby,Normal,Absenk,Sommer,Programm 1,Programm 2,Programm 3,Wie Leitstelle,Unknown]"
# options: ["Standby","Normal","Absenk","Sommer","Programm 1","Programm 2","Programm 3","Wie Leitstelle"]
# options:
# - Standby
# - Normal
# - Absenk
# - Sommer
# - Programm 1
# - Programm 2
# - Programm 3
# - Wie Leitstelle
select_option:
- service: mqtt.publish
data:
topic: home/weishaupt/Betriebsart/set
payload: >
{% set mapper = {
'Standby' : 1,
'Normal' : 3 ,
'Absenk' : 4,
'Sommer' : 5,
'Programm 1' : 11,
'Programm 2' : 12,
'Programm 3' : 13,
} %}
{{ mapper[option] if state in mapper else 'Unknown' }}
qos: "1"
But this does not render the state correctly, I get the following error message:
home-assistant | 2023-07-31 08:48:43.580 ERROR (MainThread) [homeassistant.helpers.template_entity] Error validating template result 'None' from template 'Template<template=({% set opt = states('sensor.heizung_betriebsart') %} {% set mapper = { 1 : 'Standby', 3 : 'Normal', 4 : 'Absenk', 5 : 'Sommer', 11 : 'Programm 1', 12 : 'Programm 2', 13 : 'Programm 3', 255 : 'Wie Leitstelle' } %} {{ mapper.get(opt) }}) renders=4>' for attribute '_attr_current_option' in entity select.heizung_betriebsart_name validation message 'string value is None'
My assuption is that the list of options is not correct, you see the different attempts to define them commented out in the snippet above.
Could someone shed some light on why this is not working?
cheerio
Steve