I have been making separate automations for on and off. For instance, If I want a switch to turn on below a certain temp I have one automation. If I want it to turn off above a certain temp I have another automation. The trigger is always Time Pattern /15 minutes so that it can run at any 15 minute period the temp threshold has been met.
How do I create a single automation with both on and off action based on the temperature of a sensor with the trigger set to check the temp every 15 minutes? I have a space heater connected to the switch which I have named as switch.zooz. The low temp to turn on the switch is 60 and the high temp to turn off the switch is 70. The temp sensor is sensor.office_temp.
I hope it works, I can’t test it out… If it doesn’t, let me know the logs. You don’t need the 15 minutes polling, it’ll check every time your sensor is updated
I suggest modifying the template to (I also added an extra elif statement and an else statement to cover the temps between 60 and 70 - otherwise, no service would be specified and you’d get an error). Finally, I added set statements so you only get those states once (saving a micro-second or something so you don’t call the same thing twice):
I added the third elif statement to cover the times when the temp is between 60 and 70. The only way to get this far is if the temp is between 60 and 70, so I don’t need to check for that. If the switch is already off, that means you are cooling off from 70 down to 60, so leave it off. The else statement covers for the only remaining case where you are heating up to 70, so that keeps the switch on.