NTP Client / Local NTP Server support

All,

with the just release Hubitat version (2.1.5) there is a new function to set the Hub time via an API call.
Here is a driver that allows you to specify a local NTP server to retrieve the date/time from and it will update the Hub accordingly.

Right now, the driver does NOT support SNTP, only plain old NTP, however. It checks the time on boot and every X minutes (configurable).

The configuration should be pretty self-explanatory but I am happy to elaborate if anyone has questions.

You do need Hubitat version 2.1.5 or higher to have this driver working!

15 Likes

Thanks for sharing this. Installed and working great!

1 Like

Works really well. Thanks a bunch!

1 Like

Nice job on this driver.

1 Like

Works great !! Thanks for the developing the code so quickly after the update. I have it pointed to my Synology Diskstation and it is doing the job.

1 Like

What types of devices can be used for a server?

Anything capable of running a NTP server that's always on; PC, laptop, rPI, etc. I have a simple NTPd server running on a rPI Model 3B, for instance. Works flawlessly.

2 Likes

To add to that list of devices that can be NTP servers: NAS, and some routers/firewalls running for example openwrt, pfsense, Mikrotik. All of these can also have their NTP time synced using a cheap USB GPS dongle, which makes them great for setting time even when there is no Internet access.

1 Like

Excellent work! Works awesome with my RPi. :slight_smile:

1 Like

Is the reason behind this device driver solely so that no Internet look up be made?
Is that the only reason behind this device?

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.

4 Likes

I suspect that the hub doesn't update its clock on a continuous basis after the one check it does at boot time. So your HE clock will drift over time. After a couple of weeks, mine was a good 4-5 seconds off. This NTP client can be set to update your clock periodically and/or if its out of sync by various amounts.

You don't need to suspect, the hub makes a call every 24 hours

4 Likes

Good to know, thanks. Im assuming its a web call to worldclockapi and not ntp?

It uses ntpdate, if that fails, it calls our server and if that fails it calls worldclockapi.

1 Like

Question:
Should I be worried about the following error?
I set up a Virtual Device with this as the device driver, and pressed "refresh".
That should update to the NTP time? (if the hub is off)

I have seen this here and there in 1 out of 50 NTP requests or so. The next request always worked. But to be sure, I would need to see more of the log

I looked at this more carefully now, did you enter an IP address for your NTP server in the device settings?

And it still happens when you press refresh. It might have been from the very first execution when you installed the driver and there was no IP address yet