How to Access Room State?

In the auto-generated dash, there is a toggle at the top which reacts to individual entities being on or off within a specific area. It combines lights / switches / other entities.

Screenshot 2023-12-22 153900

Is it possible to access this ‘state’ without using a complex template?

I am trying to create a button card for (in this case) Dining Room which sets its colour based on all the entities in the room.

So behaviour of the button card should be (1) all entities off = white (2) any entity on = orange colour. I can tie the button colour to a single entity but I’d like to tie it to an Area. I don’t want to use groups because that would be a lot of manual setting up of groups for multiple rooms / devices and all devices already have their area set.

As you said the easiest solution is groups or templates :wink:

Here’s a template for you:

{{ 'on' in (area_entities(area_id('Living Room')) | select('match', 'light') | map('states') | list)  }}

Just replace the area id with the name of any room and it renders true if there is a light on in this room.

Thanks. How can I modify the select section to also match for switches?

Seems to be crazy to me to have to recalculate this stat if the default dash is already calculating it…

select('match', 'light')

select('match', 'switch')

The toggle at the top of the card is not actually an entity available in the backend. It is a control generated by the frontend.

Another option could be for you to create groups. Then you would not have to use templates.

@tom_l I actually set a watch on this thread because I was curious too. I think the question was how to make BOTH work, and I fooled around with the code but couldn’t figure out how to do both either, only one or the other. I realize it’s not an ideal way to do it but it was an interesting piece of code that intrigued me. Once the first select filters it down, there is no way to get at the switches too. I know it could be a loop and a variable but was curious if you really could do an OR between these (and I tried all variations of OR or IN or CONTAINS and could get but a single domain).

Ah, I see. Appologies. Try this:

| selectattr('domain', 'in', ['light', 'switch'])

As for groups with both you would have to use a legacy group. The new UI groups do not support mixed domains.

1 Like