Make timers survive restarts

It’s kinda frustrating for me that timers don’t survive restarts.

I worked on a fix for this, but life happened and I still haven’t found time to finish the tests to get it integrated. I have a custom_component that at the moment still works:

Form Post

Git Repository

The issue I see with having timers survive restarts is that HA will have no idea how long it was offline, so the timer value becomes irrelevant. HA could have simply restarted (in my case less than a minute) or there may have been a 2 hour power outage… what value should the timer restart on?

The balance of its duration minus elapsed time when Home Assistant stopped and restarted.

  • A 60 minute timer starts.
  • 15 minutes into its countdown, Home Assistant stops.
  • The timer has 45 minutes remaining.
  • Home Assistant restarts 30 minutes later.
  • The timer has 45-30=15 minutes left.
  • The timer is restored and finishes the balance of its countdown (15 minutes).

I posted an automation and python_script that restores active timers in that fashion.

How to make active timers survive a restart

1 Like

I guess I wasn’t thinking of HA being able to relate the timer value to actual current time of day. :man_facepalming: