Here we go again.... Groups and Light Groups or Tags

I know this has probably been done to death, but i’m trying to work out the best way to do this. I have quite a few lights now and for different purposes.

Is their a way to tag a light so that it can belong to multiple groups?

In my living room i have strip lights, reading lamps, Under bench lamps and they all server different purposes. ie: At night only the strip backlights will come on.

I know i can do multiple groups, but that means creating a group, and then adding every light to it. Is their another way, like what openhab used to do, where you could just ‘tag’ an item with a group and then your automation would just say “Turn off Strip light”.

Any ideas? or do i just suck it up and add them all into groups in yaml…

Suck it up. :slight_smile:

You do have to assign the light to multiple groups. There’s no other way. Doesn’t take that long.

Also you can be smart about it. e.g.

The light groups, light.front_downlights and light.rear_downlights can be put in the light group light.downlights, which itself can go in light.all_lights. No need to specify all the individuals.

1 Like

I had this thought myself this morning too! It would be much more simple to manage groups when you change your config a lot if you could just tag the groups that the entity belonged to during definition. I’ve found it very challenging to keep my groups list in-sync with my changing entities (mostly automation changes) so I’ve mostly given up on groups. If instead, you listed the groups to which the entity belonged in the definition it the configuration would be much more natural.

For example:

binary_sensor:
  - platform: mqtt
    name: 'Sensor near Kitchen Sink'
    state_topic: '433/Kitchen_Sink_Moisture'
    off_delay: 120
    device_class: moisture
    groups:
       - all_moisture_sensors
  - platform: mqtt
    name: 'Sensor near Power Room Sink'
    state_topic: '433/Powder_Room_Sink_Moisture'
    off_delay: 120
    device_class: moisture
    groups:
       - all_moisture_sensors

group:
  all_moisture_sensors:
    name: All Moisture Sensors

Instead of:

binary_sensor:
  - platform: mqtt
    name: 'Sensor near Kitchen Sink'
    state_topic: '433/Kitchen_Sink_Moisture'
    off_delay: 120
    device_class: moisture
  - platform: mqtt
    name: 'Sensor near Power Room Sink'
    state_topic: '433/Powder_Room_Sink_Moisture'
    off_delay: 120
    device_class: moisture

group:
  all_moisture_sensors:
    name: All Moisture Sensors
    entities:
      - binary_sensor.sensor_near_kitchen_sink
      - binary_sensor.sensor_near_power_room_sink
      - binary_sensor.sensor_near_guest_bathroom_sink

This way, if I add or remove an entity, the group list is also automatically adjusted – instead of it always being an after thought – oops, I guess I forgot to remove the dead entity from my groups list again…