I’m getting myself confused with syntax here… I have an LDR sensor which I am trying to control my lights with. I am attempting to use Jinja2 templating instead of multiple automations. The general idea is I want to set the brightness_pct level to:
- 0 when over 630 (Off)
- 40 from 450 - 630
- 50 from 280 - 480
- 60 when below 280
What I have so far is:
{% if states('sensor.sn1_ldr') | float > 630 %}
0
{% elif states('sensor.sn1_ldr') | float < 630 %}
40
{% elif states('sensor.sn1_ldr') | float < 450 %}
50
{% elif states('sensor.sn1_ldr') | float < 280 %}
60
{% endif %}
Is this right?
It’d be nice if there was a between(280, 480)
comparison