odya / hass-ina219-ups-hat

Home Assistant UPS Hat integration. Waveshare and others based on INA219
MIT License
12 stars 3 forks source link

Inverted values reported for UPS HAT (D) #30

Open OndraM opened 2 months ago

OndraM commented 2 months ago

Hi, I have Waveshare UPS HAT (D) and I have installed the latest version of this integration (downloaded from the master branch) in HA.

Using the INA219.py script from Waveshare, I'm getting proper values for the UPS. However, with this integration, values for Current and Power have inverted value - when the device is charging, the Current value is below zero, and when it is running on battery, the Current is positive number.

And probably because of this inversion, I am also getting inverted state for the "charging" entity. And "Remaining Capacity" is always reported as 0. Value of Voltage is on the other hands reliable.

This is my config:

ina219_ups_hat:
    addr: 0x43
    sma_samples: 5
    name: Waveshare Raspberry UPS
    unique_id: raspberry_ups
    battery_capacity: 9000 # 2x4500 mAh

Is this behavior a bug? Let me know if I can provide some more debug data.

OndraM commented 2 months ago

It also seems the INA219.py for the D version uses some different values.

https://github.com/uvjim/rpi_waveshare_ups/blob/main/custom_components/rpi_waveshare_ups/ina219/INA219_D.py