Hello,
I’m having trouble defining an automation that, as the temperature of a sensor changes, does two different things depending on the temperature reached. in practice I would like that:
when the sensor temperature is <= 17, a scene is executed
when the sensor temperature is >= 20, a climate is set off (state: off).
The problem I’m encountering is to create a single IF … EIif … EndIf
at Action level that is able to activate the scene in one case and switch off the climate in the other.
Can you help me? Thanks in advance.
You should also respond to @finity. What you may be after is the “choose” action for your automation.
Here’s an example where my air-conditioner automation determines whether to heat or cool based on the temperature and solar production - in my case it runs a script. You could tailor this to your own case.
but obviously, being newbie in HA, even if the logic is correct the coding is wrong. The problem is having to execute both a scene and a service in a single IF, and the service_template: is certainly wrong, but I don’t know how to fix it.
Hello @finity ,
thank you for this solution and thanks to @teda-230 for the previous one. I did not know the choose: opttion and it gives me the impression of being equivalent to a differently coded IF. What I don’t understand is why in your code there are two choices: while in the @teda-230 example there is only one. Surely both structures work, but on a logical level I would consider @teda-230 structure more correct, or am I wrong? Anyway thanks to both of you for your assistance and for your solutions.
EDIT: I changed the last line with hvac_mode: 'off'
and tried it, but it reported this error:
Invalid config for [automation]: [hvac_mode] is an invalid option for [automation]. Check: automation->action->0->choose->1->sequence->0->hvac_mode.
I’m sure that hvac_mode is correct because it works in other automations: