for my heating automation(s) I am trying to execute an action based on a template.
Specifically, depending of the state of a sensor, I want to execute one action or another.
Example:
The code itself does not give any errors, but unfortunately the execution of the actions: list stops at this point and none of the succeeding actions are triggered.
Data needs to return a dictionary, not yaml. Also, if this just a single if statement and you aren’t going to have multiple options, you’re likely better off using if,then,else action.
Thanks for your reply! I read it multiple times and still can’t follow what you mean
Could you please elaborate a little bit more, maybe give an example?
I am running a sequence of actions to update the temperature settings for each thermostat.
Depending on the a binary sensor state (= window sensor reporting an open window), for a single one of those thermostats, I don’t want to update the temperature (which would trigger the TRV switching into heat mode), but instead I want to run a climate.turn_off action.
The automation itself is triggered by a number of different events, so its most likely not sufficient to place a condition clause before the input_number.set_value action for this particular TRV.
(I would need to check again, but there was a reason why I tried it the way it looks now).
If you know an alternative way to “phrase” it, please let me know.
Direct reply to your question (without going into whether it is necessary or not): you have to return dictionary in both cases, not just in the “else” case.
you can also use dict() function to make the dictionary: dict(value=states("input_number.heating_bedroom_day")). Either way, the whole thing must be enclosed in {{ }} for functions (states/dict) to work. Same applies to the target field.
I am, of course, aware of the template editor (been using it for years).
However, until now I was not consciously aware that it shows the data type of the output.
Thanks for pointing that out!