Created
September 19, 2026 19:49
-
-
Save bmfurtado/c2f13022d15d8dc314bf551220f4cbbe to your computer and use it in GitHub Desktop.
Door-held activation (manual control preserved)
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: Door-held activation (manual control preserved) | |
| description: >- | |
| While a door is open, and for a configurable time after it closes, holds a | |
| set of entities on and another set off (e.g. camera status light on, | |
| camera privacy mode off). Afterwards it reverts only the entities it | |
| actually changed, and only if they are still in the state it put them in, | |
| so anything already active beforehand or changed by hand during the window | |
| is left alone. | |
| domain: automation | |
| homeassistant: | |
| min_version: 2024.10.0 | |
| input: | |
| door_sensor: | |
| name: Door sensor | |
| description: Binary sensor that is "on" when the door is open. | |
| selector: | |
| entity: | |
| filter: | |
| - domain: binary_sensor | |
| device_class: | |
| - door | |
| - garage_door | |
| - opening | |
| - window | |
| entities_on: | |
| name: Turn ON while active | |
| description: Entities to switch on while active (e.g. camera status light). | |
| default: [] | |
| selector: | |
| entity: | |
| multiple: true | |
| filter: | |
| - domain: switch | |
| - domain: light | |
| - domain: input_boolean | |
| entities_off: | |
| name: Turn OFF while active | |
| description: Entities to switch off while active (e.g. camera privacy mode). | |
| default: [] | |
| selector: | |
| entity: | |
| multiple: true | |
| filter: | |
| - domain: switch | |
| - domain: light | |
| - domain: input_boolean | |
| close_delay: | |
| name: Hold time after close | |
| description: How long to stay active after the door closes. | |
| default: | |
| hours: 0 | |
| minutes: 2 | |
| seconds: 0 | |
| selector: | |
| duration: | |
| extra_conditions: | |
| name: Extra conditions (optional) | |
| description: Only activate if these pass, e.g. nobody home, alarm armed. | |
| default: [] | |
| selector: | |
| condition: | |
| mode: single | |
| max_exceeded: silent | |
| variables: | |
| door_sensor: !input door_sensor | |
| entities_on: !input entities_on | |
| entities_off: !input entities_off | |
| triggers: | |
| - trigger: state | |
| entity_id: !input door_sensor | |
| from: "off" | |
| to: "on" | |
| conditions: | |
| - condition: and | |
| conditions: !input extra_conditions | |
| actions: | |
| # Only take ownership of entities that aren't already in the active state. | |
| - variables: | |
| changed_on: "{{ entities_on | select('is_state', 'off') | list }}" | |
| changed_off: "{{ entities_off | select('is_state', 'on') | list }}" | |
| - if: "{{ changed_off | length > 0 }}" | |
| then: | |
| - action: homeassistant.turn_off | |
| target: | |
| entity_id: "{{ changed_off }}" | |
| - if: "{{ changed_on | length > 0 }}" | |
| then: | |
| - action: homeassistant.turn_on | |
| target: | |
| entity_id: "{{ changed_on }}" | |
| # Hold: wait for the door to close, then count down. A re-open during the | |
| # countdown loops back to waiting for the next close. | |
| - repeat: | |
| sequence: | |
| - wait_template: "{{ is_state(door_sensor, 'off') }}" | |
| - wait_for_trigger: | |
| - trigger: state | |
| entity_id: !input door_sensor | |
| from: "off" | |
| to: "on" | |
| timeout: !input close_delay | |
| until: "{{ wait.trigger is none }}" | |
| # Revert only what we changed, and only if it is still how we left it. | |
| - variables: | |
| revert_off: "{{ changed_on | select('is_state', 'on') | list }}" | |
| revert_on: "{{ changed_off | select('is_state', 'off') | list }}" | |
| - if: "{{ revert_off | length > 0 }}" | |
| then: | |
| - action: homeassistant.turn_off | |
| target: | |
| entity_id: "{{ revert_off }}" | |
| - if: "{{ revert_on | length > 0 }}" | |
| then: | |
| - action: homeassistant.turn_on | |
| target: | |
| entity_id: "{{ revert_on }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment