Set or customize NTP source

I am running hassio on a Rpi3 Home Assistant Version 0.79.3
Searching for NTP related queries, I find only subjects where people are looking to serve NTP from their pi / hassio

I want to change whatever the default is, to a local network NTP service already in place.
I think I am close, alter config.json? but I can’t access/find it, the SSH add on does not seem to be any help in this regard.

What am I missing? Import from USB? Little help?

1 Like

Bump? I have left this alone, but it has come around again. I would prefer NTP queries not leave the internal network. I’m sure it is something simple…

I am now running version 0.83.0 for what it is worth.

Thank you,

1 Like

I also want to know how to do this. I’ve been using hassio for a few months now and I just realized that there doesn’t seem to be any NTP client support for syncing hassio’s internal time to a timeserver on the network. I have another machine on my local network that serves NTP for the whole house, I’d like to point my hassio at it too, so it’s aligned with the rest of the network.

The instructions for updating the time source are in Configuration.

If you have access to the root filesystem:

You can manual edit the systemd timesync file on /etc/systemd/timesyncd.conf . Our default ntp configuration look like:
[Time]
NTP=time1.google.com time2.google.com time3.google.com
FallbackNTP=0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org 3.pool.ntp.org

If not:

Format a USB stick with FAT32/EXT4/NTFS and name it CONFIG (in all capitals). Alternative you can create a CONFIG folder inside boot partition. Use the following directory structure within the USB drive:

timesyncd.conf

The timesyncd.conf file allow you to set different NTP servers. HassOS won’t boot without correct working time servers!

You can put this USB stick into the device and it will be read on startup and files written to the correct places. The USB Stick just needs to be insterted to the device during this setup process and can be disconnected afterwards.

5 Likes

Hi, I’m new to Home Assistant and have limited Linux experience but I’m 99% I have this same issue: while running Hassos on a PI4 (no internal clock) with no internet access, the system does not fully boot-up. It forever hangs at “homeassistant login:”.
While it boots up (incompletely), I see no log complaining about NTP related failures.

As suggested by @rodpayne, I did create a USB drive with a custom NTP config pointing to my local network, tested, windows hosted NTP server.

When I boot up with this custom config in place, there is absolutely no difference. I see no additional logs, and the boot process still hangs in the same place.
If I boot exactly the same setup with internet enabled, It hangs for a very little while (~5sec) on “homeassistant login:” but then it continues and completes the HA start-up with no problems. Only in this case I can access the HA ui.

As I’m out of ideas and I believe Hassos is not really meant to completely fail if no internet, please advise what else I could be missing. Could it be that NTP custom config is not considered when internet access fails?
PS: I can see the “CONFIG” usb works at least for “network/my-network” configuration, as I am using it to configure the wifi and is working fine on my setup.

I am having the same problem as LucianAut. I am trying to run HA offline and it hang up on load up without internet. Everything I have read points to the NPT server, but I am still trying to find a fix. I am new also and would like to be able to use HA offline but as this point I have had no luck.

1 Like

I use HA in python venv not hass.io as I run other things on the pi so I can change the ntp settings myself, however I have smart plugs and lightbulbs that abuse public ntp servers for connectivity check which I can’t change thus I opted for redirecting any and all NTP requests to my router on which I run OpenWRT and my own ntp server.

Even if you don’t use OpenWRT, if it’s decent router it should let you define your own firewall rules, these are what I use in Custom Rules under LuCi / Network / Firewall:

# Force NTP
iptables -t nat -A PREROUTING -s 192.168.1.0/24 -p udp --dport 123 -j DNAT --to 192.168.1.1
iptables -t nat -A PREROUTING -s 192.168.1.0/24 -p tcp --dport 123 -j DNAT --to 192.168.1.1

This has the benefit of not having to set the ntp myself on each new device / vm / container etc I decide to spin up.

So there´s still no solution to run HA on Rpi4 fully locally?

This helps, thank you!!!

hi ,

i am trying to achieve something similar , what should i write in that file to make sure hassio boots up without internet

TIA

1 Like

I see you’re not getting an answer. I didn’t get any as well. It seems this is a fringe thing, which is weird to me as my HA Core install just basically doesn’t work without internet, and almost all of my stuff is local, not cloud.

i had a older copy of hassos which i booted with ethcer, that works fine booting offline
and i just checked one of my installation is working from last year without any problem with same hassos as mentioned in the picture attached

any idea why ?

Screen Shot 2020-09-21 at 11.07.08 PM

hi, any idea how to do this on a virtual machine? I am running HA on VirtualBox

If you have access to /etc/systemd/timesyncd.conf, it should work the same way. I don’t have experience with an HA virtual machine.

If you upgrade to HassOs 6.1 , there is a check now at boot, so it gets synched correctly… My time was also incorrect before on cold boot when running esxi… Now that’s been corrected

I’m running a datalogger running HassOs 6.2 within a company network. Only struggling with time running out of sync as soon as the logger is rebooted. The company offers their own NTP servers.

Tried the USB method for uploading ‘timesyncd.conf’ but with no avail yet. Together with IT-support I’ll try to go for the method of forcing NTP via an firewall rule that G.G.B.Spender posted.

Maybe anyone is aware of another option to change NTP servers within HassOS that I have missed?

2 post above

/etc/systemd/timesyncd.conf

there you can change it in HassOS

Thanks for pointing that out, I tried to find ‘systemd’, but I can’t find it using using the SSH & Web Terminal addon in HassOS. I think I’m having some trouble logging in as root, so I will try to figure that out first…

you need to enter in the host itself not with ssh addon, thats not possible…
you are running virtual, right? then you need to go to the console

or use this addon

I have standard HA install, but there is no /etc/systemd folder: