I have a Xiaomi Aqara Zigbee Luminance Sensor. I will use it instead of my Sun sensor to control the outdoor lights during the dark period of the day.
I want to add some kind of delay. So it have to be below a certain lux level for at least x minutes, before my lights are switched on/off. To prevent flickering during cloud/sunset/sunrise.
I just saw some strange things happening all morning, at sunrise… The sunset was triggered some minutes before the sunrise, but the illuminance valu have not been higher than 5 during this time.
Is it the exact same time every morning?
You could add a simple notification or log entry to see what the state of sensor.ljusmtare_illuminance actually is.
The lux-level have been 1 lx from 19:38 to 06:01:06, when it goes up to 2.
3 minutes later, 06:04:06 the “sunset automation” alias: Solnedgång Lux was executed.
So the value have not been higher than 5 as the trigger defines.
It seem like the automation can be executed, without passing the trigger-value.
Please help me out here…
Do you have the log entries as i suggested?
It sounds to me like something else is running the automation. You don’t have some old debug-stuff laying around that does an “automation.trigger” or something?
No, I’m quite sure I don’t have any other automatons triggering this. But I’ll add it and check tomorrow!
Seems to be something when going from 1 to 2 lx during the morning.
Ok, checked this today again… Now in the latest HA, the triggering device are clear visible. So its actually no other automation that triggers this.
Do I need to add some additional condition, like trigger only if sun is not rising? According to my logging the illuminance have not been higher than 5 when the automation was triggered.
Can the automation trigger multiple times, even if the value does not rise above the threshold?
It should not. But it could be that you get a bad measurement or a single measurement of a wrong value, which for some reason is not visible in the logs.
Also, if the automations are reloaded or HA is restarted, the threshold will be reset, so the first measurement after a reload or restart could trigger an automation.
Ah, maybe it are related to HA restart during the evening. I must check the logger for a evening with no HA restart. That can make sense.
This morning the automation triggers on the first value since the restart of HA (I guess). It have been 1lux all the night, but 3 minutes before the automation triggered, the illuminance changed to 2lux and hence triggered the automation.
Is there a way of letting the automation be persistent during restarts? Or should I just a condition to restrict triggering during the morning (in this case)?
Maybe checking if the group are on/off as a condition. I have some ideas. At last can understand why it’s triggered… I start to remember I have seen mornings with no triggering (that’s maybe when the HA didn’t get restarted during the evening).
What you could do is use a template binary sensor, with delay_on and delay_off so that it requires the light level to be above, or below, for three minutes before it changes state. Then short blips won’t matter, and you can use that in your automation trigger.
Ok just checked the logbook of this morning. It was no unexpected trigger of the sunset automation during the morning (when going from 1lux to 2lux).
And, I didn’t fiddle around with HA yesterday at all… So it have to do with the restarts.
I guess I can trigger the automation by pointing with a flashlight on the illuminance-sensor during the night/evening after a restart (when value stays at 1 lux). When the sensor reports the first value (below the threshold), the automation will trigger after the delay-time (3min).
Maybe I can live with it, or I have to do a special solution as @Tinkerer proposes.
Thanks @Olen for pointing me in the right direction!