My current version

Here is my current version. I ignore lights that start with, end with, or contain certain strings. I now store this list in the "variable" custom component. 

Source: https://github.com/brianhanifin/Home-Assistant-Config/blob/master/scripts/lights/lights_on_update.yaml
This commit is contained in:
Brian Hanifin 2019-02-25 18:24:49 -08:00 committed by GitHub
parent 380b67a127
commit f52e3d4c5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 6 deletions

View File

@ -16,13 +16,21 @@ sensor:
lights_on:
value_template: >
{% macro get_lights_on() -%}
{%- for group in states.group|groupby('state') -%}
{%- for group in states.light|groupby('state') -%}
{%- for entity in group.list -%}
{%- if entity.state == 'on'
and entity.name.split(' ')[1]|lower == 'lights'
and entity.name.split(' ')[0]|lower != 'interior'
and entity.name.split(' ')[0]|lower != 'all'
-%}
{%- if entity.state == 'on'
and entity.entity_id != 'light.dummy'
and entity.entity_id != 'light.garage_entry_light'
and entity.entity_id != 'light.hue'
and entity.entity_id != 'light.living_room'
and entity.entity_id != 'light.kitchen_undercabinet'
and entity.entity_id != 'light.porch_light'
and entity.entity_id != 'light.shoe_closet_light'
and not ('gateway_light' in entity.entity_id)
and not ('hub' in entity.entity_id)
and not (entity.entity_id).endswith('_led')
and not (entity.entity_id).endswith('nightlight')
and not (entity.entity_id).startswith('light.lamplinc') -%}
{{ entity.entity_id }}{{ ' ' }}
{%- endif -%}
{%- endfor -%}