CJNE / ha-sunspec

Home Assistant customcomponent for SunSpec modbus devices
MIT License
63 stars 14 forks source link

`ac_meter Total Watt-hours Exported` sign issue #249

Open DooMMasteR opened 7 months ago

DooMMasteR commented 7 months ago

Version of the custom_component

0.025

Configuration

image

Describe the bug

ac_meter Total Watt-hours Exported is a huge value, slowly lowering whenever electricity is exported image

dp2008 commented 6 months ago

Have the same problem with Kostal Smart Energy Meter there seems to be a fix for openHAB but nothing for HA: https://community.openhab.org/t/solved-wrong-values-with-modbus-and-kostal-smart-energy-meter/99785

see last comment form Oct 2022: the Kostal SEM reports Exported Real Energy as signed int32 instead of unsigned int32, which makes it report bad values. Same happens in Home Assistant and with the official Sunspec verification tools.

DooMMasteR commented 6 months ago

Yeah I already tried to get KOSTAL to fix the issue in firmware, but they are super shitty at supporting their products.

guidoffm commented 1 month ago

I have the same problem with the Kostal meter. I found a workaround, until a compliant firmware is available: You can install the Node Red add-on. Then, you can read out one of the wrongly interpreted values, convert it to the correct value, and then send the corrected value to a new virtual sensor in Node Red.

The conversion function is quite simple:

function convert(v){
    return -(v << 0);
}

The << operator converts the uint32 to int32, and the - sign makes the value positive again.