I am pretty new to automations in Home Assistant. I am a sw developer, and that seems to be making things more difficult actually
I have a switch and a thermometer… I want the switch to turn on when the temperature is above 32°C, but only during between 8:30 - 21:00. Otherwise, the switch should be off.
I ended up creating three scripts.
One to turn on the switch above 32*C and betwen 8:30/21:00:
And finally, one to turn it off always after 21:00:
alias: turn off at night
description: ""
triggers:
- trigger: time
at: "21:00:00"
actions:
- type: turn_off
device_id: 3dc45ca861d7fb6b1d8c09cfdb1db294
entity_id: 0e8f0b76e005503792b6d57fbefeb661
domain: switch
mode: single
It seems to be working, but it feels like overkill. Three scripts for such a simple task?
What is a better way to in Home Assistant to address the issue? Can i mix the three scripts into one? Is there a better way?
thank you, i need to learn trigger id’s and the associated usage… I know that LLMs are good for this, but i prefer to learn it myself, i am a bit old fashioned
There’s another technique you might be interested in:
You’re right, though, it often doesn’t help to think of automations and scripts as software - they’re more like rules. When this happens, do that. A large collection of separate automations may seem “inelegant” but it can be much easier to maintain.
i will stick with the automation with the triggers because i think it’s more explictive of the logic behind it, and the custom thermostat will still require an automation.
But the termostat has a lot of logic that will keep it running when the automation does not.
For instance a reload or reboot will make your only fan (I assume it’s a fan) stay on or off if the temperature crosses the threshold at the same time.
The thermostat will know it’s out of bounds and turn on/off.
And has a much easier interface to use if you wish to use it manually or set a new temperature range