I would like to create a binary sensor that indicates if the light level has reached a certain daytime brightness or fallen below a sunset level.
If the light level is above 200 the sensor is turned on.
if the light level is below 10 the sensor is turned off.
I’m not sure how to template this. Would this work?
(bianary_sensors.yaml)
- platform: template
sensors:
lounge_auto_lights_enable:
friendly_name: "Lounge Auto Lights Enable"
value_template: >-
{% if states('sensor.aeotec_lounge_light_level') > 200 %}
'on'
{% elif states('sensor.aeotec_lounge_light_level') < 10 %}
'off'
{% else %}
{{ states('lounge_auto_lights_enable') }} # stay the same state
{% endif %}
This sensor will be used to prevent my lights automatically turning on in the morning if I have not woken up and opened the blinds and there is a dim light level in the room (as happens at sunset when I do want the lights to turn on).
If the max_age of the statisitcs sensor worked I would not need this work around as I could just test for light_level > 200 in the last 8 hours.