Hi community,
this is my first post, so please be gentle if something is off
I have a home assistance instance (Docker container) running and measuring energy usage across my home with different measurement devices, such as a couple of Shelly and some socket type (Gosund EP2) with ESP8266, that have Tasmota flashed on them and send their data using MQTT.
For quite a while now, there is a strange behaviour that occures sporadically and is only visible in my energy dashboard. Sometimes there seems to be negative power usage values, that leads to having the graph scale displaying a negative range (such as would be expected, when you would feed in power from solar panels). But I do not have any power generating elöectronics in my home, yet.
I tried to debug this issue and it seems to have something to do with how JSON conversion of decimal data is handled inside home assistant.
Tasmota is sending sensor data like:
{"Time":"2024-12-15T13:18:00","ENERGY":{"TotalStartTime":"2024-11-03T16:36:21","Total":3.691,"Yesterday":0.106,"Today":0.006,"Period":0,"Power":20,"ApparentPower":28,"ReactivePower":19,"Factor":0.72,"Voltage":225,"Current":0.123}}
So every energy value is a JSON number type with “.” as the separator (JSON itself does not support a native floating point type).
When viewing the websocket communication for the energy dashboard, I can see that the negative values are quite small:
"sensor.ghomeep2a_01_energy_total": [
{
"start": 1733958000000,
"end": 1733961600000,
"change": -0.00099999999999988987
},
So my guess is, that at some conditions the JSON parsing does interpret the incoming data differently. I also stumbled across this behaviour, when trying to pretty-print the JSON message with Notepad++ (JsonTools plugin). This is doing similar “mistakes”. This is the message from above, pretty-printed:
{
"Time": "2024-12-15T13:15:30",
"ENERGY": {
"TotalStartTime": "2024-11-03T16:36:21",
"Total": 3.6909999999999998,
"Yesterday": 0.106,
"Today": 0.0060000000000000001,
"Period": 0,
"Power": 20,
"ApparentPower": 28,
"ReactivePower": 20,
"Factor": 0.70999999999999996,
"Voltage": 225,
"Current": 0.125
}
}
Maybe some of you have a clue on how to get this fixed. Maybe I should raise a issue?
Thanks,
StyleTec