Skip to content

Instantly share code, notes, and snippets.

@alphasixtyfive
alphasixtyfive / open_windows.yaml
Last active February 17, 2022 10:55
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 }}
@alphasixtyfive
alphasixtyfive / lights_on.yaml
Last active February 17, 2022 10:56
Homeassistant - count lights that are on in specific areas
template:
- sensor:
- name: Lights on
icon: mdi:lightbulb
state: >-
{% set exclude_areas = [None, 'Volvo'] %}
{{ states.light | selectattr('state', 'eq', 'on') | map(attribute='entity_id') | map('area_name') | reject('in', exclude_areas) | list | count }}
attributes:
areas: >-
{% set exclude_areas = [None, 'Volvo'] %}
@alphasixtyfive
alphasixtyfive / insights.yaml
Created January 12, 2022 17:58
Homeassistant insights
template:
- sensor:
- name: Total entities
icon: mdi:shape
state: "{{ states | count }}"
- name: Total automations
icon: mdi:robot
state: "{{ states.automation | count }}"