Hi!
I am running the latest hass and it’s been working fine for years.
I have a two Philips Hue motion sensors and one from Ikea.
They control lights.
I used to have a simpler automation setup but decided to make it more fancy and use snapshot scenes of the previous state before changing the state of a light.
I used to have one automation to turn on the light when the sensor detected motion, then one automation that turned off the light when there was no motion detected. This worked fine.
Now I have an automation that creates a scene with a snapshot of the light before turning on the light.
Then restores to the scene when there is no motion detected. This works most of the time.
But for some reason sometimes the light stays on sometimes. It does this until I manually turn it off, it’s not enough for me to walk by the motion sensor in order to reset.
I don’t understand why. Any ideas?
I have had this to happen with all three of my sensors.
They are configured the same way.
Here is an example:
Sounds like you have the automation restart or run multiple instances at the same time.
When this happens then the first run turns one the lights and before it’s finished and have restored the lights the next one have started and made a snapshot of lights set up from the first run, which means that it overwrites the first snapshot
This was something I suspected as well.
But I have mode: single on all my automations.
I have double checked the condition times as well and I can’t find anything that would explain this.
There are no errors and nothing out of the ordinary.
I will wait until it happens the next time and see exactly what the logs say about triggered automations.
One of the lights stuck again and I investigated the logs.
I know what happens but I don’t know how to solve it.
There is motion detected.
The snapshot scene is created.
The light is turned on.
There is no motion for 20 seconds, the light is not yet turned off since I have a 30 second time under for under trigger (5 seconds in the above example).
Then there is motion detected and the snapshot is created again before the light is turned off.
This creates a snapshot scene with the light turned on.
How do I do this properly with a custom timeout for the light being on after motion is detected, without the snapshot scene being overwritten with the wrong value?
Create a timer helper.
Change the mode to restart.
Use a choose, to check the state of the timer, ONLY create the snapshot if the state of the timer is idle
Listen for the trigger ( platform: event) timer.finished and restore the created snapshot when the trigger fires.
Here is how I listen for the timer event as an example:
That’s how I deal with all my motion lights, and in the example I have given - turning up media volume when I have music playing across the whole house.
Andrews way of solving the problem felt a little complicated since there already is a counter.
I did some more digging and solved the problem by using an input boolean.
Thanks to this thread: