From 4e66b74f141c484421c8bb5f9968d225e1711273 Mon Sep 17 00:00:00 2001 From: Nils Reiter Date: Sat, 18 May 2024 16:05:30 +0200 Subject: [PATCH] it's now possible to specify devices --- ha-scenes.yaml | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/ha-scenes.yaml b/ha-scenes.yaml index 475d59f..ae23b73 100644 --- a/ha-scenes.yaml +++ b/ha-scenes.yaml @@ -19,6 +19,11 @@ blueprint: ## Changelog + ### 2.4 + + - It is now possible to also specify devices. If a device has multiple entities from the + light domain, all will be added individually. + ### 2.3 - Selecting the lights is now done via proper lists, and no longer relies on parsing json @@ -408,7 +413,7 @@ variables: {% for a in ns.areas %} {% set ns.l = ns.l + area_entities(a)|select('match', 'light.')|list %} {% endfor %} - + {% if target.entity_id is defined %} {% if target.entity_id is iterable and not target.entity_id is string %} {% set ns.l = ns.l + (target.entity_id|list) %} @@ -416,7 +421,19 @@ variables: {% set ns.l = ns.l + [target.entity_id] %} {% endif %} {% endif %} - + + ## process devices + {% if target.device_id is defined %} + {% if target.device_id is iterable and not target.device_id is string %} + {% for f in target.device_id %} + {% set ns.l = ns.l + device_entities(f)|select('match', 'light.')|list %} + {% endfor %} + {% else %} + {% set ns.l = ns.l + device_entities(target.device_id)|select('match', 'light.')|list %} + {% endif %} + {% endif %} + + ## process labels {% if target.label_id is defined %} {% if target.label_id is iterable and not target.label_id is string %} @@ -427,11 +444,11 @@ variables: {% set ns.l = ns.l + label_entities(target.label_id)|select('match', 'light.')|list %} {% endif %} {% endif %} - + {% if skipgroups|default(true) %} {% set ns.l = expand(ns.l) | rejectattr('attributes.entity_id', 'defined') | map(attribute = "entity_id") | list %} {% endif %} - + {% if onlyonlights|default(false) %} {% set ns.l = ns.l | select('is_state', 'on') %} {% endif %} @@ -520,4 +537,4 @@ sequence: - wait_for_trigger: - platform: template value_template: "{{ (( lights | list | count ) != (lights | select('is_state', 'on') | list | count)) }}" - timeout: "{{ repeat_delay }}" + timeout: "{{ repeat_delay }}" \ No newline at end of file