Last active
August 24, 2024 00:05
-
-
Save alexbbt/39ce7ff85c7b1284e9253a57fc258a0f to your computer and use it in GitHub Desktop.
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: Control Closet Light with Double Sliding Doors and a Timeout | |
| description: Control the light inside a closet with double doors and an optional timeout. | |
| domain: automation | |
| input: | |
| controlling_door_sensors: | |
| name: Doors | |
| description: Door sensors, when any opens the light will turn on, when all are closed, the light will turn off. | |
| selector: | |
| entity: | |
| domain: | |
| - binary_sensor | |
| multiple: true | |
| controlled_light: | |
| name: Light | |
| description: Light that is controlled by open/closed state of the Door | |
| selector: | |
| entity: {} | |
| enable_timeout: | |
| name: Enabled the timeout setting bellow | |
| description: Turn on to use the timeout duration below to turn off the lights after the time has elapsed | |
| default: false | |
| selector: | |
| boolean: | |
| light_timeout: | |
| name: Duration | |
| description: The duration to leave the light on for (optional) | |
| selector: | |
| duration: | |
| mode: restart | |
| variables: | |
| enable_timeout: !input enable_timeout | |
| trigger: | |
| - platform: state | |
| entity_id: !input controlling_door_sensors | |
| id: Doors | |
| - platform: state | |
| entity_id: !input controlled_light | |
| to: "on" | |
| id: Light | |
| action: | |
| - choose: | |
| - conditions: | |
| - condition: trigger | |
| id: | |
| - Doors | |
| sequence: | |
| - choose: | |
| - conditions: | |
| - condition: and | |
| conditions: | |
| - condition: not | |
| conditions: | |
| - condition: state | |
| entity_id: !input controlling_door_sensors | |
| state: "off" | |
| alias: Check if any door is open | |
| - condition: template | |
| value_template: "{{ trigger.to_state.state == 'on' }}" | |
| alias: Verify a door was opened | |
| - condition: state | |
| entity_id: !input controlled_light | |
| state: "off" | |
| sequence: | |
| - service: homeassistant.turn_on | |
| target: | |
| entity_id: !input controlled_light | |
| data: {} | |
| - conditions: | |
| - condition: and | |
| conditions: | |
| - condition: state | |
| entity_id: !input controlling_door_sensors | |
| state: "off" | |
| alias: Check if both are closed | |
| - condition: state | |
| entity_id: !input controlled_light | |
| state: "on" | |
| sequence: | |
| - service: homeassistant.turn_off | |
| target: | |
| entity_id: !input controlled_light | |
| data: {} | |
| default: | |
| - if: | |
| - condition: and | |
| conditions: | |
| - condition: template | |
| value_template: "{{ enable_timeout }}" | |
| alias: Confirm if the timeout is enabled | |
| - condition: state | |
| entity_id: !input controlled_light | |
| state: "on" | |
| then: | |
| - delay: !input light_timeout | |
| - service: homeassistant.turn_off | |
| target: | |
| entity_id: !input controlled_light | |
| data: {} | |
| alias: Wait for timeout | |
| - conditions: | |
| - condition: trigger | |
| id: | |
| - Light | |
| sequence: | |
| - if: | |
| - condition: template | |
| value_template: "{{ enable_timeout }}" | |
| alias: Confirm if the timeout is enabled | |
| then: | |
| - delay: !input light_timeout | |
| - service: homeassistant.turn_off | |
| target: | |
| entity_id: !input controlled_light | |
| data: {} | |
| alias: Wait for timeout |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment