Display if lights are left on

edit: see @chairstacker reply much simpler !

I have been “getting my head” around the Lovelace interface. I hadn’t realized you can combine multiple cards into a single view.

I needed a view which shows what lights have been left on in the house (forgetful teenagers). If no lights are on the card disappears. This combines the conditional-card and entity-filter-card into a single view.

It uses the default group default.all.lights as the trigger for the conditional-card. If all lights are “off” then the entity-filter-card is not displayed. The entity filter card then displays any of the lights that are on. All this is achieved without a single line of code!

 - type: conditional
   conditions:
     - entity: group.all_lights
       state: "on"
     card: 
       type: entity-filter
       entities:
         - < entity  of light >
         - < entity of next light >
         - < etc >
       state_filter:
         - "on"
       card:
         type: entities
         title: Lights left on

Hope this helps someone :slight_smile:

3 Likes

Can’t you just achieve the same with show_empty: false in the entity-filter card?

This works fine for me:

      - type: entity-filter
        card:
          type: glance
          title: Cameras - offline
          show_state: false
        entities:
          - entity: device_tracker.cam1
            name: Camera 1
          - entity: device_tracker.cam2
            name: Camera  2
          - entity: device_tracker.cam3
            name: Camera  3
        state_filter:
          - not_home
        show_empty: false

Or is there something I’m not getting correctly?

@ chairstacker much simpler thankyou !

However it given me another idea. By combining both the conditional-card and entity-filter-card I can display or not display cards based on entity’s not contained in the entity filter , so for instance I can display which lights are on when everyone is out.

I use this (light.garden its a group of light, that I have to exclude to avoid duplicate)

  - type: "custom:monster-card"
    card:
      type: Entities
      title: Lights that are ON
      show_header_toggle: false
    filter:
      include:
        - domain: light
          state: 'on'
        - entity_id: '*switch.light*'
          state: 'on'
      exclude:
        - entity_id: "light.garden"
1 Like

what ! wild cards on entity id’s and this works on all cards ?

What else don’t I know :slight_smile:

1 Like

yes pretty powerful stuff