description: ""
triggers:
- trigger: state
entity_id:
- climate.hallway
attribute: hvac_action
to: heating
id: "on"
- trigger: state
entity_id:
- climate.hallway
attribute: hvac_action
from: heating
id: "off"
- trigger: time_pattern
minutes: "*"
id: "on"
- trigger: time_pattern
minutes: "*"
id: "off"
conditions:
- condition: or
conditions:
- condition: and
conditions:
- condition: trigger
id:
- "on"
- condition: template
value_template: "{{state_attr('climate.hallway', 'hvac_action') == 'heating' }}"
- condition: template
value_template: >-
{{state_attr('climate.guest_room', 'hvac_action') != 'heating'
}}
- condition: and
conditions:
- condition: trigger
id:
- "off"
- condition: template
value_template: "{{state_attr('climate.hallway', 'hvac_action') != 'heating' }}"
- condition: template
value_template: >-
{{state_attr('climate.guest_room', 'hvac_action') == 'heating'
}}
actions:
- choose:
- conditions:
- condition: trigger
id:
- "on"
sequence:
- device_id: [i assume this isn't insecure to share but redacted to be safe]
domain: climate
entity_id: [i assume this isn't insecure to share but redacted to be safe]
type: set_hvac_mode
hvac_mode: heat
- conditions:
- condition: trigger
id:
- "off"
sequence:
- device_id: [i assume this isn't insecure to share but redacted to be safe]
domain: climate
entity_id: [i assume this isn't insecure to share but redacted to be safe]
type: set_hvac_mode
hvac_mode: "off"
mode: single
I have this automation setup for my heating system, the goal is to make it so that when enabling heating on the “Hallway” thermostat, the “Guest Room” thermostat turns on, which combines the heating and cooling in the zone into one place.
I had a more basic version set up for a few weeks but the “Guest Room” thermostat didn’t get turned on when it should have a few times, and once that happens it never gets triggered again since the temperature doesn’t rise, so I had to manually turn it on when I noticed. To solve that I added the timers and all of the conditional logic.
It seems to be working as I want it to, but as this is my first automation I was curious whether there is a better way to accomplish what I am doing here. I couldn’t think of a better way to add a timer into the mix that could regularly ensure that the “Guest Room” thermostat didn’t fall out of sync.
The logic of the automations seems a little off… The attribute hvac_action indicates whether the climate device is currently acting to modify temperature or not. By triggering on that attribute, the Guest Room temperature is being controlled by the Hallway’s heating needs, not its own actual needs.
That’s the goal. I’m just using the guest room thermostat as a switch for the hallway thermostats heating. The hallway thermostat is not actually connected to a heating system, it’s connected to the AC for the zone while the guest room one is connected to the heating for the zone. The idea is to connect them, and then basically ignore the guest room thermostat and only use the hallway one to control the climate.
triggers:
- trigger: state
entity_id:
- climate.hallway
attribute: hvac_action
to: heating
id: "on"
- trigger: state
entity_id:
- climate.hallway
attribute: hvac_action
from: heating
id: "off"
actions:
- choose:
- conditions:
- condition: trigger
id:
- "on"
sequence:
- device_id: [i assume this isn't insecure to share but redacted to be safe]
domain: climate
entity_id: [i assume this isn't insecure to share but redacted to be safe]
type: set_hvac_mode
hvac_mode: heat
- conditions:
- condition: trigger
id:
- "off"
sequence:
- device_id: [i assume this isn't insecure to share but redacted to be safe]
domain: climate
entity_id: [i assume this isn't insecure to share but redacted to be safe]
type: set_hvac_mode
hvac_mode: "off"
mode: single
That should be it. I wasn’t home when it happened but I suspect the issue has to do with my internet cutting out rather than a problem with the automation, these are nest thermostats so I lose connection when the internet is out.
OK, so we’re dealing with occasional communications disruptions and have to implement a mitigation strategy
When the internet connection is lost, does the state of the climate entity (representing the Nest thermostat) change to unavailable?
Because if it does then the automation can be designed to detect that and mitigate the situation. In other words, the moment the climate entity changes from unavailable to something else , the automation is triggered and proceeds to compare the state of both thermostats (and makes any necessary changes).
Another mitigation approach is to have the automation set the climate entity’s state more than once, whenever necessary. In other words, a repeat is used to set climate to heat, wait 2 seconds, then confirm it’s actually set to heat. If it’s not, try again up to a maximum of, say, 5 times before giving up and notifing you of the failure.
Either strategy (or combined) is more efficient than using a Time Pattern Trigger to repeatedly check the thermostats every minute.
That’s very helpful, thank you! I’ll have to wait a bit to cut out the internet and see how that affects how the devices show in HA. If I understand correctly, with that first strategy I’d essentially be using the same conditionals but using the change from unavailable as a trigger rather than the timer? Is there a better way to do the conditional logic that wouldn’t require two duplicate triggers with different ID’s?
With the repeating method, would a while loop until the state changes work rather than a set limit?
I recommend to loop until the condition is met but only up to a maximum number of attempts (to prevent looping endlessly).
I posted an example here. Note the use of repeat.index in the template.
As an added feature, you can add a test, after the repeat, to check if the climate entity is in the desired state. If not, it can notify you of the failure.