This has been working fine but now that it is getting colder I would like to add some logic to consider the temperature in the office and turn on the fan if it is above a certain temperature and the space heater if below a certain temperature.
If office.wall_switch is on
turn on office.speakers
turn on office.mixer
turn on office.neon
if office.temp under 68
turn on office.heater
else if office.temp over 75
turn on office.fan
notify.my_phone
I am trying to understand the best way to implement this added condition/logic. I want to be certain that the fan and heater aren’t on at the same and that neither is on if temp is between the high (fan) and low (heat). I was looking at conditions within the actions but that dead-ended quick since the actions stop if evaluation = false.
Thank you, I appreciate you taking the time to respond. This appears to work as expected. I didn’t realize I could use variables nor did I know that you could use conditions the way presented. I can use both to simplify some of my other automations. Thanks again!
You should know that the automation employs new functionality introduced in version 0.113.
choose allows you to introduce ‘branches’ in the logic’s flow. If you are familiar with other forms of programming, it’s like a chain of if-elif statements (or a case statement). In this automation, if the office temperature is below 68 then the heater is turned on. If it is above 75, the fan is turned on. If it is neither below 68 or above 75 (i.e. it is between the two temperatures), neither the heater or fan are turned on.
variables let you define a variable that can be referenced anywhere within the automation. However it cannot be referenced outside of the automation. In this automation, we define a variable called office based on a sensor’s value. The variable is referenced twice by two separate conditions.
The automation also uses the new compact way of defining a Template Condition. Instead of the traditional way (which is still valid):