just discovered we can not do
- unique_id: badge_wind_compass
state: >
{{states('sensor.winddirection')}}
name: >
{{states('sensor.wind_compass_abbreviation')}}
unit_of_measurement: >
{{states('sensor.winddirection')}}°
picture: >
{%- set degrees = states('sensor.winddirection')|float(0) %}
{%- set path = '/local/weather/wind_compass/' %}
{%- set ext = '.png' %}
{%- set num = ((degrees // 11.25) * 11.25 // 1)|int %}
{%- set num = 0 if num == 360 else num %}
{{"{}{}{}".format(path,num,ext)}}
which is very useful for displaying badges, and have some more meanings the Unit placeholder than only
because I use custom-ui I can do:
homeassistant:
customize:
sensor.badge_wind_compass:
templates:
unit_of_measurement: >
if (entities['sensor.winddirection'])
return entities['sensor.winddirection'].state + ' °';
return 'Initializing';
to see:
allowing templates on the unit could lift the template:
integration even further