Almost every time I restart or reboot HA I have a problem with my Motion activated lights automation. Usually lamp is always on after reboot and automation no longer works.
To fix it I have to disable and enable automation, sometime several times. Or physically turn off/on lamp.
I have aqara zigbee motion sensor and aqara zigbee lamp.
The automation looks like this:
When motion sensor started detecting motion
Then do
activate lamp scene (turn on lamp)
wait for 1 trigger: When motion-sensor changes from any state to Clear for 30 seconds
Turn off lamp
Maybe itâs happening because automation was running when HA was restarted?
Any way to fix it?
Visual editor is not happy, but looks like automation still works!
I would never figure out to add not from and not to there.
Itâs only possible in yaml mode?
I rebooted HA when automation was running and lamp was on and never goes off. I activated automation with motion sensor and itâs still running.
It stuck at waiting for 1 trigger:
- wait_for_trigger:
- entity_id:
- binary_sensor.lumi_lumi_sensor_motion_aq2_motion
to: "off"
for:
hours: 0
minutes: 0
seconds: 30
trigger: state
from: null
update: after some time it recovered itself
I wonder what if create 2 automations: first automation to turn lamp on trigger and second automation to turn off lamp
I see the problem is aqara motion sensor, it stuck in Motion: Detected state after HA restart for about 10 minutes thatâs why my automation doesnât work.
I did another test, I rebooted HA when state was Motion: Clear and after reboot it worked right away!
Is there a way to set or reset item state on boot maybe?
Update 2: I set python_script integration and now can set state for motion sensor when HA starts.
I also now have two automations: first automation to turn lamp on trigger and second automation to turn off lamp.
The reason I need a second automation because I need to constantly monitor duration of Clear state, without dealing with states transition (from detected to clear).
This trigger type: no_motion should turn off lamp after HA restart if its on.
In my testing trigger based on state changes doesnât work for some reason.
Update 3: I rebooted HA and lamp was on and sensor state was clear. My automation failed.
I guess I need to create automation to turn off lamp when HA starts and go back to my original automationâŚ
I tested example with âchooseâ function and it works, thanks.
But it feels a bit complex with all On/Off ids. I guess you canât create it using visual editor only.
Regarding initial problem, I have now automation that sets state to âoffâ (clear) for motion-sensor when HA starts and also turns off aqara lamp. And it worked in my testing.