Group Light and Switches

I am wondering if a create a group of light and switches I tried this but it does not work of course:

light:
  - platform: group
    name: livingroom lights
    entities:
      - light.Bulb01
      - light.Bulb02
      - light.Bulb03
      - switch.plug2
3 Likes

Use this instead if you have other entity that is not light-

group:
  living_room_lights:
    name: Living Room Lights
    entities:
      - light.bulb01
      - light.bulb02
      - light.bulb03
      - switch.plug2

If you want to use automation to turn it ON/OFF, use the call service of homeassistant.turn_on or homeassistant.turn_off.

4 Likes

That’s a Light Group which is different from a Group.

A Light Group is used to control state, brightness, and color of lights.

A Group controls the state of various entities, typically entities with on/off state values (but not necessarily limited to that).

EDIT
Ninja’d!

1 Like

This worked:

group:
  LivingroomLights:
    name: Livingroom Lights
    entities:
       - light.Bulb01
       - light.Bulb02
       - light.Bulb03
       - switch.plug2
2 Likes

The custom of this community forum is to assign the Solution tag to the first, or best, post that answers the question. In this case, that would be ardysusilo’s post, not your own post that simply applied the suggestion.

For more information, refer to guideline 21 of the FAQ.

1 Like

@123
@ardysusilo

Sure, Im happy to mark ardysusilo’s post as solution.

Regards

John

1 Like

Since Groups are not supported in HOMEKIT is there any other way to implement a light group with a switch? maybe with a template?

light:
  - platform: group
    name: livingroom lights
    entities:
      - light.Bulb01
      - light.Bulb02
      - light.Bulb03
      - switch.plug2

Create a Light Switch from switch.plug2 then include it in the Light Group you originally created.

light:
  - platform: switch
    name: Plug2
    entity_id: switch.plug2

  - platform: group
    name: livingroom lights
    entities:
      - light.bulb01
      - light.bulb02
      - light.bulb03
      - light.plug2
5 Likes

That works well however not sure how I should reference the lights in HomeKit, basically what i should replace group.livingroomlights with what?

homekit:
  - filter:
      include_entities:
        - cover.garage_door
        - group.livingroomlights <--------
        - switch.bedroom_lights 

light.livingroom_lights

That’s how you originally defined it.

Check it at Developer Tools.

I think it will be light.livingroom_lights

Thanks guys!

I got it all to work like this:

homekit:
  - filter:
      include_entities:
        - cover.garage_door
        - light.livingroom_lights
        - switch.bedroom_lights

.
.
.

light:
  - platform: switch
    name: Plug2
    entity_id: switch.plug2


  - platform: group
    name: livingroom lights
    unique_id: livingroom_lights
    entities:
      - light.bulb01
      - light.bulb02
      - light.bulb03
      - light.plug2

Glad to hear that using a Light Switch helped to solve the problem of getting the switch included in the Light Group.

Hi Guys,

I tried this solution this morning and it didn’t work. It created a group, but when you look into the group it states it has no unique_id. So you can’t perform group actions on the entities, it just comes up in Lovelace greyed out.

Checking the Entities page in devices doesn’t give you much, but shows the group as defined with a red marker next to it. You drill into the details and the “Related” page is blank, no related items found.

I tried defining a unique_id manually in the yaml but this didn’t seem to have worked… So I tried the hail Mary of a full restart. It came back up seemingly not working. I actually started writing a query to this thread when I went back some minutes later to check on details, and found of a sudden it was working. No real explanation as to why it took 5 minutes to decide it would work. My z2m runs very lumpy so maybe that delayed startup…

The critical bit of the puzzle was, I needed to add a unique ID manually for the above to work:

  - platform: group
    name: Patio Lights All
    unique_id: Unique_PatioLightGroup_ID
    entities:
      - light.PatioCoverLight
      - light.PatioArborLight

It refused to work without this.

Rob

there is a heavy limitation here. Some lights are switches, others are lights. This is the only way to combine them which is manual. And you can’t assign a custom icon, because you can’t assign a unique_id.

Is there a way to have this hybrid group of switches and lights and set a custom icon?

1 Like

I think #8 by @123 (Taras) should be marked as the solution to this question!

It is vital to understand that a Light Group is more than a normal Group. A Group can only be switched on or off. In a Light Group you can control additionally properties like brightness and color.

The solution of Taras provides you with a way to integrate switches in such a Light Group. They will then follow the on/off state of the group and simply ignore any color or other settings, just like lights do that are not dimmable.