Dynamic Button Card Dependent on Entity State(s) in Room

Hey all, I have what I think is a pretty easy solve, but I seem to be searching for the wrong terms.

Suppose I have a button card w/ icon lightbulb-outline:

  • On tap navigates to room card and in the room itself there are several entities (in this example n=2)

  • On Hold turns off all entities in the room (this is done through node red flow)

So, both of those things I can get to work however, what I really want is if anyone of the entities in the aforementioned room have state of on, the icon on the button is yellow instead of the default white. (And if all the entities in the room are off, the icon is the default white).

I have included a small sketch of how I expect it to work. Any points in the right direction would be greatly appreciated.

You could create a group with characteristic all: false . Then use the new entity (e.g. group.kitchen) in your button-card. Template the icon


type: custom:button-card
styles:
   icon: 
     - color:
         [[[
           if (entity.state == 'on') return 'yellow'; return 'white';
         ]]]

or try it with

type: custom:button-card
color_type: icon

or use it in state section:


type: custom:button-card
show_state: true
state: 
  - value: 'on'
    icon: mdi:bulb-outline
    color: yellow
1 Like

Thanks - the characteristic all:false is what I was missing. Much appreciated.