Hi,
I’ve searched like crazy how to do it but finds nothing (or understands nothing). Probably I’m searching in the wrong places because it must be a quite common automation procedure. I’m a Home Assistant newbie, so I may have misunderstood things.
What I want to do:
When the target temperature of my entity climate.hallpumpen changes, I want to read the target temperature attribute from this entity and pass it on to another entity, called climate.vardagsrummet and update its target temperature to be the same.
I have created an automation that works:
alias: SetRadiatorsVardagsrum
description: >-
Changes Radiator temperature "Vardagsrum" when Hallpump temperature setting is
changing
trigger:
- platform: state
entity_id:
- climate.hallpumpen
attribute: temperature
condition: []
action:
- service: climate.set_temperature
data:
target_temp_high: 19
target_temp_low: 17
target:
entity_id: climate.vardagsrummet
mode: single
However, for troubleshooting, the action is hardcoded, just to see that the automation works.
Now I want to change the hardcoded “target_temp_high” value of 19 to the value from climate.hallpumpen, but I don’t understand what syntax to use.
I can read the climate.hallpumpen target temperature attribute by the code: {{ state_attr('climate.hallpumpen' , 'temperature') }} and it returns the correct value.
But how do I pass it on to climate.vardagsrum in my automation action?
I may be wrong but my impression, based on the documentation for the climate.set_temperature service call, is that both target_temp_high and target_temp_low must be specified (i.e. you can’t set one without also setting the other).
It’s also my understanding that the attributes target_temp_high and target_temp_low exist only when the thermostat’s hvac_mode is heat_cool. So if climate.vardagsrummet is in some other mode, the two attributes aren’t defined and attempting to set them with climate.set_temperature is likely to fail. All this to say that, ideally, one should confirm the thermostat is in the desired mode before setting target_temp_high and target_temp_low.
If I’m wrong about any of this, please correct me; I don’t have a suitable thermostat to experiment with heat_cool mode.
Taras, you are correct, both attributes must be set when triggering an action. But that’s no problem for me, I’m only using the target_temp_high and can hardcode target_temp_low to whatever.
I must have made some error, now both method works. Thanks!
Of course, reading documentation helps. But as a newbie its hard just to know where to start, the written knowledge is so huge and spread out so you are just lost.
I understand that the first alternative picks the temperature attribute value from the defined device Hallpumpen. The second alternative pics the temperature attribute from the device that triggered the automation (whichever it was)
Yep, there is quite a steep learning curve. But, start with the official documentation. Read through it several times. Take baby steps. Regarding this forum and other sources of help, the sheer volume of data can indeed be overwhelming. But be careful, a LOT of what is on here gets quickly outdated.
Exactly. You’ve got it. In general, I go with the second method for a couple of reasons. If I change the trigger entity or entities, I don’t have to change the action. Also, in the rare case that the trigger entity changes between the trigger firing and the action being executed, the automation is always reacting to the event that triggered it, not some later data. Of course, there may be times when the latter is more appropriate, too. Basically, get to thinking about what makes more sense based on the particular scenario.
As long as no one ever turns it off or sets it to heat or cool or there’s a communication problem and it becomes unavailable then, I agree, you don’t need to take that into consideration.