Skip to content

Instantly share code, notes, and snippets.

@martintamare
Last active April 9, 2024 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martintamare/657aa6ee8c62a6c34f6c10b6fb4881a7 to your computer and use it in GitHub Desktop.
Save martintamare/657aa6ee8c62a6c34f6c10b6fb4881a7 to your computer and use it in GitHub Desktop.
Smart Thermostat for Windows v2
blueprint:
name: Smart Thermostat for Windows
description: 'Based on your window sensor this automation turns the thermostat on
or off. You can also specify the time that is needed to switch the state. '
domain: automation
input:
window_sensor:
name: Window / Door Sensor
selector:
entity:
domain: binary_sensor
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: 30
selector:
number:
mode: box
min: 0.0
max: 3600.0
unit_of_measurement: seconds
step: 1.0
thermostat:
name: Thermostat
selector:
entity:
domain: climate
thermostat_helper:
name: Thermostat Helper to store last State
selector:
entity:
domain: input_text
variables:
thermostat_entity: !input thermostat
thermostat_helper_entity: !input thermostat_helper
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'
action:
- choose:
- conditions:
- condition: and
conditions:
- condition: state
entity_id: !input 'window_sensor'
state: 'off'
sequence:
- service: climate.set_hvac_mode
data:
hvac_mode: "{{ states(thermostat_helper_entity) }}"
target:
entity_id: !input 'thermostat'
- conditions:
- condition: or
conditions:
- condition: state
entity_id: !input 'window_sensor'
state: 'on'
sequence:
- service: input_text.set_value
data:
value: "{{ states(thermostat_entity) }}"
target:
entity_id: !input 'thermostat_helper'
- service: climate.set_hvac_mode
data:
hvac_mode: 'off'
target:
entity_id: !input 'thermostat'
default: []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment