I have a number of lights inside and outside my house that is integrated to home assistant. I am looking for a different aspect with turning all these lights on. i have created a group to switch on all the lights and it works perfectly but the problem is with switching off. During night time some of the lights will already be ON when i toggle group on switch but when i switch off its turns off all the lights including ones which were previously on too. that is not good. so can anybody suggest me a mechanism which would only switch off lights that was in off condition during when the group on switch was activated, leaving rest on.
If it’s always the same lights that are already on and you want to keep on, why not create three groups and do the following, e.g.:
- Group1 = lightA, lightB, lightC
- Group2 = lightD, lightE
- Group3 = Group1, Group2
This way you can turn all lights on by switching Group3 on and switch only Group1 or Group2 off, depending on which ones you’d like to stay on.
If it varies which lights were on and should stay on, I can only think of creating an input_boolean per light that gets set when you switch on the light individually (as a 2nd action) and not when it’s done in a group. This way you’d have a record of which light was on before you switched on the group and can turn off the lights again accordingly.
This might require heavy templating, though, in order to avoid an endless number of automations.
what service are you using to toggle?
light.toggle, or homeassistant.toggle or something else?
I don’t have my config in front of me (at work), but I have had groups of switches behave like you want with a toggle (eg if on, turn off and vice versa) - cant remember what service I used.
The Light Toggle Service seems to say it will behave like you ask.
SERVICE LIGHT.TOGGLE
Toggles the state of one or multiple lights using groups.
Note : If light.toggle
is used for a group of lights, it will toggle the individual state of each light.
i dont exactly want to toggle in group. In the night some of the lights will already be on . when i enable the all lights on functions all the lights in the system turns on but when i turn the same function off all the lights turn off including those which were on before the all lights in function. so i want a function that would allow me to switch on all the lights and switch off those lights which were switched on only with this all lights on fucntion leaving the already on lights on.
Then I am with @chairstacker. Setup some groups for the lights you want to all behave the same and switch those groups.
I light can be a member of more than one group!
I had some need for similar functionality a week ago. Can’t remember what it was, but I googled a lot and ran into a custom component that creates a scene dynamically of the current states of the said entities. So you could probably automate this so that on the ‘lights on’ click it first creates the scene -> then all lights on -> when pressed “all” lights off -> set back to the previously created scene.
Not sure if this would help but it’s the only solution that I found that even seemed to be close. I didn’t try it because it wouldn’t have worked with hass.io. Can’t remember the url/name either so feel free to google
You must be taking about SceneGen. it should have worked with the conventional home assistant but as you sai i am also waiting for some one to build an addon for it for hassio. thanks for the advice bro. it would have worked withh HA