henricm / ha-ferroamp

Ferroamp MQTT Home Assistant sensors for EnergyHub, SSO, ESM and ESO
MIT License
38 stars 14 forks source link

EnergyHub DC Link Voltage state is zero #364

Closed bj00rn closed 1 year ago

bj00rn commented 1 year ago

Seems that the sensor state sums up to zero.

image

Is this really the correct way to represent DC voltage? I have no domain knowledge here whatsoever here, it just appears to me that the current state value seems useless, especially when trying to correlate DC link voltage history with SSO fault codes.

Nominal DC link voltage is 760V (720-780V) according to specs, which leaves 380+380 within that range..

image

From the looks of it would seem that a useful way of summing up dc link voltage would be something like self._attr_native_value = int(abs(neg) / count + pos / count). Again, i have no domain knowledge here so maybe im wrong.

offending line: https://github.com/henricm/ha-ferroamp/blob/56df5e9f542d0b4d9f843acd52ab5107cdcfd614/custom_components/ferroamp/sensor.py#L759

argoyle commented 1 year ago

No domain knowledge at my end either but I see how you're thinking. @danielolsson100 or @mickecamino perhaps knows more?

danielolsson100 commented 1 year ago

@argoyle I have no clue in this matter since I am not using this value at all, I don't even store the history data in the DB for this sensor ;)

jonasbkarlsson commented 1 year ago

It should be pos / count - neg / count.

Also, it shouldn't be int(). Would be better to use something like round(float(pos / count - neg / count), 2).

mickecamino commented 1 year ago

The value from Ferroamp is a float, so it should be a float in the code: SSO-MQTT

argoyle commented 1 year ago

It should be pos / count - neg / count.

Also, it shouldn't be int(). Would be better to use something like round(float(pos / count - neg / count), 2).

That would result in ~760 in the case @bj00rn had, right? Can someone provide a PR with those changes?

mickecamino commented 1 year ago

Hmmm, it seems that I looked at the wrong sensor, Here is the correct one: dclink-voltage

bj00rn commented 1 year ago

It should be pos / count - neg / count. Also, it shouldn't be int(). Would be better to use something like round(float(pos / count - neg / count), 2).

That would result in ~760 in the case @bj00rn had, right? Can someone provide a PR with those changes?

I can give it a shot

bj00rn commented 1 year ago

Works on my machine (TM) :-)

Screenshot_20230709-133043