hi all, i have set up tis template but is always “unavailable”, do you have any ideas why?
template:
- sensor:
- name: "litri_consumati_istantanei"
unique_id: litri_consumati_istantanei
state: >
{% if states('sensor.meross_smart_plug_1_power') > 0 %}
5
{% else %}
0
{% endif %}
unit_of_measurement: "L/s"
madface
(Mike)
November 5, 2023, 9:44am
2
If you put the template in the developer tools in ha, what ist the result, is it working there?
If even not there, maybe the value is stored as a string, then converting it to an integer could help:
{% if states('sensor.meross_smart_plug_1_power') | int(0) > 0 %}
5
{% else %}
0
{% endif %}
1 Like
yes! the conversion from string to integer works! thanks a lot!
tom_l
November 5, 2023, 11:33am
4
There’s no ‘maybe’ about it. State values are always strings. Only attributes can have different types.
1 Like
madface
(Mike)
November 5, 2023, 12:02pm
5
Thanks for clarification, this was one of the background things in ha i wasn’t aware of!