Group-like automation with Node-Red

I have several lights in a room. I’d like to have an additional switch which works like a Group in HA but I dont want to make Group if it is possible since maintaining groups is a pain with tons of devices. What I want:

  • If I turn on any light in the room, this additional switch has to turn on
  • If I turn off all the lights in the room the switch has to turn off
  • If I turn off the switch, all lights has to turn off in the room

Or can I identify somehow all lights in a room?

You’re literally asking for light groups without specifying which lights are in the groups.

You might be able to do this with the ‘Areas’ and the ‘light’ service to reference an area. But you’ll end up writing scripts for each area, for each action, and then have to figure some sort of template to read if any lights are on, and update your new pseudo group card in lovelace.

By then you could have just edited the yaml once and been done with it with built in mechanisms that just work.

It would be nice if a light group could include an ‘Area ID’ and pull those areas lights automagically

service: light.turn_on
target:
  area_id: 50c7cd2591fd4505a240675bb77f7166
data:

Thanks a lot! Even better would be able to use groups in UI. E.g. when I create/open an entity in configuration, I could check checkboxes of groups and it means that the given entity added to the checked group… Whith this if I change anything, even the entity ID, it remains in its group. Buth this is missing.
As a workaround I made light group under lights.yaml
I think there is a better solution with Node-Red, but I’m not good enough in it.

1 Like

The thing with light groups is that it’s a one-and-done situation. You’re lightbulbs don’t change rooms often, do they? It’s just not a high demand need I don’t think. Eventually I’m sure there will be a light group admin UI.

For lovelace UI look for the Folding Group Entity Row Card Folding Group Entity Row Card

For the top level switch / group enter your light group entity.
Then list the sub group / individual entities below it. Really nice UI control for groups and individuals without cluttering everything up.