I’m using a Aeotec Multi 6 to measure the indoor luminance, to control my indoor lights. It has been working quite well, but now I’ve experience that the sensor does not report the value “in time”, i.e. it gets too dark before it reports to the controller and when I do a refresh on the device, it reports directly. I found out that the refresh value can be altered, but only maximum of 60 seconds.
This will cause that the luminance value will flicking up and down with 1 or 2 lux between every refresh, no big deal unless it is between the value that I triggers on. I.e. my “shade” and “dark” scripts toggles every second minute until the luminance value have been stable on either side of the trigger value.
I’m looking for adding a “for minutes: 10” statement, but cannot see where I can add this for my automation. Any one of you guys that have a idea and can help me?
My automation:
- alias: Turn on or off light based on lux
trigger:
platform: state
entity_id: sensor.light_sensor
condition:
condition: and
conditions:
- condition: state
entity_id: sensor.someone_home
state: 'yes'
- condition: state
entity_id: sun.sun
state: 'above_horizon'
# - condition: time
# after: '08:00:00'
action:
- service_template: >-
{% if is_state ("sensor.light_sensor", "Bright") %}
script.bright_lights
{% elif is_state ("sensor.light_sensor", "Dim") %}
script.dim_lights
{% elif is_state ("sensor.light_sensor", "Shade") %}
script.shade_lights
{% elif is_state ("sensor.light_sensor", "Dark") %}
script.dark_lights
{% else %}
unknown
{% endif %}
And my sensor that gives me the trigger values
light_sensor:
friendly_name: Inside Light Sensor
value_template: >-
{% if states("sensor.dinner_room_luminance") | float >= 29 %}
Bright
{% elif states("sensor.dinner_room_luminance") | float < 27 and states("sensor.dinner_room_luminance") | float >= 20 %}
Dim
{% elif states("sensor.dinner_room_luminance") | float < 18 and states("sensor.dinner_room_luminance") | float >= 15 %}
Shade
{% elif states("sensor.dinner_room_luminance") | float < 13 and is_state("input_boolean.night_mode", "off") %}
Dark
{% elif states("sensor.dinner_room_luminance") | float < 13 and is_state("input_boolean.night_mode", "on") %}
Night
{% else %}
unknown
{% endif %}
Maybe this could work? It will need an automation for each brightness state so you might want to simplify the condition, for example with another template sensor.
- alias: Turn to Bright light based on lux
trigger:
platform: state
entity_id: sensor.light_sensor
to: 'Bright'
for:
minutes: 10
condition:
condition: and
conditions:
- condition: state
entity_id: sensor.someone_home
state: 'yes'
- condition: state
entity_id: sun.sun
state: 'above_horizon'
# - condition: time
# after: '08:00:00'
action:
- service:
script.bright_lights
Actually, maybe just change the top of your original automation to this:
- alias: Turn on or off light based on lux
trigger:
platform: state
entity_id: sensor.light_sensor
to: ["Bright","Dim","Shade","Dark","Night"]
for:
minutes: 10
condition:
# [...]
Thanks, the last one was very attractive. Have got another tip as well. Will try both and see how well it work. Appreciate you input and effort on this @amelchio
Or, you could build hysteresis into your automations. Say in the morning you’d have your “Shade” scene come on at 10 lux (so above: 10) , but then as it’s getting darker in the evening, trigger it on below: 8. (I might have that backwards… but I think you might know what I mean!)