Replaces unsupported domain/device_class trigger with event-based approach that listens to state_changed events and filters for selected occupancy sensors. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
129 lines
4.1 KiB
YAML
129 lines
4.1 KiB
YAML
blueprint:
|
|
name: Occupancy Controlled Lights with Adaptive Lighting
|
|
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
|
|
input:
|
|
occupancy_sensors:
|
|
name: Occupancy Sensors
|
|
description: Occupancy sensors to monitor (can select individual sensors or entire areas)
|
|
selector:
|
|
target:
|
|
entity:
|
|
domain: binary_sensor
|
|
device_class: occupancy
|
|
lights:
|
|
name: Lights
|
|
description: Light entities to control
|
|
selector:
|
|
target:
|
|
entity:
|
|
domain: light
|
|
adaptive_lighting_switch:
|
|
name: Adaptive Lighting Switch
|
|
description: Adaptive lighting switch entity for this room
|
|
default: {}
|
|
selector:
|
|
entity:
|
|
domain: switch
|
|
integration: adaptive_lighting
|
|
turn_on_transition:
|
|
name: Turn On Transition
|
|
description: Transition time in seconds when turning lights on
|
|
default: 5
|
|
selector:
|
|
number:
|
|
min: 0
|
|
max: 300
|
|
step: 1
|
|
unit_of_measurement: seconds
|
|
turn_off_transition:
|
|
name: Turn Off Transition
|
|
description: Transition time in seconds when turning lights off
|
|
default: 15
|
|
selector:
|
|
number:
|
|
min: 0
|
|
max: 300
|
|
step: 1
|
|
unit_of_measurement: seconds
|
|
adapt_brightness:
|
|
name: Adapt Brightness
|
|
description: Whether to adapt brightness when turning on lights
|
|
default: true
|
|
selector:
|
|
boolean:
|
|
adapt_color:
|
|
name: Adapt Color
|
|
description: Whether to adapt color when turning on lights
|
|
default: true
|
|
selector:
|
|
boolean:
|
|
off_delay:
|
|
name: Off Delay
|
|
description: Time to wait after no motion before turning lights off
|
|
default: 0
|
|
selector:
|
|
number:
|
|
min: 0
|
|
max: 3600
|
|
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
|
|
|
|
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' }}"
|
|
|
|
action:
|
|
- choose:
|
|
- conditions:
|
|
- condition: template
|
|
value_template: "{{ expand(sensors) | selectattr('state', 'eq', 'on') | list | count > 0 }}"
|
|
sequence:
|
|
- if:
|
|
- condition: template
|
|
value_template: "{{ adaptive_lighting_switch != none and adaptive_lighting_switch != {} }}"
|
|
then:
|
|
- action: adaptive_lighting.apply
|
|
data:
|
|
entity_id: !input adaptive_lighting_switch
|
|
turn_on_lights: true
|
|
transition: !input turn_on_transition
|
|
adapt_brightness: !input adapt_brightness
|
|
adapt_color: !input adapt_color
|
|
else:
|
|
- action: light.turn_on
|
|
target: !input lights
|
|
data:
|
|
transition: !input turn_on_transition
|
|
- conditions:
|
|
- condition: template
|
|
value_template: "{{ expand(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 }}"
|
|
- action: light.turn_off
|
|
target: !input lights
|
|
data:
|
|
transition: !input turn_off_transition
|
|
|
|
mode: single |