Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save gresie/476f1169ddd4a1bbbb12662f5b20e383 to your computer and use it in GitHub Desktop.
Save gresie/476f1169ddd4a1bbbb12662f5b20e383 to your computer and use it in GitHub Desktop.
Homeassistant blueprint to switch heater on or off depending on window or door sensor
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/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
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:
- 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