Skip to content

Instantly share code, notes, and snippets.

@ilpantera
Forked from AlexanderBabel/smart-thermostat.yaml
Last active January 17, 2025 14:17
Show Gist options
  • Select an option

  • Save ilpantera/a8b958ece334a68c7f9c5f6b42b330a5 to your computer and use it in GitHub Desktop.

Select an option

Save ilpantera/a8b958ece334a68c7f9c5f6b42b330a5 to your computer and use it in GitHub Desktop.
blueprint:
name: Smart thermostat with delay
description: 'This automation uses your window sensor to control the thermostat, turning it on or off based on the window state. You can set the delay time for state changes to avoid retriggering. To prevent heating in summer, specify the weather entity and your winter temperature. Additionally, you can set a delay for resuming heating in winter to avoid triggering full power heating immediately after a window is closed.'
domain: automation
source_url: https://gist.github.com/AlexanderBabel/69c3b996a66b3a132cafadcbac4140cc
input:
window_sensor:
name: Window / Door Sensor Group
selector:
entity:
domain: binary_sensor
multiple: false
window_delay:
name: Window / Door Sensor Delay
description: Time the sensor needs to stay the same after change to trigger
the automation. This is done to avoid retriggering. (Default = 5s)
default: 5
selector:
number:
mode: box
min: 0.0
max: 3600.0
unit_of_measurement: seconds
step: 1.0
weather:
name: Weather
description: Specify your weather to get the current outside temperature from.
selector:
entity:
domain: weather
multiple: false
wintermode:
name: Wintermode
description: The ouside temperature needs to be below this to activate wintermode.
(Default = 16°C)
default: 16
selector:
number:
step: 0.5
min: 0.0
max: 150.0
unit_of_measurement: °C or °F
mode: slider
wintermode_delay:
name: Wintermode Delay
description: Time the outside temperature neeeds to stay above the wintermode
temperature to turn the heating off.
default: 1800
selector:
number:
mode: box
min: 1.0
max: 86400.0
unit_of_measurement: seconds
step: 1.0
return_delay:
name: Return Delay
description: Time to wait before returning the heating to auto after the window is closed.
default: 1200 # Default is 20 minutes
selector:
number:
mode: box
min: 0.0
max: 86400.0
unit_of_measurement: seconds
step: 1.0
thermostat:
name: Thermostat
selector:
entity:
domain: climate
multiple: false
trigger:
- platform: state
entity_id: !input window_sensor
to: 'off'
from: 'on'
for: !input window_delay
- platform: state
entity_id: !input window_sensor
to: 'on'
from: 'off'
for: !input window_delay
- platform: numeric_state
entity_id: !input weather
attribute: temperature
below: !input wintermode
for: !input wintermode_delay
- platform: numeric_state
entity_id: !input weather
attribute: temperature
above: !input wintermode
for: !input wintermode_delay
action:
- choose:
- conditions:
- condition: and
conditions:
- condition: state
entity_id: !input window_sensor
state: 'off'
- condition: numeric_state
entity_id: !input weather
attribute: temperature
below: !input wintermode
sequence:
- delay: !input return_delay
- service: climate.set_hvac_mode
data:
hvac_mode: auto
entity_id: !input thermostat
- conditions:
- condition: or
conditions:
- condition: state
entity_id: !input window_sensor
state: 'on'
- condition: numeric_state
entity_id: !input weather
attribute: temperature
above: !input wintermode
sequence:
- service: climate.set_hvac_mode
data:
hvac_mode: 'off'
entity_id: !input thermostat
default: []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment