BUG - Sporadic Register Shift with Modbus TCP
I have integrated my WEM3080T into my HomeAssistant using the Modbus TCP interface.
It worked like expected a long time.
After updating the firmware of the WEM3080T to i.75.99.bin i have noticed strange measurement values in my energy dashboard in HomeAssistant.
I have analysed the issue and found sporadic strange measurement values coming from my WEM3080T. See the following chart.
The ImportEnergy_SUM drops from ~5kWh to ~2kWH, strange, the import energy should not drop (without a reset) at all.
The Voltage drop from ~230V to ~0V and at the same time the Current raises from ~0A to ~230V.
This looks like the values of current and voltage are exchanged.
So i analysed further and recorded the raw word values of all Modbus TCP registers 0-55 and found that when this sporadic bug happens, all register values are shifted one register up. So the value of register 0 is now in the register 1 and so on. See the following table.
Register | normal value | strange value |
---|---|---|
0 | 23324 | - |
1 | 28 | 23314 |
2 | 0 | 28 |
3 | 28 | 0 |
4 | 11 | 28 |
5 | 785 | 11 |
6 | 0 | 785 |
7 | 0 | 0 |
8 | 438 | 0 |
9 | 2 | 441 |
10 | 23326 | 2 |
11 | 164 | 23316 |
12 | 0 | 164 |
13 | 352 | 0 |
14 | 18 | 354 |
15 | 13579 | 18 |
16 | 9 | 13579 |
17 | 38165 | 9 |
18 | 920 | 38165 |
19 | 0 | 920 |
20 | 23393 | 0 |
21 | 21 | 23384 |
22 | 0 | 21 |
23 | 42 | 0 |
24 | 9 | 42 |
25 | 33441 | 9 |
26 | 0 | 33441 |
27 | 0 | 0 |
28 | 866 | 0 |
29 | 0 | 862 |
30 | 5001 | 0 |
31 | 0 | 5001 |
32 | 0 | 0 |
33 | 423 | 0 |
34 | 36 | 424 |
35 | 52014 | 36 |
36 | 7 | 52017 |
37 | 44138 | 7 |
38 | 0 | 44138 |
39 | 0 | 0 |
40 | 0 | 0 |
41 | 0 | 0 |
42 | 0 | 0 |
43 | 0 | 0 |
44 | 0 | 0 |
45 | 0 | 0 |
46 | 0 | 0 |
47 | 0 | 0 |
48 | 0 | 0 |
49 | 0 | 0 |
50 | 0 | 0 |
51 | 0 | 0 |
52 | 0 | 0 |
53 | 0 | 0 |
54 | 0 | 0 |
55 | 0 | 0 |
The sporadic bug is very short and after that the values are in the correct registers again.
I updated my WEM3080T to the current firmware i.76.058.8.bin to see if the bug is already fixed. But i noticed that the bug is still present.
I found a workaround for myself. I used the HTTP Request API in combination with the HACS component https://github.com/lewei50/ha_iammeter.
I would like to share my findings with you and hope you can find the root cause for the issue.
Thanks for your sharing,
Please let me know ,when do you first find this issue.
We happen to upgrade the modbus hacs several days before, I think this issue may be caused by the latest upgrading.
we will check it soon.
please try to request the modbus/tcp from the YAML ,like this
https://imeter.club/topic/713#content3836
and check whether this issue would occur again.
Of course ,we would also check the issue of modbus HACS from ourside.
Hello,
1. Did you use the manual register setting method in configuration.yaml (instead of the hacs->IamMeter-modbus mode)
2. Is the data in your list exported from homeassistant?
Hello, i first found the issue ~2 weeks ago.
I am using the HomeAssistant Modbus Integration, i am not using the ha_iammeter_modbus HACS.
You can add another ha_iammeter_modbus for comparison, or install a new homeassistant and use HomeAssistant Modbus Integration for comparison. I encountered similar problems when using HomeAssistant Modbus Integration a long time ago, especially when adding multiple modbus hubs.
I have changed my YAML Modbus Configuration to the Configuration from https://imeter.club/topic/713#content3836.
This configuration only contains the Power measurements from the three phases.
I will observe if the issue is present with this configuration as well.
1. Yes i use the manual configuration via YAML for the HA Modbus Integration.
2. The data comes from HomeAssistant. The values are readings from home assistant, not real exports.
It seams to me that the issue is also present with the configuration i should use from https://imeter.club/topic/713#content3836.
I compared the measurement values from Modbus TCP and HTTP and exported the measurements. How can i upload you a history.csv file?
You can send the .csv data to support@devicebit.com. Earlier today, I exported the data from my hacs integrated ha_iammeter_modbus and checked it. There was no data confusion.
I send you a history.csv export with measurements and also my YAML configuration file i use with the Modbus HA integration.
I also installed the HACS
ha_iammeter_modbus integration.
I will observe if the issue is present again and if it only happens with the Modbus HA integration.
OK
ha_iammeter_modbus integration. I will observe if the issue is present again and if it only happens with the Modbus HA integration.
Hi Tim,
Have you used this Modbus interface recently, say within the last 2-3 weeks, or was it a long time ago?
I’d like to know if this issue occurred when you first started requesting data from Modbus in Home Assistant (HA), or if it had been running normally for a long time and only became abnormal in the last 2-3 weeks.
Hello, I put the yaml configuration you sent into my homeassistant and the interval for getting data is 15 seconds, while the data in the csv you sent is 5 seconds. In addition to the yaml configuration you sent, have you set any other parameters?
ha_iammeter_modbus integration. I will observe if the issue is present again and if it only happens with the Modbus HA integration.
I am using the Modbus interface of the WEM3080T for ~1 year with the HomeAssistant Modbus Integration and it worked fine for a long time.
But some weeks ago (2-4 weeks) i first noticed the issue. The issue was not present before, i could verify this by the energy charts of HA.
The issue did not occure when i first started requesting data from the WEM3080T via Modbus from HA.
In my YAML configuration the default scan_interval of 15s is used, cause i did not specify it.
The history.csv measurement data was generated using the configuration from https://imeter.club/topic/713#content3836.
In this configuration the scan_interval is changed to 5s. If you want to i can also export another history.csv with my configuration, if the issue occures again.
Also, the entity names in your yaml configuration file do not correspond to the names in the csv file one to one, so I am not sure whether the entity configurations in your csv data correspond to the yaml. Also, are there multiple names in your homeassistant: hub1?
I see. You still have the problem after using this configuration. I wonder if you can install another homeassistant and use the same configuration to read the data to see if the problem still exists.
I have sent you another export history2.csv via mail.
You can find the values ImportEnergySum, ExportEnergySum, VoltageL2/B, CurrentL2/B from all three interfaces i use at the moment.
* HomeAssistant Modbus Integration with the YAML configuration i sent you
* HACS IAMMeter Http
* HACS IAMMeter Modbus
I just analyzed your data. From the data, we can see that the data obtained from HACS IAMMeter Modbus is normal, but the data obtained from 'HomeAssistant Modbus Integration with the YAML configuration' is problematic. This can determine that the modbustcp data source of the electricity meter is normal, and the problem is in HomeAssistant Modbus Integration. You can try to delete all custom configurations and only keep sensor.voltage_l2 to see if there is still a problem. If the problem is solved, then there is a problem with your yaml configuration. If there is still a problem, then there may be a problem with your ha, and you may need to go to the ha forum to seek official help.
VoltageL2/B, CurrentL2/B from all three interfaces i use at the
moment.
* HomeAssistant Modbus Integration with the YAML configuration i
sent you
* HACS IAMMeter Http
* HACS IAMMeter Modbus