Hi,
I don´t know if I could explain it very well - so if something isn´t clear please ask.
I´m using HA a while and the automations are growing and growing. And I ask me: Isn´t it possible to reduce the number of automations (and the complexity of the automations) with some magic commands? Let me explain: I am using a thermostate which I automate to change the temperature several times a day - depending on if the present day is a workday or on a weekend. So at my point (and with my skills) I´ve got two options:
One automation for one time of changing the thermostate.
One automation with very complex if/then (translated :)) constructions
But isn´t it possible to declare my time table in something like a variable and creating one automation with a relative simple syntax?
Hope you could understand what I like to say. I´ve tried different blueprints but not ones fit to my needs and I´m wondering: I couldn´t be the first one with these wishes.
Well, thats what I mean with number 2 (very complex if/then constructions) but you are right - these would reduce the number of automations. But will it be faster? What is the best for automations: Many but simple automations or fewer automations with complexer commands?
I don’t think this will affect speed very much - maybe a millisecond or less. It is more not having to manage so many automations. If you are comfortable with managing more automations then please continue on that route. If you start losing track of automations then you should choose the combined mode. This is really personal preference. As an engineer, I appreciate the elegance of some of the combined automations. Getting things to work is the most important and if you need brute force and stupidity to get it done then I am all for that - have and still use it for some automations. I can clean up after the automation works and meets the wife approval factor.
@AllHailJ I´m an engineer too and I totally agree with your approach. But I´m also looking for something smarter solution. I´ve read a great blog post about smarter automation and I´m fixed on :). And I found Template integration which will allows you to reduce the complexity of an automation. But, and thats the annoying point, I don´t get it and I hope I´m not the only one who is seeking the solution for that climate control automation.
I tried to control my heating with automations as well and quickly gave up. Automations seem to be a bit bloaty for this task.
Currently I am using the appdaemon addon with schedy and it works nicely.
But I´m not happy with that: Too many redundant configurations and to complex to understand it with only one view. Every condition I have to add makes it more and more complex.
I´m searching for a simple automation “set temperature with settings depend on the time of day” with definition of timetables with responding temperatures. You know what I mean?
Of course: Shedy is nice but not easy to manipulate (after configuration) and its a separate configuration on a different point. I like all settings on one point.
The following is a consolidated version of all three automations. I think I understood the purpose of the binary_sensor but if I didn’t then it will require adjustments.
Override when the binary_sensor is off for 1 minute
Disable when the binary_sensor is on for 2 minutes
The choose has three choices where the first two corresponds to one of the first three triggers and the last choice is for the fourth trigger.
EDIT
I overlooked to mention that because this is a single automation, it cannot do what your third automation does and that’s to turn off the first two automations (because it would be turning itself off in this case). What it does instead is to have the weekday/weekend triggers check if the binary_sensor is off before setting the thermostat’s target temperature. If it’s on then the scheduled operation isn’t performed.
I just noticed an edge case as I was testing. If the times are the same in weekday and weekend it will always take the first. So for 08:00 and 22:00 it will take weekday and not run.
Good point; I overlooked that important detail. It effectively prevents consolidating the weekday and weekend schedules into one automation if both have common hours.EDIT I was too hasty when I wrote that; I now believe it can be done. I’ll post it tomorrow.
Dual version
It’s fairly easy to split the consolidated version into two separate automations, each handling its own schedule. The disabling logic can go in either one; I put it in the first automation.
As promised, here’s the revised version. It’s more compact than the previous version I posted and can handle a scheduled hour that’s common to both the weekday and weekend schedules.
I can assure you that saying ‘abracadabra’ didn’t make the “script part” materialize for me.
That changes my understanding of the binary_sensor’s purpose. Can you explain what role this binary_sensor plays with regards to the schedule?
That error message implies the variables in the example I posted have been altered. In the example, the key-values pairs (in weekend and weekday) are both integers (the error message is indicating one of them is a string).
Ah OK. Let me say it this way: It’s hard too “read” the script part for me and creating such code for me is doing magic :).
That’s easy: It’s a sensor that detect “door is open” and if the door is longer open than 2 minutes the thermostate should turned off and under no circumstances it should turned on. If the door is closed (“off”) for one minute the thermostate should turned on and the regarding temperature for the time slot should be set.
Hmm, I just copied your code. But I will check. Thanks.
That’s how I assumed it should work so I advise that you do not make the change you suggested.
The only change I would make is to rename override to enable to make it clearer that the scheduled operation is being re-enabled (after having been disabled by the open door).