HA container does not respect NTP time change on host after container is started

I run a container install of HA on an 8 GB Pi 5 (which also runs many other services, thus I don’t want HA to take over the OS).

I do not have a clock battery, and thus if the Pi has been off (e.g. power outage, thunderstorm, etc), it might take a few minutes to get the correct time. Often the Pi is up before the Internet is up.

Now the issue: if the HA container starts before the time sync happens, it seems scheduled events ignore that the time changed. This leads to lamps turning on at the wrong time, etc.

I use triggers like:

at: "22:00:00"
trigger: time

So I would expect them to respect the system clock if it changes. It also affect sunrise/sunset triggers, so it seems to be a global problem. If I run date inside the container, it is of course correct.

I think this is a regression, but I don’t know exactly when it started happening. Sometime earlier this year I believe is the first time I noticed it, but I didn’t figure out the cause until now.

It almost seems like HA reads the time once at startup and then just uses offsets from that. Is there a way to fix this? A known bug (I didn’t find anything in the bug tracker)?

A ds3231 is less then 2€ and solves all your problems.

I understand that getting some sort of real time clock for the rpi (either the official clock battery for Pi 5, or something connected to I2C) would solve this.

I still think HA should respect time changes though. The clock can drift over time and get corrected by NTP too for example.

Totally agree, but since it doesn’t, it does not hurt to look at an alternative solution