Firstly, I’m aware that there are thermostat scheduling integration and blueprints out there. But I wanted to try my own as a learning experience. I just completed this and noticed there are numerous dangling “else” statements. I believe that is normal. Also, I’m using multiple triggers so I changed the mode to “restart”. I believe this is necessary in this case. Please correct me if I am wrong.
Those nested Ifs will never do anything because any given run of an automation will only ever have 1 trigger. As it is currently configured the 5:30am trigger will produce the desired results and the 11am trigger will work in the Else. The 11:30pm trigger will never do anything.
For branched logic where all the options are mutually exclusive, like times, the Choose action is a better fit than If/Then. Especially when there are more than 2 possible options.
If you just want to do it with If/Then, it is possible. You just need to un-nest the Ifs so that each of them is always checked:
With the current triggers and actions, the restart will never be needed. That mode is only needed in cases where you need to break into a running automation because it is taking time doing something. The actions you have should be completed in microseconds and your triggers are hours apart.
There are a number of ways to make this automation more compact / less verbose.
Your automation is designed to perform one action (climate.set_temperature) but using different temperature values depending on the time of day. The temperature values can be specified as trigger variables in each one of the three Time Triggers.
In effect, the decision-making (which temperature value to use) becomes part of triggers so actions doesn’t need to decide (using if statements or condition) what to do.
Question – I’m a YAML novice. Is there any way to see the variables on the visual editor?
Also, I’m curious as to why when I added an additional time trigger for testing purposes, it also copied the hi and lo variables. Not sure why it did that!