Skip to content

Instantly share code, notes, and snippets.

@ow
Last active June 8, 2025 23:55
Show Gist options
  • Save ow/23723cae79e115f1cd6892eb75a392c0 to your computer and use it in GitHub Desktop.
Save ow/23723cae79e115f1cd6892eb75a392c0 to your computer and use it in GitHub Desktop.
Thermostat automation
blueprint:
name: Door open/close thermostat control with mode restore
description: >
Turns off thermostat when door is open, and restores HVAC mode when door is closed.
Saves previous HVAC mode to an input_text helper.
domain: automation
input:
door_sensor:
name: Door/Window Sensor
selector:
entity:
domain: binary_sensor
device_class: opening
thermostat:
name: Thermostat
selector:
entity:
domain: climate
previous_mode_helper:
name: Input Text Helper for Previous HVAC Mode
selector:
entity:
domain: input_text
door_open_delay:
name: Door Open Delay
description: How long the door needs to stay open before turning off thermostat
default: 00:02:00
selector:
duration: {}
trigger:
- platform: state
entity_id: !input door_sensor
to: 'on'
for: !input door_open_delay
- platform: state
entity_id: !input door_sensor
to: 'off'
action:
- choose:
- conditions:
- condition: state
entity_id: !input door_sensor
state: 'on'
sequence:
- service: input_text.set_value
target:
entity_id: !input previous_mode_helper
data:
value: >
{% set thermostat_entity = !input thermostat %}
{{ state_attr( thermostat_entity, 'hvac_mode' ) }}
- service: climate.set_hvac_mode
target:
entity_id: !input thermostat
data:
hvac_mode: 'off'
- conditions:
- condition: state
entity_id: !input door_sensor
state: 'off'
sequence:
- service: climate.set_hvac_mode
target:
entity_id: !input thermostat
data:
hvac_mode: "{{ states( !input previous_mode_helper ) }}"
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment