From d338a7298a822b8a1eceff5021d3e4676775043a Mon Sep 17 00:00:00 2001 From: John Ogle Date: Wed, 5 Nov 2025 17:41:10 -0800 Subject: [PATCH] Revert to simple multiple entity selector MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Simplifies sensor selection back to multiple entity selector instead of complex target/area approach. More reliable and straightforward while still supporting multiple sensors. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- occupancy_controlled_lights.yaml | 38 +++++++++----------------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/occupancy_controlled_lights.yaml b/occupancy_controlled_lights.yaml index 9d65fd2..a873e28 100644 --- a/occupancy_controlled_lights.yaml +++ b/occupancy_controlled_lights.yaml @@ -5,12 +5,12 @@ blueprint: input: occupancy_sensors: name: Occupancy Sensors - description: Occupancy sensors to monitor (can select individual sensors or entire areas) + description: Binary sensors that detect occupancy/presence in the area selector: - target: - entity: - domain: binary_sensor - device_class: occupancy + entity: + domain: binary_sensor + device_class: occupancy + multiple: true lights: name: Lights description: Light entities to control @@ -69,33 +69,17 @@ blueprint: step: 1 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: - - platform: event - event_type: state_changed - event_data: - domain: binary_sensor + - platform: state + entity_id: !input occupancy_sensors -condition: - - condition: template - value_template: "{{ trigger.event.data.entity_id in sensors }}" - - condition: template - value_template: "{{ state_attr(trigger.event.data.entity_id, 'device_class') == 'occupancy' }}" +condition: [] action: - choose: - conditions: - condition: template - value_template: "{{ expand(sensors) | selectattr('state', 'eq', 'on') | list | count > 0 }}" + value_template: "{{ expand(occupancy_sensors) | selectattr('state', 'eq', 'on') | list | count > 0 }}" sequence: - if: - condition: template @@ -115,12 +99,12 @@ action: transition: !input turn_on_transition - conditions: - condition: template - value_template: "{{ expand(sensors) | selectattr('state', 'eq', 'on') | list | count == 0 }}" + value_template: "{{ expand(occupancy_sensors) | selectattr('state', 'eq', 'on') | list | count == 0 }}" sequence: - delay: seconds: !input off_delay - condition: template - value_template: "{{ expand(sensors) | selectattr('state', 'eq', 'on') | list | count == 0 }}" + value_template: "{{ expand(occupancy_sensors) | selectattr('state', 'eq', 'on') | list | count == 0 }}" - action: light.turn_off target: !input lights data: