-
-
Save skarol/0237e60916bb2edb2d2ff37a17034a29 to your computer and use it in GitHub Desktop.
Home Assistant - Vacation Mode Lights Blueprint
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
# source: https://community.home-assistant.io/t/vacation-lighting-replay-historical-lighting/282435 | |
# blog post on this: https://blog.fuzzymistborn.com/smart-vacation-mode-lighting/ | |
blueprint: | |
name: Blueprint - Vacation Lighting | |
description: Vacation Lighting - Replay Sensors to Light Behavior | |
domain: automation | |
input: | |
vacation_mode_toggle: | |
name: Vacation Mode - Input Boolean | |
selector: | |
entity: | |
domain: input_boolean | |
default_brightness: | |
name: Default Brightness | |
default: 50 | |
selector: | |
number: | |
min: 1 | |
max: 100 | |
unit_of_measurement: "%" | |
mode: slider | |
replay_sensor_1: | |
name: Replay Sensor (1) | |
selector: | |
entity: | |
domain: sensor | |
light_target_1: | |
name: Light Target (1) | |
selector: | |
entity: | |
replay_sensor_2: | |
name: Replay Sensor (2) | |
selector: | |
entity: | |
domain: sensor | |
light_target_2: | |
name: Light Target (2) | |
selector: | |
entity: | |
# Declare blueprint inputs as variables for use in {{templates}} | |
variables: | |
replay_sensor_1: !input replay_sensor_1 | |
light_target_1: !input light_target_1 | |
replay_sensor_2: !input replay_sensor_2 | |
light_target_2: !input light_target_2 | |
# Trigger when replay sensor changes state | |
trigger: | |
- platform: state | |
entity_id: !input replay_sensor_1 | |
- platform: state | |
entity_id: !input replay_sensor_2 | |
# As long as Vacation Mode is on | |
condition: | |
- condition: state | |
entity_id: !input vacation_mode_toggle | |
state: 'on' | |
action: | |
- variables: | |
corresponding_light: > | |
{% if trigger.entity_id == replay_sensor_1 %} | |
{{ light_target_1 }} | |
{% elif trigger.entity_id == replay_sensor_2 %} | |
{{ light_target_2 }} | |
{% endif %} | |
- choose: | |
# Replay turned on && entity_id is "LIGHT" | |
- conditions: | |
condition: and | |
conditions: | |
- condition: template | |
value_template: '{{ trigger.to_state.state == "1" }}' | |
- condition: template | |
value_template: '{{ corresponding_light.split(".")[0] == "light" }}' | |
sequence: | |
- service: light.turn_on | |
data: | |
entity_id: '{{ corresponding_light }}' | |
brightness_pct: !input default_brightness | |
- service: system_log.write | |
data: | |
message: 'Vacation - Replay Lighting (Blueprint): {{trigger.to_state.entity_id}}: turning on: {{ corresponding_light }}' | |
level: info | |
# Replay turned on && entity_id is "SWITCH" | |
- conditions: | |
condition: and | |
conditions: | |
- condition: template | |
value_template: '{{ trigger.to_state.state == "1" }}' | |
- condition: template | |
value_template: '{{ corresponding_light.split(".")[0] == "switch" }}' | |
sequence: | |
- service: switch.turn_on | |
data: | |
entity_id: '{{ corresponding_light }}' | |
- service: system_log.write | |
data: | |
message: 'Vacation - Replay Lighting (Blueprint): {{trigger.to_state.entity_id}}: turning on:{{ corresponding_light }}' | |
level: info | |
# Replay turned off | |
- conditions: | |
condition: and | |
conditions: | |
- condition: template | |
value_template: '{{ trigger.to_state.state == "0" }}' | |
sequence: | |
- service: homeassistant.turn_off | |
data: | |
entity_id: '{{ corresponding_light }}' | |
- service: system_log.write | |
data: | |
message: 'Vacation - Replay Lighting (Blueprint): {{trigger.to_state.entity_id}}: turning off:{{ corresponding_light }}' | |
level: info |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment