"Unknown" Energy stats every other reboot

I have a “Solar Assistant” Raspberry PI that is attached to a SunSynk inverter. This uses MQTT to send through statistics to Home Assistant. I have various automations that help us deal with the rolling blackouts that we have in South Africa, known as load shedding.

Since a few days ago, the statistics have not been reliably fed through to Home Assistant and all sensors in that integration report “unknown”. A while ago, I set up a nightly reboot of my HA raspberry pi to help with some other stability issues (things would hang and freeze - that seemed to sort it out), and I noticed that at 03h05, when the box rebooted, the energy stats would either start or stop.

This screenshot shows the “unknown status” starting at 03h05 and ending at 03h05 the next morning, and so on, on April 11 and April 12. You will see that April 12 has a very short “unknown” section - I rebooted the box manually at that point. On April 13, you will see the same again - And yes, I was up at 4am, and rebooted the box to get this working. For what it’s worth, we live in a place that has a comically unstable electricity supply, hence the very two long “Off” periods are more or less accurate: we were without power.

While the short answer is “don’t reboot your box”, that doesn’t help for situations where, for example, I need to install updates and update HACS modules, which require reboots.

Restarting HA doesn’t seem to make a difference, only rebooting does.

Solar Assistant, in all this, hasn’t lost power once and I’ve rebooted it only twice in the last 6 months (once yesterday - didn’t make a difference). I’m therefore fairly sure that SA is not the problem.

My problem is, though, that I have no idea how to debug this scenario! I’ve checked logs and can’t see anything obvious.

Any assistance to remedy this would be greatly appreciated!

Neither of those require a reboot of the host. Only a restart of Home Assistant.

My initial thoughts are to try to resolve the hang/freeze issue first. It might, or might not, be related but a stable platform would be my first priority. I would make sure the hardware is ok (power supply, SD card, etc.). Selectively disable integrations to see if that has any impact on the hangs/freeze, etc.

Touché. What about Home Assistant OS updates?

The point is, at some point, I’ll need to reboot, and it would be really nice if I didn’t have to wonder if my power stats are going to be affected.

Well, perhaps, except that it’s been “working” with my nightly reboots for many months now. I’ve disabled the reboots - so let’s see: perhaps it is even resolved?

I’m really just trying to work out where I can look to see why this specific issue is happening and if it can be solved.

How have you installed home assistant?

Which mqtt broker are you using and where is it installed?

It appears that this could be the culprit. I’m using Mosquitto Broker which was recently updated to 6.2.0. At least one other user has reporting the same issue (Problem after upgrade mosquito broker to 6.2.0 - bridge with Supla - no auto-updates · Issue #2945 · home-assistant/addons · GitHub).