I’m trying to figure out how to write a condition for “are all lights in an area on/off” without specifying the entities individually.
Context:
I have Zigbee lights set up through ZHA, but they are cheap ones that respond correctly to commands only 90% of the time (and often not at all to commands sent within seconds of eachother).
Right now what I do to turn on the lights is:
Check for motion in a room
If motion detected, run a script that selects the right light color based on time-of-day
This script calls lights.on on the room variable that triggered the motion
crucially I rerun the lights.on script after 5 seconds to make sure the lights actually responded
The approach of rerunning the script naively is both unelegant and annoying, and causes issues because:
Someone might have changed the color of the lights (through voice assistant) in the wait window of the script that changes the color of the lights
The bulbs sometimes respons slowly or not at all to Zigbee commands sent within seconds of eachother, so it creates an unpredictable queue of commands when I just rerun the script twice
Ideally I would like to:
Run the script as above
Check if any of the lights in the room are off (when they should be on) or on (when they should be off) and only rerun the command if that is the case
Prompted by your question, I stood next to a bulb and rapidly changed it’s colors in HA. And it seems to work fine, even with rapid changes
I have other zigbee devices that work perfectly yes. Mostly switches and a few buttons. I’ve yet to experience issues with them.
I’ll read that post and see if I can fix it up.
That said, I’m still curious about the initial question for other reasons (ie if lights are already on, do not override them). Do you have an idea about the original question?
Not out of the top of my head but I think I have seen such a thing some time ago but can’t find it right now.
On the other hand, I think of 2 possible ideas:
in an automation you can specify a room for controlling the lights
You would need to set the “all entities” option for the group to “on” - that way the group would only be on if all the lights were on. (Which is what you want, I think? Or do you need to know which light has failed?)