Skip to content

Instantly share code, notes, and snippets.

@jacobmovingfwd
Last active September 19, 2024 19:01
Show Gist options
  • Save jacobmovingfwd/f1bbac3afad55a84af2825d8c3248084 to your computer and use it in GitHub Desktop.
Save jacobmovingfwd/f1bbac3afad55a84af2825d8c3248084 to your computer and use it in GitHub Desktop.
alias: HVAC Automation
trigger:
- platform: numeric_state
entity_id:
- climate.main_house
attribute: current_temperature
above: 72
- platform: numeric_state
entity_id:
- climate.main_house
attribute: current_temperature
below: 68
- platform: numeric_state
entity_id:
- climate.upstairs
attribute: current_temperature
above: 72
- platform: numeric_state
entity_id:
- climate.upstairs
attribute: current_temperature
below: 63
- platform: time
at:
- "04:00:01"
- "06:00:01"
- "08:00:01"
- "16:00:01"
enabled: true
condition: []
action:
- wait_template: "{{ has_value('climate.main_house') }}"
alias: Wait for main_house to be available
enabled: false
- alias: Wait for main house to be available
repeat:
until:
- condition: state
entity_id: climate.main_house
attribute: runstate
state: normal
sequence:
- delay:
seconds: 30
- data:
name: main_house temp
message: "{{state_attr('climate.main_house', 'current_temperature')}}"
entity_id: climate.main_house
action: logbook.log
alias: log main_house current_temp
- data:
name: upstairs temp
message: "{{state_attr('climate.upstairs', 'current_temperature')}}"
entity_id: climate.upstairs
action: logbook.log
alias: log upstairs current_temp
- choose:
- conditions:
- condition: numeric_state
entity_id: climate.main_house
attribute: current_temperature
below: 68
alias: If main_house too cold
sequence:
- alias: >-
If upstairs is cooling, set to fan. Else set upstairs to heat on
winter schedule
if:
- condition: state
entity_id: climate.upstairs
attribute: hvac_action
state: cooling
then:
- repeat:
sequence:
- alias: set upstairs to fan
data:
hvac_mode: fan_only
target:
device_id: climate.upstairs
action: climate.set_hvac_mode
- delay:
hours: 0
minutes: 0
seconds: 30
milliseconds: 0
until:
- condition: state
entity_id: climate.upstairs
attribute: hvac_action
state: fan
alias: Set Upstairs to fan
else:
- alias: else, set upstairs to heat, following winter schedule
target:
device_id: climate.upstairs
data:
hvac_mode: heat
temperature: >-
{{ 72 if (now() | as_timestamp() | int(1000)) >= 14400 and
(now() | as_timestamp() | int(1000)) < 28800 else 65 }}
action: climate.set_temperature
- repeat:
until:
- condition: state
entity_id: climate.main_house
attribute: hvac_action
state: heating
sequence:
- alias: set main_house to heat
target:
entity_id: climate.main_house
data:
temperature: 70
hvac_mode: heat
action: climate.set_temperature
- delay:
seconds: 30
alias: Set main_house to heat
- action: notify.mobile_app_pixel_6
data:
title: Main house set to heat.
message: >-
Main House: {{state_attr('climate.main_house', 'hvac_action')}}
{{state_attr('climate.main_house', 'current_temperature')}}
Upstairs: {{state_attr('climate.upstairs', 'hvac_action')}}
{{state_attr('climate.upstairs', 'current_temperature')}}
- conditions:
- condition: numeric_state
entity_id: climate.main_house
above: 72
attribute: current_temperature
alias: If main_house too hot
sequence:
- if:
- condition: state
entity_id: climate.upstairs
attribute: hvac_action
state: heating
then:
- alias: set upstairs to fan
data:
hvac_mode: fan_only
target:
entity_id: climate.upstairs
action: climate.set_hvac_mode
else:
- alias: else, set upstairs to cool, on summer schedule
target:
entity_id: climate.upstairs
data:
hvac_mode: cool
temperature: >-
{{ 65 if (now() | as_timestamp() | int(1000)) >= 57600 and
(now() | as_timestamp() | int(1000)) < 21600 else 70 }}
action: climate.set_temperature
alias: If Upstairs is heating, set to fan. Else set upstairs to cool
- repeat:
until:
- condition: state
entity_id: climate.main_house
attribute: hvac_action
state: cooling
sequence:
- alias: then set main_house to cool
target:
entity_id: climate.main_house
data:
temperature: 70
hvac_mode: cool
action: climate.set_temperature
- delay:
seconds: 30
alias: Set main_house to cool
- action: notify.mobile_app_pixel_6
data:
title: Main house set to cool.
message: >-
Main House: {{state_attr('climate.main_house', 'hvac_action')}}
{{state_attr('climate.main_house', 'current_temperature')}}
Upstairs: {{state_attr('climate.upstairs', 'hvac_action')}}
{{state_attr('climate.upstairs', 'current_temperature')}}
- conditions:
- condition: numeric_state
entity_id: climate.main_house
attribute: current_temperature
above: 67
below: 73
- condition: numeric_state
entity_id: climate.upstairs
attribute: current_temperature
above: 75
- condition: numeric_state
entity_id: climate.upstairs
attribute: current_temperature
below: 63
alias: If main_house is in comfort range
sequence:
- choose:
- conditions:
- condition: template
value_template: >-
{{ (now() | as_timestamp() | int(1000)) >= 57600 and
(now() | as_timestamp() | int(1000)) < 21600 and
states('climate.upstairs.current_temperature') |
float(default=0) >= 65 }}
alias: if upstairs is over 65F at night
- condition: numeric_state
entity_id: climate.upstairs
attribute: current_temperature
above: 72
alias: if upstairs is over 72F at any time
alias: and upstairs is too hot
sequence:
- alias: If main_house is heating, set it to fan
if:
- condition: state
entity_id: climate.main_house
attribute: hvac_action
state: heating
then:
- repeat:
until:
- condition: template
value_template: "{{ is_state('climate.main_house', 'fan_only') }}"
enabled: false
- condition: state
entity_id: climate.main_house
attribute: hvac_action
state: fan
sequence:
- alias: set main_house to fan_only
data:
hvac_mode: fan_only
target:
entity_id: climate.main_house
action: climate.set_hvac_mode
- delay:
seconds: 30
alias: set main_house to fan_only
- alias: set upstairs to cool, following summer schedule
target:
entity_id: climate.upstairs
data:
hvac_mode: cool
temperature: >-
{{ 65 if (now() | as_timestamp() | int(1000)) >= 57600
and (now() | as_timestamp() | int(1000)) < 21600 else 70
}}
action: climate.set_temperature
- action: notify.mobile_app_pixel_6
data:
title: Main house good, Upstairs set to cool.
message: >-
Main House: {{state_attr('climate.main_house',
'hvac_action')}} {{state_attr('climate.main_house',
'current_temperature')}} Upstairs:
{{state_attr('climate.upstairs', 'hvac_action')}}
{{state_attr('climate.upstairs',
'current_temperature')}}
- conditions:
- condition: numeric_state
entity_id: climate.upstairs
attribute: current_temperature
below: 64
alias: and upstairs is too cold
sequence:
- alias: If main_house is set to cool, set to fan
if:
- condition: state
entity_id: climate.main_house
attribute: hvac_action
state: cooling
then:
- repeat:
until:
- condition: template
value_template: "{{ is_state('climate.main_house', 'fan_only') }}"
enabled: false
- condition: state
entity_id: climate.main_house
attribute: hvac_action
state: fan
sequence:
- alias: set main_house to fan_only
data:
hvac_mode: fan_only
target:
entity_id: climate.main_house
action: climate.set_hvac_mode
- delay:
seconds: 30
alias: Set main_house to fan_only
- alias: then set upstairs to heat, on winter schedule
target:
entity_id: climate.upstairs
data:
hvac_mode: heat
temperature: >-
{{ 72 if (now() | as_timestamp() | int(1000)) >= 14400
and (now() | as_timestamp() | int(1000)) < 28800 else 65
}}
action: climate.set_temperature
- action: notify.mobile_app_pixel_6
data:
title: Main house good, Upstairs set to heat.
message: >-
Main House: {{state_attr('climate.main_house',
'hvac_action')}} {{state_attr('climate.main_house',
'current_temperature')}} Upstairs:
{{state_attr('climate.upstairs', 'hvac_action')}}
{{state_attr('climate.upstairs',
'current_temperature')}}
default:
- action: notify.mobile_app_pixel_6
data:
title: "HVAC: All good."
message: >-
Main House: {{state_attr('climate.main_house', 'hvac_action')}}
{{state_attr('climate.main_house', 'current_temperature')}}
Upstairs: {{state_attr('climate.upstairs', 'hvac_action')}}
{{state_attr('climate.upstairs', 'current_temperature')}}
variables:
entities:
- climate.main_house
- climate.upstairs
main_house_floor: 68
main_house_ciel: 72
upstairs_floor: 63
upstairs_ciel: 76
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment