I run HA in a location where power is turned off for several days at a time. When HA boots the time is off by several days. So, all of the automations that work off of sunset do not function till the next day. When I restore power, I tether a phone for internet, so it takes some time to get the correct time. I have been trying to figure out how I get the sun calculations to update bit have not had success. The only thing I have found was to restart HA once the time is updated. Is there any way to automate the restart or fix the calculations? I was thinking of using elevation of sun but that does not get updated after powerup.
What hardware are you running on? The BIOS will usually keep the time, unless the BIOS battery is flat or you’re running a PI that doesn’t have one. If the latter, you should be able to force NTP to have updated before HA starts (depending on the HA installation method you’ve used).
I am running on a RPi4. That is a good thought to delay the startup or maybe even better to add a RTC that would simplify things.
I am using the HA OS distribution. I could not find a way to do either of these choices so back to original question.
It’s a bit hard to confirm (and I don’t use HAOS), but it seems it needs NTP to boot already. You can check and change the NTP settings if needed, it seems.
I suspect your pi is coming up before your tethered internet is available. Therefore the pi can’t set it’s time when it starts.
You could try an automation that runs, say, 2 minutes after a restart and reloads the sun device.
Action would be like:
service: homeassistant.reload_config_entry
data: {}
target:
device_id: 75aec5f18d9496933b82c5688da2105c
Could be and thus it can’t set the time.
Yes, that totally is the normal sequence internet is up after the router boots. That is what I was looking for I am thinking that I can check for internet access and then reload then call the service to reload the configuration. Thanks for the help I recently switched from hubitat to HA and it is quite a diverse platform. I have already triggered that service and saw it recalculate the times so I think it will work thanks!