Hubitat forgetting the right time

Hi - I hit an issue that caused a bunch of havoc in my household yesterday morning and I'm trying to figure out how to avoid it or work around it, or if there is a hubitat bug.

Specifically, I have a RM rule that flippes my mode from "Sleep" to "Home" at 5:50am with a few exceptions (in Vacation or away mode).

What happened?

  • My setup did not set me to Home at 5:50 am, so when the door was opened at 6am my alarms went off and woke up my kids (and then my wife who was not happy with me)
  • Half asleep I was trying to figure out what was wrong as it has worked every day for a few weeks now, and I realized thanks to the logs time stamp that my HE's time was completely wrong (like a full day early and wrong time wrong).
  • To "fix' The issue - at least for the next day - I went to the "location and modes" settings page and did the Browser time sync.

How did this happen?

  • The day before at 6:30pm (roughly), I killed some of the power in my house to install a new dimmer. The inevitably must have restarted the HE, and possibly my routers, but I know for a fact my routers were back and up with internet pretty quickly.

So my questions are;

  1. Why wouldn't HE have checked and updated the time it has for my time zone for that many hours (let's say 7pm Jan 1st through 6am Jan 2nd). I would assume the HE periodically checks for the time, specially on reboot and if there isn't internet safe to assume there is some delay and retry logic?

  2. Is there something I personally should do to help prevent this? I understand HE doesn't have a battery powered internal clock, and if there is no internet it can't get it, but in my case the internet was not down very long (if at all).

My biggest worries;

  1. This keeps happening.
  2. While away/vacation that I have a quick power outage when away from home, and I'm not able to reset any time until I'm physically back home.

Thanks for the help and thoughts.

Aside from the ntp issues, I would urge you to get a small UPS so you can prevent the Hubitat from doing abnormal shutdowns when you are not home. Those abnormal shut downs may be one of the causes of database corruption.

Anyone recommed for small scale version (aka cheap), for uk and could run a router (sky)?

1 Like

Hubitat Time Drift (c) (tm) is a well known thing.
In addition to all the advice already given, take a look at @dan.t's

As @aaron says: You can put in any NTP server you want. Having a local NTP service just makes your HE less reliant on cloud and all of your local time based systems to be in sync from a single local source.

It works like a charm.

2 Likes

In some older firmwares there was an issue with the hub not reconnecting to the internet if it couldn't when it first came up (router wasn't ready yet) or if it lost access for a while. I believe this was supposed to have been fixed in 2.6 or something like that but I haven't verified it. The NTP client @GatVlieg referenced has been working well for me, I have it connecting to a server in my network which gets its time from NTP on the internet but if it can't get to the internet it doesn't have the same problems Hubitat does with its clock on reboots or nightly maintenance if the internet isn't available at that time.

Thanks. I just installed the NTP Client, but that will only work if my Windows PC stays up as well.
Does anyone know natively how often without the NTP Client (or in parallel of it running) HE checked their cloud for the latest time?

None of this explains why for over 12 hours it never tried to re-sync it's time.

It doesn't just have to be your Windows PC you use for setting the time.
Not being able to set your time if the internet isn't there will be the least of your problems; if you think the wife & kids were unhappy with an alarm because of an incorrect time, wait until nobody has internet...

As for a reason, your guess is as good as mine. My system had time drift as well, but never in the severe category. With this little gem I have never had any time drift again.

Agreed. I guess I'm wondering what should happen after an HE reboot. If it can't get the time right away, when is the next time it's supposed to check, as I seemed to have hit a 11 hour+ window where it did not.

This is what I do to make sure HE ALWAYS has a ntp server it can reach.

I bought a Raspberry PI and installed ntpd on it which syncs to a off site time server. Then I installed the app mentioned in Hubitat forgetting the right time here and then setup that app to get the time from the Pi.

This way no matter what HE will always reach a ntp server and keep time regardless of network outage.

NOTE: Pi's do not have rtc chips so to combat that I bought a RTC Hat that works exactly like your PC RTC using a battery to keep time if powered off or can't reach the network for a time sync.

3 Likes

Thank you.
Right now I have a Windows PC always on as my Plex server, so it should do for now modulo a full power-outage and the laptop battery dies... but that’s ok.

The main open question I still have though is what is HE's theoretical performance here in terms of after a boot, when should it check to sync the time with the default server, and if it can't reach it, what the fall back / next check is, since I've seem to hit a window of 11+ hours with no check.

I have no idea. Maybe @bravenel or @mike.maxwell can answer that.

Pinging this thread, as the open question I still have is what should be the expected behavior for when Hubitat queries the cloud for time sync after a reboot and if there is any retry logic or when the next check would be.

I'd love to mark this as solved for others.

Thank you

Had something similar happen to me. HE thinks the time is 7:45am MST, the automations think it's 7:45am MST. The logs even say my kids lights were auto-turned on at 7:45am MST, but it actually happened at 5:45am MST.

Pretty basic, priority 0 stuff when writing software is to get your time right. Any official word here that isn't "buy a UPS" or "install a server"?

I ended up running the excellent NTP Client / Local NTP Server support app. I also have put my HE (along with my Router) on a UPS which I needed to do anyway.

1 Like