Last active
August 12, 2022 07:47
-
-
Save bruxy70/4d31e5ccc70ed5e5e5423a53298253db to your computer and use it in GitHub Desktop.
Home Assistant Automation Blueprint - automate lights inside the room and the hallway, using presence information, door sensor and lights state.
This file contains 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: Toggle lights on door open - with presence detection | |
description: When the door is open, toggle the inside and outside light | |
based on the state of both lights and presence in the room. | |
Works only at night based on the sun position. | |
source_url: https://github.com/bruxy70 | |
domain: automation | |
input: | |
door_sensor: | |
name: Door sensor | |
description: The binary sensor - door open. | |
selector: | |
entity: | |
domain: binary_sensor | |
inside_light: | |
name: Inside light | |
description: The light inside the room. | |
selector: | |
entity: | |
domain: light | |
outside_light: | |
name: Outside light | |
description: The light on the corridor. | |
selector: | |
entity: | |
domain: light | |
presence_inside: | |
name: Presence in the room | |
description: The FP1 sensor registering if somebody is in the room. | |
selector: | |
entity: | |
domain: binary_sensor | |
device_class: presence | |
mode: restart | |
trigger: | |
- platform: state | |
entity_id: !input door_sensor | |
to: "on" | |
id: "door" | |
- platform: state | |
entity_id: !input presence_inside | |
to: "off" | |
id: "presence" | |
variables: | |
inside: !input inside_light | |
outside: !input outside_light | |
presence: !input presence_inside | |
condition: | |
condition: and | |
conditions: | |
- condition: state | |
entity_id: sun.sun | |
state: below_horizon | |
action: | |
- choose: | |
- alias: Comming - turn on inside, turn off outside | |
conditions: "{{ trigger.id == 'door' and is_state(inside,'off') and is_state(outside,'on') and is_state(presence,'off') }}" | |
sequence: | |
- service: light.turn_on | |
entity_id: !input inside_light | |
- service: light.turn_off | |
entity_id: !input outside_light | |
- alias: Leaving - turn on outside | |
conditions: "{{ trigger.id == 'door' and is_state(inside,'on') and is_state(outside,'off') and is_state(presence, 'on') }}" | |
sequence: | |
- service: light.turn_on | |
entity_id: !input outside_light | |
- alias: Left - turn off inside | |
conditions: "{{ trigger.id == 'presence' }}" | |
sequence: | |
- service: light.turn_off | |
entity_id: !input inside_light |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment