I am drawing out a flow for HVAC automation. I am wondering if some of the conditions are unnecessary.
Basically what I am wanting to do…
- if window opened, start timer
- on event timer.finished turn off HVAC
Simple enough right? Well, here is where my brain wants to over complicate things. I’m thinking it would be a good practice NOT to send unnecessary commands. For example, if the HVAC system is already off, no need to send it a command to turn off.
Is it best practice to explicitly test for state desired before sending state?
Also, when using a timer, should I be looking at the event bus for timer.finished
or entity state change? I’m trying to think ahead in case there is a random reboot or something where state may not be correct.
Here is some example yaml. Note, the ha start and automation reload are there as a protection in case something odd happens to hopefully detect the proper state.
alias: test1
description: ""
trigger:
- platform: homeassistant
event: start
id: ha_start
alias: HA Start
- platform: event
event_type: automation_reloaded
alias: Automation Reload
id: automation_reload
- platform: state
entity_id:
- binary_sensor.dining_area_window_1
to: "on"
id: daw1_open
alias: Dining Area Window 1 Open
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.window_hvac_timer
alias: HVAC Timer Finished
id: hvac_timer_finished
condition: []
action:
- choose:
- conditions:
- condition: and
conditions:
- condition: or
conditions:
- condition: trigger
id: ha_start
alias: HA Start
- condition: trigger
id: automation_reload
alias: HA Reload
alias: HA Start or Reload
- condition: state
entity_id: timer.window_hvac_timer
state: idle
alias: HVAC Timer Idle
- condition: state
entity_id: binary_sensor.dining_area_window_1
state: "on"
alias: Dining Area Window Open
alias: HA Start OR Reload AND Timer Finished, Window Open
- condition: not
conditions:
- condition: state
entity_id: climate.downstairs_ecobee
state: "off"
alias: Downstairs Ecobee Off
sequence:
- service: climate.set_hvac_mode
data:
hvac_mode: "off"
target:
entity_id: climate.downstairs_ecobee
alias: HVAC Off
- conditions:
- condition: and
conditions:
- condition: trigger
id: daw1_open
alias: Dining Area Window 1 Open
- condition: not
conditions:
- condition: state
entity_id: timer.window_hvac_timer
state: active
alias: HVAC Timer Active
alias: NOT HVAC Timer Active
alias: DAW1 Open AND Timer NOT Active
sequence:
- service: timer.start
data: {}
target:
entity_id: timer.window_hvac_timer
alias: Activate HVAC Timer
- conditions:
- condition: and
conditions:
- condition: trigger
id: hvac_timer_finished
alias: HVAC Timer Finished
- condition: not
conditions:
- condition: state
entity_id: climate.downstairs_ecobee
state: "off"
alias: Downstairs Ecobee Off
alias: Downstairs Ecobee NOT Off
alias: HVAC Timer Finished AND HVAC NOT Off
sequence:
- service: climate.set_hvac_mode
data:
hvac_mode: "off"
target:
entity_id: climate.downstairs_ecobee
alias: HVAC Off
mode: single