Correction, November 2026: An earlier version of this post opened with a gap in my energy dashboard that I never saw, named evcc as a client although I don't run it, described a Home Assistant add-on that my Docker install cannot run, and gave a made-up example of a wrong battery value. I have rewritten it from my repository history and the cache's log. The cache itself had a real fault until 31 October, which is described below.
Why a cache
My inverter is a Huawei SUN2000-8KTL-M1 with a LUNA2000 battery. Modbus TCP goes through the SDongle, and according to my notes the dongle allows only one or two Modbus connections at a time. On 4 April 2026 the AC THOR, which heats water with surplus PV power and reads the inverter to do so, held the connection permanently, and Home Assistant got no inverter data. Home Assistant reads the inverter with the built-in Modbus integration, not with the Huawei Solar integration.
A proxy for an hour and a half
The first attempt that day was a Modbus proxy running as a service on the VM of my Home Assistant: one connection to the dongle, clients on port 5502. I pointed Home Assistant and the AC THOR at it. The proxy passed every client's requests on to the dongle, and my notes from that day give conflicting transaction IDs between the clients as the problem. About an hour and a half later I replaced it with a cache server of my own.
How the cache works
The cache polls the dongle itself and answers all clients from memory. It opens a connection, reads 13 register blocks with 50 ms between them and closes the connection again. It started on 4 April with a 30-second interval, which I shortened to 10 seconds four days later. Since the fix in October it also waits 1.5 seconds after connecting; a first version of the fix without that wait did not work against the dongle, and I took it back. It is a systemd service of about 400 lines of Python on the VM of my old instance, and my new instance reads from it over the VPN. The register addresses are explained in my post on the SUN2000 registers.
REGISTER_BATCHES = [
(32016, 4), # PV string 1/2 voltage + current
(32064, 2), # input power (int32)
(32069, 3), # phase A/B/C voltages
(32080, 2), # active power (int32)
(32085, 1), # grid frequency
(32087, 1), # inverter temperature
(32106, 2), # cumulative energy yield (uint32)
(32114, 2), # daily energy yield (uint32)
(37113, 2), # active grid power (int32)
(37119, 4), # grid export (2) + grid import (2)
(37760, 1), # battery SOC
(37765, 2), # battery power (int32)
(37780, 8), # battery total charge/discharge + daily
]Reads with function code 3 are answered from the cache, each with the transaction ID of the client that asked. A single-register write with function code 6 goes straight through to the dongle. My Home Assistant only reads, and the cache's log, which goes back to 25 June, contains no forwarded write. On 20 November only my two Home Assistant instances were connected, each reading every 60 seconds. That does not tell me whether the AC THOR still uses the cache, and I have not checked its settings.
The fault until October
Until 31 October the cache sent every read to the dongle with transaction ID 0 and did not check whether a reply belonged to its request. After a timeout it carried on over the same connection, so a late reply could end up under the next register address. On 29 October the daily PV yield in Home Assistant briefly read 30,393.61 kWh instead of about 2.24 kWh, and later 42,949,672.92 kWh instead of about 18.26 kWh. Home Assistant's long-term statistics counted those jumps as yield.
A packet capture showed that the dongle sends a frame with transaction ID 0 at the start of a new connection that no request asked for. Since 31 October the cache uses its own IDs from 1 to 65535, reads header and payload completely, checks ID, unit, function code and length, and discards replies that do not match. After a timeout it closes the connection. Counter values that jump implausibly are rejected, and a client asking for a register older than 120 seconds gets a Modbus exception instead of the last value. I corrected the statistics afterwards with Home Assistant's recorder API, and I will describe that separately.
What the log shows
Between 25 June and 30 October the cache logged more than 861,000 polls. 693,442 of them read 12 of the 13 blocks, and all 13 came through only 681 times. I have not checked which block failed each time. In the same period the cache logged 383 warnings that its data was older than 120 seconds.
Between 19 November and the morning of 20 November, 8,761 of 8,769 polls read all 13 blocks. In the same time the cache discarded 8,750 unrelated replies, almost one per connection, which fits the unsolicited frame from the packet capture. There has been no warning about old data since 13 November.
What is still open
The cache runs on the VM of my old instance and reaches the dongle over the VPN. Once I switch off the old instance, the cache has to move, either into my home network next to the dongle or onto the new server. I have not decided which.
The code is published as cloudapp-dev/sun2000-modbus-cache, MIT licensed and without dependencies outside the standard library, with a Dockerfile, a compose file and a systemd unit. The corrections from 31 October are in its main branch but not yet in a tagged release.
Frequently asked questions
How many Modbus connections does the Huawei SDongle allow?
Very few. My notes from April say one or two, and while the AC THOR was connected, Home Assistant got no data.
Does the cache work with the built-in Modbus integration?
Yes. My Home Assistant reads the inverter through the cache with the built-in Modbus integration and a scan interval of 60 seconds.
Can I write to the inverter through the cache?
Single-register writes are passed straight through to the dongle. I have not used that myself, and my log contains no forwarded write.



