So, this morning I went to drive my kid to school. We were a bit late. When I stepped out the front door I saw that the windshield of my car had frozen over. So Home Assistant to the rescue, to give me a heads-up not to take that second cup of coffee but to go outside to defrost the car.
My approach would be:
Create a boolean flag “did it freeze last night”
Automation 1: set flag to off at midnight
Automation 2: if temp below +3° C between 0:01 and 7:00 then set flag to on
Automation 3: at 7:15, if flag = on then notify
So my question to you: Is this the “cleanest” way to do this?
Perhaps there is a way to have a single automation with a condition “has temp been below +3° C in the last x hours”, which runs at 7:15?
You can’t use a traditional automation here as what does it do if it’s already below 3 degrees at midnight. 3 degrees is quite a long way from freezing too.
You have two options both involve 3 objects - an automation and your input_boolean being common to both
The last item could be a boolean sensor or a script either one would check your time conditions and determine outcome.
I’d favour a script as that could also turn off your flag at midnight
Your suggestion actually does what you want is understood by you and is thus maintainable, I don’t think the persuit of ‘one automation’ to cure all ills, is desirable.
Thanks for your time Mutt.
Reason I asked is to learn new stuff, and to adhere to the KISS principle.
I was actually wondering if there is a way for an automation to look at historical data.
Probably you are right, best to build it like I laid out, and then see what the future holds
I don’t think there is a way to look at historical data, (but I’m quite amenable to be proved wrong ).
You might be able to do it with the statistics addon but I’ve not played with that, perhaps @petro might be able to give you some pointers ? Else I’ve seen the guy who wrote it around sometimes (but can’t remember his name )
Edit: not sure any of what I said counts as a solution
Petro, not sure this fills the requirements as he wants a notification @ 07:15 if it was below 3° at ANY time between 00:01 and 07:00 that morning (even if it was just for 1 minute)