I have an automation that turns on my attic light when motion is detected by my Ikea zigbee motion sensor. But the sensor goes from “Clear” to “Unavailable” after some hours. And this causes the blueprint to not trigger. The motion sensor will change from “Unavailable” to “Detected” just fine, but it will not trigger the automation.
What would be the best way of handling this? Drop the blueprint and create a new automation that triggers even if the motion sensor goes from “Unavailable” to “Detected”? Or can I do some magic so the motion sensor doesn’t go to “Unavailable”?
This is the included blueprint from Home Assistant and several people have improved on it.
You can search the Blueprint Exchange for something that works better, or take control of that one and edit it as an automation, probably adding not_to: and/or not_from: key in the trigger.
I remembered why I started using the blueprint in the first place: To simplify the automations I had earlier, using separate automations for “on” and "off, and a timer to control when to trigger the “off” automation.
I ended up now just copying the motion light blueprint and removing the “from” property from the trigger as you suggested. Worked like a charm!
@ohj Personally, I would fix the root cause of the sensor going unavailable. Luckily, it’s a pretty simple fix if you understand what’s going on.
ZHA’s default setting for marking devices as Unavailable is set to 21600 seconds (6 hours) for battery devices. Basically, if a battery device doesn’t “check in” or send a message to ZHA, it will be marked as unavailable.
Looking at your Activity screenshot above, your sensor is going unavailable pretty much exactly at the 6 hour mark (give or take a few seconds). Looks like the Ikea sensor doesn’t report as frequently as ZHA expects.
To fix this, go to Settings > Integrations > ZHA > Configure (cog icon) & scroll down to the “Consider battery-powered devices unavailable after” field.
Change that 21600s value to something much higher. As a baseline example, that setting in Z2M is set to 25h, so I’d set the value to 86400-90000.
Remember to click “Update Configuration” for the setting to actually apply!
That’s a very good point. I didn’t consider that this started being a problem after I went from DeCONZ to ZHA. I believe DeCONZ also has a 24 hour period before considering a battery powered device offline.