Last active
January 24, 2026 15:49
-
-
Save NOX73/c4c1cb08e9d2834d7387741de4c99b4c to your computer and use it in GitHub Desktop.
Utility room light (toggle switch + door 15m + manual 60m, motion refresh)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| blueprint: | |
| name: Utility room light (toggle switch + door 15m + manual 60m, motion refresh) | |
| description: > | |
| - Switch toggles the light. | |
| - Door open -> light ON for 15 minutes (motion refreshes 15m). | |
| - Manual ON (by switch toggle that turns light ON, or UI ON by user) -> 60 minutes (motion refreshes 60m). | |
| - If door opens while manual is active -> switch to 15m mode. | |
| - Timer finished -> light OFF and cleanup. | |
| domain: automation | |
| input: | |
| door_sensor: | |
| name: Door sensor (binary_sensor) | |
| selector: | |
| entity: | |
| domain: binary_sensor | |
| motion_sensor: | |
| name: Motion sensor (binary_sensor) | |
| selector: | |
| entity: | |
| domain: binary_sensor | |
| target_light: | |
| name: Target light (single light entity) | |
| selector: | |
| entity: | |
| domain: light | |
| manual_switch: | |
| name: Wall switch trigger (switch/light/binary_sensor) | |
| description: Any state change toggles the target light. | |
| selector: | |
| entity: | |
| domain: | |
| - switch | |
| - light | |
| - binary_sensor | |
| helper_timer: | |
| name: Helper Timer (auto-off) | |
| selector: | |
| entity: | |
| domain: timer | |
| helper_mode: | |
| name: Helper Mode (input_select) | |
| description: "Stores current mode: door or manual." | |
| selector: | |
| entity: | |
| domain: input_select | |
| door_duration: | |
| name: Door duration | |
| default: | |
| hours: 0 | |
| minutes: 15 | |
| seconds: 0 | |
| selector: | |
| duration: {} | |
| manual_duration: | |
| name: Manual duration | |
| default: | |
| hours: 1 | |
| minutes: 0 | |
| seconds: 0 | |
| selector: | |
| duration: {} | |
| mode: restart | |
| max_exceeded: silent | |
| trigger: | |
| - platform: state | |
| entity_id: !input manual_switch | |
| id: switch_toggled | |
| - platform: state | |
| entity_id: !input door_sensor | |
| to: "on" | |
| id: door_open | |
| - platform: state | |
| entity_id: !input door_sensor | |
| to: "off" | |
| id: door_closed | |
| - platform: state | |
| entity_id: !input motion_sensor | |
| to: "on" | |
| id: motion | |
| - platform: state | |
| entity_id: !input target_light | |
| to: "on" | |
| id: light_on | |
| - platform: state | |
| entity_id: !input target_light | |
| to: "off" | |
| id: light_off | |
| - platform: event | |
| event_type: timer.finished | |
| event_data: | |
| entity_id: !input helper_timer | |
| id: timer_finished | |
| variables: | |
| door_dur: !input door_duration | |
| manual_dur: !input manual_duration | |
| action: | |
| - choose: | |
| # 0) Switch toggled -> toggle light; if light ends up ON -> set MANUAL mode and start 60m timer | |
| - conditions: | |
| - condition: trigger | |
| id: switch_toggled | |
| sequence: | |
| - choose: | |
| - conditions: | |
| - condition: state | |
| entity_id: !input target_light | |
| state: "on" | |
| sequence: | |
| # Toggle OFF | |
| - service: timer.cancel | |
| target: | |
| entity_id: !input helper_timer | |
| - service: light.turn_off | |
| target: | |
| entity_id: !input target_light | |
| default: | |
| # Toggle ON -> MANUAL | |
| - service: light.turn_on | |
| target: | |
| entity_id: !input target_light | |
| - service: input_select.select_option | |
| target: | |
| entity_id: !input helper_mode | |
| data: | |
| option: manual | |
| - service: timer.start | |
| target: | |
| entity_id: !input helper_timer | |
| data: | |
| duration: "{{ manual_dur }}" | |
| # 1) Door opened -> DOOR mode 15m (overrides manual) | |
| - conditions: | |
| - condition: trigger | |
| id: door_open | |
| sequence: | |
| - service: light.turn_on | |
| target: | |
| entity_id: !input target_light | |
| - service: input_select.select_option | |
| target: | |
| entity_id: !input helper_mode | |
| data: | |
| option: door | |
| - service: timer.start | |
| target: | |
| entity_id: !input helper_timer | |
| data: | |
| duration: "{{ door_dur }}" | |
| # 2) Light ON via UI by user -> treat as MANUAL 60m | |
| - conditions: | |
| - condition: trigger | |
| id: light_on | |
| - condition: template | |
| value_template: "{{ trigger.to_state.context.user_id is not none }}" | |
| sequence: | |
| - service: input_select.select_option | |
| target: | |
| entity_id: !input helper_mode | |
| data: | |
| option: manual | |
| - service: timer.start | |
| target: | |
| entity_id: !input helper_timer | |
| data: | |
| duration: "{{ manual_dur }}" | |
| # 3) Motion -> refresh timer according to current mode (door/manual). If mode unknown -> default door. | |
| - conditions: | |
| - condition: trigger | |
| id: motion | |
| sequence: | |
| - choose: | |
| - conditions: | |
| - condition: state | |
| entity_id: !input helper_mode | |
| state: "manual" | |
| sequence: | |
| - service: timer.start | |
| target: | |
| entity_id: !input helper_timer | |
| data: | |
| duration: "{{ manual_dur }}" | |
| default: | |
| - service: timer.start | |
| target: | |
| entity_id: !input helper_timer | |
| data: | |
| duration: "{{ door_dur }}" | |
| # 4) Light OFF -> cancel timer (cleanup) | |
| - conditions: | |
| - condition: trigger | |
| id: light_off | |
| sequence: | |
| - service: timer.cancel | |
| target: | |
| entity_id: !input helper_timer | |
| # 5) Timer finished -> turn off light | |
| - conditions: | |
| - condition: trigger | |
| id: timer_finished | |
| sequence: | |
| - service: light.turn_off | |
| target: | |
| entity_id: !input target_light | |
| # 6) Door closed -> turn off light and cancel timer | |
| - conditions: | |
| - condition: trigger | |
| id: door_closed | |
| sequence: | |
| - service: timer.cancel | |
| target: | |
| entity_id: !input helper_timer | |
| - service: light.turn_off | |
| target: | |
| entity_id: !input target_light |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment