Hi,
i’m trying to set an automation that fires up 3 days after my HA latest reboot, but at a specific hour of the night.
My hardware is slow and unsupported and sometimes RAM gets filled and a restart of HA is needed.
Originally I did an automation that fires up every three nights at 4:00 AM but sometimes I restart HA manually for changing some config and the nightly restart becomes useless. So my idea was to create a trigger that adds 3 days to sensor.uptime PLUS… “some hours to reach 4 AM”.
by the way, if your issue is that it craps out when ram gets filled, system monitor has info about ram usage and available swap. instead of doing a random reboot at some time, you could trigger off low ramp/high swap or something more directly the problem.
no, i mean sensor.uptime
I don’t need to reboot my hardware, only HA process
But this is not important, I need to understand how to do something at sensor.uptime + 3 days + some hours until 4 AM
my actual test trigger is:
{{ (states(‘sensor.uptime’) | as_datetime + timedelta(days=+3)).isoformat() }}
I wish to understand how to do better templates as it is a totally new language for me, my idea was to convert sensor.uptime to a simple YYYY-MM-DD trimming out the hours and minutes, but maybe there is a better approach.
So far I was able to create this:
{{ (states(‘sensor.uptime’) | as_datetime + timedelta(days=+3)).isoformat() }}
For instance I did a HA reboot (only my docker instance, not the whole hardare!) at 18:15 today (february 17) and I want to automatically restart HA on february 20 at 00:00.
If tomorrow I will restart it manually to adjust some configuration, the automation should restart HA on february 21 instead of 20
same problem, how to set a calendar event 3 days after a sensor state plus some hours to 4 AM?
i need some formula that transforms this: {{ states('sensor.uptime') }}
which now is: 2024-02-17T20:41:17+00:00
i get that you’re trying to do all the math to set a time and then prob create a trigger on that time. but i’m still thinking that’s overly complicated. does this do what you want and much simplier in 1 automation? no calendar event, no additional automation, etc.