Skip to content

Commit

Permalink
it's now possible to specify devices
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsreiter committed May 18, 2024
1 parent a398b1a commit 4e66b74
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions ha-scenes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -408,15 +413,27 @@ 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) %}
{% else %}
{% 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 %}
Expand All @@ -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 %}
Expand Down Expand Up @@ -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 }}"

0 comments on commit 4e66b74

Please sign in to comment.