Skip to content

Instantly share code, notes, and snippets.

@alphasixtyfive
Last active February 17, 2022 10:56
Show Gist options
  • Save alphasixtyfive/499986276170a52fcb7a767569b7229d to your computer and use it in GitHub Desktop.
Save alphasixtyfive/499986276170a52fcb7a767569b7229d to your computer and use it in GitHub Desktop.
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'] %}
{{ states.light | selectattr('state', 'eq', 'on') | map(attribute='entity_id') | map('area_name') | reject('in', exclude_areas) | unique | list }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment