Lovelace Card to show if windows (group) is open or closed

Hi Team

I’m new to the HA platform, but it is moving forward - thanks for all your work. Keep it up.

My first automation project is to solve the situation when leaving the house .- ‘Are all the windows closed ?’.

The solution is to place windows sensors on all my windows, and then place a tablet next to the front door (at the inside ;-), which shows with a large ‘icon’ if all windows are close or if some are open.

I have used:
-Rasp with Hassio.
-Aeon Labs ZW090 Z-Stick Gen 5 (z wave)
-Cam NEO Coolcam door/window sensors (z wave)
-simple tablet browsing Lovelace.

And to get the sensors to work:

In the customize.yaml-
binary_sensor.neo_coolcam_window1_detector_sensor:
device_class: window

So with this config, they show up as ‘windows’ and with a blue icon and closed windows when closed, and a yellow icon and open window when open.

And with this in the group.yaml-
OpenWindows:
control: hidden
entities:
- binary_sensor.neo_coolcam_window1_detector_sensor
- binary_sensor.neo_coolcam_window2_detector_sensor

I have one group ‘definition’ - OpenWindows, that indicates if just one window is open. (with on/off - would like this to be Open/closed and a windows icon - how ?)

Using Lovelace as ui at the tablet.
So the base elements are working.

Now to the question:
I would like to have a ‘Card’ or other large icon in lovelace that is Red or Green depending on if the ‘OpenWindows’/group is on or off. Maybe with some ‘filter’ to list at the red ‘box’ the windows that are open.

What would you recommend ?
Looking forward to some good comments.

Regards Joern

1 Like
    cards:
      - type: entity-filter
        state_filter:
          - 'on'
        card:
          type: glance
          show_state: false
          columns: 2
        show_empty: false
        entities:
          - binary_sensor.main_entrance
          - binary_sensor.living_room_shutter
          - binary_sensor.living_room_window
          - binary_sensor.bathroom_window
          - binary_sensor.bedroom_shutter
          - binary_sensor.bedroom_window
          - binary_sensor.guest_room_shutter
          - binary_sensor.guest_room_window
          - binary_sensor.kitchen_door
          - binary_sensor.kitchen_door_shutter
          - binary_sensor.kitchen_window
          - binary_sensor.kitchen_window_shutter
          - binary_sensor.laundry_window
          - binary_sensor.office_shutter
          - binary_sensor.office_window
          - binary_sensor.private_shower_window

You might find this convenient as it shows only the windows/doors that are open.
Try it if you like. Just replace my entities with yours.
These are two cards. One entity-filter card that will filter the closed windows and hide them. And one glance card to show them in a very minimal view.

Read more about the entity-filter card here:


And the glance card here:

Thanks for responding.
And it works nice. I have a card that only shows the windows that are open. Thanks.

But, I would like to show something when all windows are closed (and the list is empty) - like a text ‘All windows are closed’, or a Green background… and is it possible to change the background to red when there are open windows (when the list contains elements) ?

Been looking at the ‘Conditional’ card, but can’t get it to work.

Any suggestions ?

You can try a template binary sensor.

You can use a template to determine if everything is closed and have it give you a message.
I am not sure about the background you ask for tho… sorry.

I have built exactly such a setup.

First, in configuration.yaml I define a custom sensor that defines which other sensors are supposed to trigger the warning sign:

binary_sensor:
  - platform: template
    sensors:
      housesecure:
        device_class: opening
        value_template: >-
          {{ is_state('binary_sensor.backdoor', 'off') and is_state('binary_sensor.bathroomwindow', 'off') and ... }}

My ui-lovelace.yaml then has a hidden card with a red stop sign that is only shown when that “sensor” is off:

resources:
  - url: /local/custom-lovelace/lovelace-card-modder/card-modder.js
    type: js

views:
  - title: Status
    cards:
      - type: horizontal-stack
        cards:
          - type: conditional
            conditions:
              - entity: binary_sensor.housesecure
                state_not: "on"
            card:
              type: picture
              image: /local/stop.svg
          - type: custom:card-modder
            style:
              "--paper-item-icon-color": green
              "--paper-item-icon-active-color": red
            card:
              type: entities
              entities:
                - binary_sensor.backdoor
                - binary_sensor.bathroomwindow

card-modder.js is from https://github.com/thomasloven/lovelace-card-modder. It is used to show the icon of the open entity in red instead of green.

stop.svg is from https://commons.wikimedia.org/wiki/Stop and had to be placed in .homeassistant/www/stop.svg.

1 Like