Control all lights in given area(s)


I somehow get a feeling reading forums that groups are thing of a past, and one should use areas instead? As all devices are put into some area anyhow, how could I create a button to toggle light state of e.g. areas a and b? Or just b?

I saw some example of using template, and failed while modifying it in ha “edit dashboard → add button” gui:

show_name: true
show_icon: true
type: button
  action: toggle
entity: {{ expand(area_entities('Piha')) | selectattr('domain', 'eq', 'light') | map(attribute='entity_id') | list }}
show_state: true

It complains about comma in selectaddr. Is this even the right direction to go to?

1 Like

I copied the template from here, simplifying it by removing state.

You have to build a script (or automation) first. The default button card is not templatable

Thanks. Would it still show the state of lights in button? Or any indication if any of the lights are on?

What I’d like to have is kinda like a slider in right top corner of lights card for the list of lights already does. Not just a dummy script without state indication, but if any of the lights is on, icon would show up bright, and when all are off, it would show dim.

What about an approach without template:

type: button
  action: call-service
  service: light.toggle
  data: {}
    area_id: your_area

Or you could create a (light) group. I don’t think so that groups will disappear in the HA universe.


Thanks, good tip. Now I actually found how the groups are done in gui too. Perhaps I just got it wrong, I try using groups now.

Perhaps you mixed it up with universal groups.

1 Like

yes, as a newbie I mixed that up to groups :smiley: