HI,
having 11 of these sensors:
frontdoor_motion_sensor_lux:
friendly_name_template: >
Frontdoor:
{% set lux = state_attr('sensor.frontdoor_motion_sensor','lx') %}
{% if lux <=1 %}
moonlight
{% elif lux <=2 %}
night light
{% elif lux <= 10 %}
dimmed light
{% elif lux <= 50 %}
'cosy' living room
{% elif lux <= 150 %}
'normal' non-task light
{% elif lux <= 350 %}
working / reading
{% elif lux <= 700 %}
inside daylight
{% elif lux <= 2000 %}
maximum to avoid glare
{% elif lux <= 10000 %}
clear daylight
{% elif lux <= 120000 %}
direct sunlight
{% else %}
too bright!
{% endif %}
value_template: >
{{state_attr('sensor.frontdoor_motion_sensor','lx')}}
I ws wondering if I could use the anchor method for the bit after the first line of the friendly_name template:
frontdoor_motion_sensor_lux:
friendly_name_template: >
Frontdoor:
{% set lux = state_attr('sensor.frontdoor_motion_sensor','lx') %}
#make this an anchor , and insert it in all templates
{% if lux <=1 %}
moonlight
{% elif lux <=2 %}
night light
{% elif lux <= 10 %}
dimmed light
{% elif lux <= 50 %}
'cosy' living room
{% elif lux <= 150 %}
'normal' non-task light
{% elif lux <= 350 %}
working / reading
{% elif lux <= 700 %}
inside daylight
{% elif lux <= 2000 %}
maximum to avoid glare
{% elif lux <= 10000 %}
clear daylight
{% elif lux <= 120000 %}
direct sunlight
{% else %}
too bright!
{% endif %}
value_template: >
{{state_attr('sensor.frontdoor_motion_sensor','lx')}}
i am a bit confused by the foor and bar explanation https://blog.daemonl.com/2016/02/yaml.html and how I should name the anchor and insert it again…