Skip to content

Instantly share code, notes, and snippets.

@alphasixtyfive
Last active February 17, 2022 10:55
Show Gist options
  • Save alphasixtyfive/59e9f806d1135b34797295cc1a569255 to your computer and use it in GitHub Desktop.
Save alphasixtyfive/59e9f806d1135b34797295cc1a569255 to your computer and use it in GitHub Desktop.
Homeassistant - Count open windows
template:
- binary_sensor:
- name: Open windows
icon: mdi:window-open-variant
state: >-
{{ states.binary_sensor | selectattr('attributes.device_class', 'eq', 'door') | selectattr('state', 'eq', 'on') | map(attribute='entity_id') | map('area_name') | list | count > 0 }}
attributes:
areas: >-
{{ states.binary_sensor | selectattr('attributes.device_class', 'eq', 'door') | selectattr('state', 'eq', 'on') | map(attribute='entity_id') | map('area_name') | unique | list }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment