Support area-based motion sensor selection

Updates occupancy controlled lights to use target selector like lights, allowing selection of entire areas of motion sensors. Lights turn on when any sensor in the selected areas/entities detects motion and turn off when all are clear for the delay period.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-05 17:20:11 -08:00
parent b894471828
commit d03b80a211

View File

@@ -1,12 +1,13 @@
blueprint: blueprint:
name: Occupancy Controlled Lights with Adaptive Lighting name: Occupancy Controlled Lights with Adaptive Lighting
description: Automatically turn lights on/off based on occupancy sensor with adaptive lighting support description: Automatically turn lights on/off based on multiple occupancy sensors with adaptive lighting support. Lights turn on when any sensor detects motion and turn off only when all sensors are clear for the configured delay.
domain: automation domain: automation
input: input:
occupancy_sensor: occupancy_sensors:
name: Occupancy Sensor name: Occupancy Sensors
description: Binary sensor that detects occupancy/presence description: Occupancy sensors to monitor (can select individual sensors or entire areas)
selector: selector:
target:
entity: entity:
domain: binary_sensor domain: binary_sensor
device_class: occupancy device_class: occupancy
@@ -70,16 +71,19 @@ blueprint:
trigger: trigger:
- trigger: state - trigger: state
entity_id: !input occupancy_sensor target: !input occupancy_sensors
condition: [] condition: []
action: action:
- choose: - choose:
- conditions: - conditions:
- condition: state - condition: template
entity_id: !input occupancy_sensor value_template: >
state: "on" {% 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
@@ -98,15 +102,21 @@ action:
data: data:
transition: !input turn_on_transition transition: !input turn_on_transition
- conditions: - conditions:
- condition: state - condition: template
entity_id: !input occupancy_sensor value_template: >
state: "off" {% 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: state - condition: template
entity_id: !input occupancy_sensor value_template: >
state: "off" {% 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: