commit 45e5d292f6748cf461a8c2010dda62db08a9b564 Author: Alex Kelly Date: Sun Nov 29 21:18:17 2026 -0500 first commit diff --git a/light-control.yaml b/light-control.yaml new file mode 100644 index 0000000..cbefecd --- /dev/null +++ b/light-control.yaml @@ -0,0 +1,149 @@ +blueprint: + name: Occupancy light with dim warning + description: > + Turns light on at occupancy. On vacancy, starts an idle timer. When it + finishes, dims the light as a warning and starts a warn timer. When that + finishes, turns the light off. Any new occupancy cancels both timers. + domain: automation + input: + occupancy_sensor: + name: Occupancy sensor + selector: + entity: + filter: + - domain: binary_sensor + light_entity: + name: Light + selector: + entity: + filter: + - domain: light + idle_timer: + name: Idle timer helper + selector: + entity: + filter: + - domain: timer + warn_timer: + name: Warning timer helper + selector: + entity: + filter: + - domain: timer + lux_sensor: + name: Illuminance sensor (optional) + default: '' + selector: + entity: + filter: + - domain: sensor + lux_threshold: + name: Lux threshold + default: 2500 + selector: + number: + min: 0 + max: 100000 + mode: box + on_brightness: + name: On brightness (%) + default: 100 + selector: + number: + min: 1 + max: 100 + dim_brightness: + name: Warning dim brightness (%) + default: 30 + selector: + number: + min: 1 + max: 100 + +mode: queued +max: 5 + +variables: + lux_sensor: !input lux_sensor + lux_threshold: !input lux_threshold + light_entity: !input light_entity + +triggers: + - trigger: occupancy.detected + target: + entity_id: !input occupancy_sensor + options: + behavior: each + id: occ_on + - trigger: occupancy.cleared + target: + entity_id: !input occupancy_sensor + options: + behavior: each + id: occ_off + - trigger: timer.finished + target: + entity_id: !input idle_timer + id: idle_done + - trigger: timer.finished + target: + entity_id: !input warn_timer + id: warn_done + +conditions: [] + +actions: + - choose: + - conditions: + - condition: trigger + id: occ_on + sequence: + - action: timer.cancel + target: + entity_id: + - !input idle_timer + - !input warn_timer + - if: + - condition: template + value_template: > + {{ is_state(light_entity, 'on') + or lux_sensor == '' + or states(lux_sensor) | float(0) < lux_threshold | float }} + then: + - action: light.turn_on + target: + entity_id: !input light_entity + data: + brightness_pct: !input on_brightness + + - conditions: + - condition: trigger + id: occ_off + sequence: + - action: timer.start + target: + entity_id: !input idle_timer + + - conditions: + - condition: trigger + id: idle_done + - condition: state + entity_id: !input light_entity + state: 'on' + sequence: + - action: light.turn_on + target: + entity_id: !input light_entity + data: + brightness_pct: !input dim_brightness + - action: timer.start + target: + entity_id: !input warn_timer + + - conditions: + - condition: trigger + id: warn_done + sequence: + - action: light.turn_off + target: + entity_id: !input light_entity