I currently have an automation to turn on a light group of 20 individual lights every time motion is detected. If motion is detected every few seconds, I guess the service would be calling to turn on the light group even though they are already on. Are there any downsides to this? Should I be checking if the lights are already on before calling the service?
The reason it becomes tedious is because there may be an individual light that is turned off for one reason or another. I want the detected motion to turn on that individual light that is off. If I want to check for an individual light, I will need to separate the automation to check that each light is turned on, and then turn on each light individually that is not on. Is it worth the effort?
Shouldnāt be an issue, I wouldnāt worry about it. Checking the state of each entity and calling the service on only those entities that are off would probably result in more I/O anyway.
I believe it depends on how you are turning on the 20 lights.
For example:
The lighting technology you are using supports groups.
You have created a native group containing 20 lights.
You use the appropriate service in Home Assistant to activate that native group.
That means you only need to transmit one command to turn on 20 lights. In that case, thereās no improvement in performance or efficiency if you go through the trouble of determining which oneās are on/off.
On the other hand, if you are turning on the 20 lights by sending 20 commands, one to each of the 20 lights, then thereās a benefit to determine whatās on/off in order to minimize traffic. All it takes is one template to determine which lights, out of the 20, are now off.
Okay, Iāve seen similar template wizardry to iterate through a domain of lights, but this would be a subset of that group and then iterating through that subset that is āoffā to issue āonā commands. (Iām assuming something like z_wave here ?)
As youāve said it, it it must be possible, but surely you will be banned from the magic circle for disclosing such wizzarding tricks ?
What is this āmagic circleā you speak of? (First rule of Fight Club ā¦)
Here are two ways to do it. The templates in both examples produce a string containing a comma-separated list of light entities that are off.
light.garage,light.kitchen,light.porch
If none of the lights are off then the template returns none (because thatās an acceptable way of indicating āno entitiesā, whereas leaving it blank is not).
In this example, the 20 lights are defined in a list:
NOTE
The assumption Iāve made is that the light domain contains more than 20 lights and the goal here is to just use a subset of them (i.e. just 20). The template is simplified if the goal is to use all available lights.
Princess Bride. Definitely a must-see during these self-isolating times.
Vizziniās āInconceivable!ā is made even more priceless by Inigoās observation: āYou keep using that word, I do not think it means what you think it means.ā
Weāre definitely off-topic now but I canāt help but think thereās some kind of āinside jokeā when they cast Wallace Shawn to portray Vizzini, a Sicilian mob boss. Donāt get me wrong, Shawn is fantastic in the role but as Sicilian as āmac 'n cheeseā. Iām probably over-thinking it ā¦
Thanks guys for your input.
My group is a light group (https://www.home-assistant.io/integrations/light.group/).
The group is comprised of lights from multiple manufacturers: xiaomi (zigbee and wifi), IKEA (zigbee), random wifi lights, and other non-smart lights that are connected to zigbee power outlets (then converted to a power switch - https://www.home-assistant.io/integrations/light.switch/).
I then call the service ālight.turn_onā for the light group.
My light domain containās about 40 lights, all separated into areas - each with their own light group. So if I were to implement code to separate them, I would apply the same to each of my groups.
With this extra information, would you say there would be a noticeable performance improvement (network, I/O, or otherwise) by implementing Tarasā code? If so, I suppose I should also implement something similar to turn off only the lights that are not already off after no motion is detected for X minutes (rather than turning off the entire light group, even though some lights are already off)?
Erm !
I played with zigbee early on and had some problems (you are screwed if you turn it off at the switch, if you convice your family not to use the switch you need a fob thingy taped up next to the switch or you go (as Taras did) for voice control.
((I didnāt know you used NodeRed !!! Iām (TBH) shocked !!! Why ? ), (and what happened to āpremiseā ?))
It is possible (I believe, but never take anyoneās āguessā as āgospelā (I donāt even take āgospelā as āgospelā ! )) to group zigbee at the hub when you pair them (mainly hue i think). in which case that would be faster, else Tarasā is the way to go. it would also show marginal improvements over wifi ethernet and definatly for z wave.
Suck it and see
Iām pretty used to not using the light switch now. Was a bit of a nuisance at first, but no real issues with ignoring the light switches. Iām in Australia and z wave is pretty much either non-existant or super expensive. I use conbee ii as my hub, but as not all my lights are on deconz, I donāt use the groups function on there. I didnāt really see the point of grouping them on there, and then again on HA for the lights that are not on deconz. I just group all the individual lights as a HA light group.
@Burningstone uses deconz and may better advise.
Iām pretty sure if you groped them on deconz and then again on HA youād have the best of both worlds.
Regardless Iām āstronglyā leaning towards Tarasās code as your best option.
Though itās fairly easy to do without, so try it first without, test and observe, then test and time (hard to do both) - change the automation, then rinse and repeat - go with what works for you - And remeber to report back
I think Tarasās post deserves the solution tick though so please do that regardless