Forked from gresie/window_controlled_heater.yaml
Last active
November 26, 2022 15:34
-
-
Save govido/4aaa213e6209d3b76ec0e65d576e3701 to your computer and use it in GitHub Desktop.
Homeassistant blueprint to switch heater on or off depending on window or door sensor
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: window controlled heater | |
description: turn off heater when opening window and turn on with delay | |
domain: automation | |
source_url: https://gist.github.com/govido/4aaa213e6209d3b76ec0e65d576e3701 | |
#forked 2nd time from https://gist.github.com/gresie/476f1169ddd4a1bbbb12662f5b20e383 | |
#forked from https://gist.github.com/dirkk1980/8ba849b480844b32e9ca484e6de5d552 | |
#inspired by https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/motion_light.yaml | |
input: | |
heating_target: | |
name: Heater | |
selector: | |
entity: | |
domain: climate | |
window_entity: | |
name: Window Sensor | |
selector: | |
entity: {} | |
window_closed_wait: | |
name: Wait time open | |
description: Time to leave the heating on after window or door is opened. | |
default: 120 | |
selector: | |
number: | |
min: 0 | |
max: 3600 | |
unit_of_measurement: seconds | |
window_opened_wait: | |
name: Wait time closed | |
description: Time to leave the heating off after window or door is closed. | |
default: 120 | |
selector: | |
number: | |
min: 0 | |
max: 3600 | |
unit_of_measurement: seconds | |
# If window or door is closed within the delay, | |
# we restart the script. | |
mode: restart | |
max_exceeded: silent | |
variables: | |
heating_target: !input 'heating_target' | |
heating_temperature: '{{ state_attr(heating_target, ''temperature'') }}' | |
trigger: | |
platform: state | |
entity_id: !input 'window_entity' | |
from: 'off' | |
to: 'on' | |
action: | |
# timer waiting for door or window being open for X seconds (not turning the heater off if just walking through a door) | |
- delay: !input window_opened_wait | |
- service: climate.set_hvac_mode | |
entity_id: !input 'heating_target' | |
data: | |
hvac_mode: 'off' | |
- wait_for_trigger: | |
platform: state | |
entity_id: !input 'window_entity' | |
from: 'on' | |
to: 'off' | |
# timer is reset is door is closed within this delay | |
- delay: !input window_closed_wait | |
- service: climate.set_hvac_mode | |
entity_id: !input 'heating_target' | |
data: | |
hvac_mode: heat | |
- service: climate.set_temperature | |
entity_id: !input 'heating_target' | |
data: | |
temperature: '{{heating_temperature}}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, thanks for the Blueprint!
I think you have accidentally swapped the "window_closed_wait:" (line 19) with "window_opened_wait:" (line 28) ...
Because in my automation the wrong timers are always used.