Toggle switch for all of my lights but doesn't work

Hey everyone,
I need a switch for all of my hue lights and I tried this:

  - platform: template
switches:
 allhue:
   value_template: "{{ is_state('group.all_lights', 'on')}}"
   turn_on:
     service: group.turn_on
     entity_id: group.all_lights
   turn_off:
     service: group.turn_off
     entity_id: group.all_lights

Home Assistant didn’t put out any error so I thought I did it right but nothing goes off or on when I use it.
group.all_lights is definitely a thing when I go to states and look at my entities. Anything wrong in the switch code?

Thank you so much!

There are a few things to you need to know about groups:

  1. A group will be on when one, some, or all lights in the group are on.
  2. When the group is considered on, sending homeassistant.turn_on will do nothing.

Knowning that you should be good. Now on to your automation.

group.turn_on is not a valid service. THis is what you want:

- platform: template
  switches:
    allhue:
      value_template: "{{ is_state('group.all_lights', 'on')}}"
      turn_on:
        service: homeassistant.turn_on
        entity_id: group.all_lights
      turn_off:
        service: homeassistant.turn_off
        entity_id: group.all_lights
1 Like

Thank you so much, petro! This worked and helped me out a ton!! :slight_smile: I really appreciate it.

1 Like