alias: Livingroom / Office Link climate temperature
description: ''
mode: single
trigger:
- platform: state
entity_id: climate.livingroom
id: livingroom
attribute: temperature
- platform: state
entity_id: climate.office
id: office
attribute: temperature
As triggers I simply use the change of the temperature attribute of the climate elements of the office and living room. To know which once changed an thus triggered I use the new triggerId feature.
- platform: state
entity_id: binary_sensor.door
to: 'on'
I also added the door opening as a trigger so it would link the temperature when you enter. I assign it the same triggerId as changing the living room thermostat so it will cause the same action (aka, set the office temperature).
condition:
- condition: state
entity_id: binary_sensor.door
state: 'on'
This will make the automation only work when the door is open.
- condition: template
value_template: >-
{{ state_attr('climate.livingroom', 'temperature')|float !=
state_attr('climate.office', 'temperature')|float }}
And only if the office and living room are set to different temperatures.
action:
- choose:
- conditions:
- condition: trigger
id: office
sequence:
Now I start a chooser which will pick one set of actions depending on a set of conditions. For this set op actions the condition is that the automations was triggered by a trigger with triggerId office
. Looking at the trigggers, that is the changing of the climate object for the office.
- service: climate.set_temperature
target:
entity_id: climate.livingroom
data:
temperature: '{{ state_attr(''climate.office'', ''temperature'')|float }}'
If that was the case I call the service to set the temperature of the living room. As a value I grab the temperature of the office.
default:
- service: climate.set_temperature
target:
entity_id: climate.office
data:
temperature: '{{ state_attr(''climate.livingroom'', ''temperature'')|float }}'
If the above condition wasn’t met (aka, the automation was not triggered by a trigger with triggerIf office
=> it was triggered by a trigger with triggerId livingroom
= or livingroom temperature was changed or the door opened just now) it will perform the default
aaction which is doing the opposite. So now the office temperature is set to the temperature of the livingroom.
I use the default case so the triggerIf livingroom
isn’t really used / nessacairy but makes things a bit more clear. By using the default rather than making a simmalar case for the livingroom
-trigger as well will cause it to set the office temperature to the living room temperature if you manually run this automation.