I had a catastrophic failure one morning. I lost my internet connection and, at the same time, Home Assistant crashed.
When I restarted the Raspberry Pi where HA is located, it returned with the wrong date and time.
I tried several ways to make the correction manually, but I discovered that Home Assistant does not allow me to make this correction. The date and time were only corrected when the internet came back (which took a while). In that interval, all the automations became useless.
If I had any critical application running, I would have serious problems.
Home Assistant MUST ALLOW the date and time correction if it cannot connect to an NTP server.
Do you not run an ntp server locally?
In case HA is running on a raspberry you can change the date and time via terminal.
#date -s “25 OCT 2024 18:00:00”
You should be able to use that command on most Linux installations.
The problem with the Raspberrys is that they have no Real Time Clock, so when power goes the data and time goes back to something like January 1. 1970 at midnight.
If you run critical applications, then there are several solutions.
One could be to run a NTP service on another device on the network.
Raspberrys and ESP boards can do this over the internet or you can make a Stratum 1 server with an ESP board, which use the global radio signals to set the clock unrelated to the internet.
You could also use hardware with a builtin RTC.
Often your modem/router is already acting as a ntp server.
Yup, but many routers do not have a RTC themself, so they also need to get the time from the internet, before it can be served.
A yes, that is an important thing to check. Also a NAS can serve as an NTP server if you have one. Synology for instance also has a RTC.
I have to admit that this project looks cool:
It is a Stratum 1 server, which means it gets the time directly from the GPS signal, so no internet needed.
I tried, but the version of Linux that runs HA on the Raspberry Pi has several restrictions.
I chose the Raspberry Pi because it was the best hardware that combined processing power with low consumption. However, when I made this choice, I didn’t pay attention to the fact that it didn’t have an RTC, because it was my first purchase of this type of hardware and in the various channels of experienced HA users that I researched before choosing a platform, absolutely none mentioned this feature.
I have an excellent router, but it doesn’t have an NTP function and, in my opinion, this is a function that should be in the hardware where HA is running, that is, if it can’t access an NTP server, it needs to automatically use the RTC and, if it can’t, it needs to allow manual adjustment of the date and time and continue running.
But how do I re-point the NTP server in HA OS? Everything I’ve researched on this subject always points to “unofficial solutions”.
I do not know how you redurect the NTP usage to another NTP service.
I will have to look into that, because it will have to be something that can be set so it will be used at first boot and stay with that setting over reboots and updates.
The RPI pi5 have an embedded RTC chip, you just need to add a CR21 cell to the connector.
What difficulty in running date -s did you experience?
Crony is still internet dependent and would have lost its time setting when the HA host dies.
Yes, I know, and I should have made this clearer in my post.
My suggestion to use chrony was based him also following your earlier suggestion:
Personally, I’d bite the bullet and upgrade to a Pi5, which actually has a built-in RTC
HAOS will take the ntp server provided via DHCP on your network, if there is no ntp server available via DHCP, it uses as default time.cloudflare.com
and a list of others as fallback. You can also add your own ntp server (eq. your local router if it can act as ntp server) to the configuration as described here (this change will survive on reboot). Yes, this is on cli and not the WebUI, but it is at least a workaround for your issue, until someone contributes the NTP configuration options to the supervisor.
Home Assistant OS (for Raspberry Pi) does not allow changing date and time via terminal. It does not recognize Linux commands.
I already have a Raspberry 4 that works well for me. And there is already a Ds3231 RTC module made specifically for the RP that works, but the HA operating system made for the Raspberry is full of “limitations”, and that’s the problem.
How can Home Assistant support thousands of integrations and not allow you to activate a simple RTC on one of the most used hardware devices?
This is the Ds3231 device:
I’ve already researched Chrony. It doesn’t work. The ideal is to install an RTC on the Raspberry Pi and have Home Assistant allow you to install and recognize it.