Fix trigger syntax for area-based sensor selection
Replaces invalid 'target' key in trigger with proper 'entity_id' using variables section to resolve target selector. Simplifies template logic by centralizing sensor resolution. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -69,9 +69,19 @@ blueprint:
|
|||||||
step: 1
|
step: 1
|
||||||
unit_of_measurement: seconds
|
unit_of_measurement: seconds
|
||||||
|
|
||||||
|
variables:
|
||||||
|
sensors: >
|
||||||
|
{% if occupancy_sensors.entity_id is defined %}
|
||||||
|
{{ occupancy_sensors.entity_id }}
|
||||||
|
{% elif occupancy_sensors.area_id is defined %}
|
||||||
|
{{ area_entities(occupancy_sensors.area_id) | select('match', 'binary_sensor.*') | select('device_attr', 'device_class', 'occupancy') | list }}
|
||||||
|
{% else %}
|
||||||
|
[]
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
- trigger: state
|
- trigger: state
|
||||||
target: !input occupancy_sensors
|
entity_id: "{{ sensors }}"
|
||||||
|
|
||||||
condition: []
|
condition: []
|
||||||
|
|
||||||
@@ -79,11 +89,7 @@ action:
|
|||||||
- choose:
|
- choose:
|
||||||
- conditions:
|
- conditions:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: >
|
value_template: "{{ expand(sensors) | selectattr('state', 'eq', 'on') | list | count > 0 }}"
|
||||||
{% set sensors = occupancy_sensors.entity_id if occupancy_sensors.entity_id is defined
|
|
||||||
else (area_entities(occupancy_sensors.area_id) | select('match', 'binary_sensor.*') | select('device_attr', 'device_class', 'occupancy') | list) if occupancy_sensors.area_id is defined
|
|
||||||
else [] %}
|
|
||||||
{{ expand(sensors) | selectattr('state', 'eq', 'on') | list | count > 0 }}
|
|
||||||
sequence:
|
sequence:
|
||||||
- if:
|
- if:
|
||||||
- condition: template
|
- condition: template
|
||||||
@@ -103,20 +109,12 @@ action:
|
|||||||
transition: !input turn_on_transition
|
transition: !input turn_on_transition
|
||||||
- conditions:
|
- conditions:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: >
|
value_template: "{{ expand(sensors) | selectattr('state', 'eq', 'on') | list | count == 0 }}"
|
||||||
{% set sensors = occupancy_sensors.entity_id if occupancy_sensors.entity_id is defined
|
|
||||||
else (area_entities(occupancy_sensors.area_id) | select('match', 'binary_sensor.*') | select('device_attr', 'device_class', 'occupancy') | list) if occupancy_sensors.area_id is defined
|
|
||||||
else [] %}
|
|
||||||
{{ expand(sensors) | selectattr('state', 'eq', 'on') | list | count == 0 }}
|
|
||||||
sequence:
|
sequence:
|
||||||
- delay:
|
- delay:
|
||||||
seconds: !input off_delay
|
seconds: !input off_delay
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: >
|
value_template: "{{ expand(sensors) | selectattr('state', 'eq', 'on') | list | count == 0 }}"
|
||||||
{% set sensors = occupancy_sensors.entity_id if occupancy_sensors.entity_id is defined
|
|
||||||
else (area_entities(occupancy_sensors.area_id) | select('match', 'binary_sensor.*') | select('device_attr', 'device_class', 'occupancy') | list) if occupancy_sensors.area_id is defined
|
|
||||||
else [] %}
|
|
||||||
{{ expand(sensors) | selectattr('state', 'eq', 'on') | list | count == 0 }}
|
|
||||||
- action: light.turn_off
|
- action: light.turn_off
|
||||||
target: !input lights
|
target: !input lights
|
||||||
data:
|
data:
|
||||||
|
|||||||
Reference in New Issue
Block a user