Files
home-assistant/packages/climate/climate.yaml

253 lines
7.1 KiB
YAML

# Climate Package
# -----------------------------------------------------------------------------
# Climate State Helpers
input_select:
climate_mode:
name: Climate Control Mode
options:
- 'Off'
- Auto
- Manual
- Paused
input_number:
temp_setpoint_day_high:
name: Temperature Setpoint Day (High)
initial: 74
min: 60
max: 90
step: 1
temp_setpoint_day_low:
name: Temperature Setpoint Day (Low)
initial: 70
min: 60
max: 90
step: 1
temp_setpoint_night_high:
name: Temperature Setpoint Night (High)
initial: 76
min: 60
max: 90
step: 1
temp_setpoint_night_low:
name: Temperature Setpoint Night (Low)
initial: 70
min: 60
max: 90
step: 1
temp_setpoint_away_high:
name: Temperature Setpoint Away (High)
initial: 80
min: 60
max: 90
step: 1
temp_setpoint_away_low:
name: Temperature Setpoint Away (Low)
initial: 66
min: 60
max: 90
step: 1
input_datetime:
hvac_start_day:
name: HVAC Daytime Start
initial: '10:00'
has_date: false
has_time: true
hvac_start_night:
name: HVAC Nighttime Start
initial: '20:00'
has_date: false
has_time: true
input_text:
hvac_last_mode:
template:
binary_sensor:
- name: HVAC Fan Running
state: >
{{ 'Running' in state_attr('climate.thermostat', 'fan_state') }}
# -----------------------------------------------------------------------------
# Climate Scripts
script:
hvac_pause:
alias: Pause HVAC
mode: restart
sequence:
# Save the current thermostat mode because it may not be captured properly
# by `scene.create` (see https://github.com/home-assistant/core/issues/69925)
- action: input_text.set_value
target:
entity_id: input_text.hvac_last_mode
data:
value: "{{ states('climate.thermostat') }}"
# Snapshot the current mode and thermostat status
- action: scene.create
data:
scene_id: hvac_restore_state
snapshot_entities:
- climate.thermostat
- input_select.climate_mode
- input_text.hvac_last_mode
# Turn off the thermostat and set the mode to Paused
- action: climate.set_hvac_mode
target:
entity_id: climate.thermostat
data:
hvac_mode: "off"
- service: input_select.select_option
target:
entity_id: input_select.climate_mode
data:
option: Paused
hvac_restore:
alias: Resume HVAC
mode: restart
sequence:
# Restore the snapshot
- action: scene.turn_on
target:
entity_id: scene.hvac_restore_state
# Restore the thermostat mode
- action: climate.set_hvac_mode
target:
entity_id: climate.thermostat
data:
hvac_mode: "{{ states('input_text.hvac_last_mode') }}"
# -----------------------------------------------------------------------------
# Climate Automations
automation:
# Automations for Open Windows/Doors
- alias: Pause HVAC when Doors/Windows Open
mode: queued
trigger:
- platform: state
entity_id: binary_sensor.all_doors
to: 'on'
for:
minutes: 5
- platform: state
entity_id: binary_sensor.all_windows
to: 'on'
for:
minutes: 5
condition:
- "{{ not is_state('input_select.climate_mode', 'Manual') }}"
- "{{ not is_state('input_select.climate_mode', 'Paused') }}"
- "{{ is_state('input_boolean.guest_mode', 'off') }}"
action:
# - service: scene.create
# data:
# scene_id: hvac_restore_state
# snapshot_entities:
# # See https://github.com/home-assistant/core/issues/69925
# # - climate.thermostat
# - input_select.climate_mode
# - service: climate.set_hvac_mode
# target:
# entity_id: climate.thermostat
# data:
# hvac_mode: "off"
# - service: input_select.select_option
# target:
# entity_id: input_select.climate_mode
# data:
# option: Paused
- action: script.hvac_pause
- action: notify.status
data:
message: "HVAC Paused ({{ states('sensor.open_windows_doors') }} open)"
- alias: Restore HVAC when Doors/Windows Closed
mode: queued
trigger:
- platform: state
entity_id: binary_sensor.all_doors
from: 'on'
to: 'off'
for:
minutes: 5
- platform: state
entity_id: binary_sensor.all_windows
from: 'on'
to: 'off'
for:
minutes: 5
condition:
- "{{ is_state('input_select.climate_mode', 'Paused') }}"
- "{{ is_state('binary_sensor.all_doors', 'off') }}"
- "{{ is_state('binary_sensor.all_windows', 'off') }}"
action:
# - service: scene.turn_on
# target:
# entity_id: scene.hvac_restore_state
# # See https://github.com/home-assistant/core/issues/69925
# # Assume thermostat is always heat_cool when not off
# - service: climate.set_hvac_mode
# target:
# entity_id: climate.thermostat
# data:
# hvac_mode: "{{ 'off' if is_state('input_select.climate_mode', 'Off') else 'heat_cool' }}"
- action: script.hvac_restore
- action: notify.status
data:
message: HVAC Restored (Windows and Doors closed)
- alias: Widen HVAC Range at Night
mode: queued
trigger:
- platform: time
at: input_datetime.hvac_start_night
condition:
- "{{ not is_state('input_select.climate_mode', 'Manual') }}"
- "{{ not is_state('input_select.house_presence_state', 'Extended Away') }}"
action:
- service: climate.set_temperature
target:
entity_id: climate.thermostat
data:
target_temp_high: "{{ states('input_number.temp_setpoint_night_high')|float }}"
target_temp_low: "{{ states('input_number.temp_setpoint_night_low')|float }}"
- alias: Narrow HVAC Range during Day
mode: queued
trigger:
- platform: time
at: input_datetime.hvac_start_day
condition:
- "{{ not is_state('input_select.climate_mode', 'Manual') }}"
- "{{ not is_state('input_select.house_presence_state', 'Extended Away') }}"
action:
- service: climate.set_temperature
target:
entity_id: climate.thermostat
data:
target_temp_high: "{{ states('input_number.temp_setpoint_day_high')|float }}"
target_temp_low: "{{ states('input_number.temp_setpoint_day_low')|float }}"
- alias: Widen HVAC Range during Vacation
mode: queued
trigger:
- platform: state
entity_id: input_select.house_presence_state
to: 'Extended Away'
condition:
- "{{ not is_state('input_select.climate_mode', 'Manual') }}"
action:
- service: climate.set_temperature
target:
entity_id: climate.thermostat
data:
target_temp_high: "{{ states('input_number.temp_setpoint_away_high')|float }}"
target_temp_low: "{{ states('input_number.temp_setpoint_away_low')|float }}"