gndean/home-assistant-hypervolt-charger

Sensor provides negative value when reset (HA Energy Dashboard)

Closed this issue ยท 14 comments

Firstly thank you so much for this integration.

The "Hypervolt Session Energy" sensor resets to zero when the charger starts a new session, this results in home assistant measuring a negative energy consumption in the energy dashboard (last session value is carried forward until the next session starts when its zerod again)

image

Potential fix i think would be amending the session sensor.hypervolt_ct_power to a cumulative statistic allowing home assistant to pick it up as an energy reading. Ill give it a shot tomorrow and see if i get time.

Same for me:

image

I attempted to amend the sensor config but just ended up breaking it (im not new to HA just terrible at it :D)
Its done the same thing again tonight though so now my "month" (2 days) of charging is...
image
wish it was so little ๐Ÿคฃ

edit ignore the insane AC numbers i broke that at the same time as the hypervolt sensor, was copy pasting configs between the two and accidently x100 the AC numbers lol

Interesting. It is by design that the Hypervolt Session Energy resets for each session - this is to match the behaviour of the mobile app.
When summing the energy used, there may be a solution to your issue... The sensor currently has the state class of "Total" which I think is why the resets decrease the total sum of energy used. There is an alternative state class of "Total Increasing" which maybe this sensor should be declared as, so that the resets don't decrease the totals: https://developers.home-assistant.io/blog/2021/08/16/state_class_total/

I'll have a look into this and a play around.

I've added a new sensor Hypervolt Session Energy Total Increasing to V1.0.3 with the Total Increasing class mentioned above. However, I don't think it's going to work, because of the warning from the Home Assistant page about that:

It is important that the integration ensures that the value cannot erroneously decrease in the case of calculating a value from a sensor with measurement noise present.

I do see the Session Energy decrease, just before the session is stopped e.g.:

image

Each one of the marked points counts as a reset and HA ends up counting approximately double the actual energy used. I think I've confirmed this by seeing double the expected value in my energy monitor within HA.

I will probably drop the Hypervolt Session Energy Total Increasing sensor from the next release, unless you think it has value? But I think a different approach is required.

Maybe I could only update the value of Hypervolt Session Energy Total Increasing only when:

  1. the session ID changes
  2. charging stops

and not during the middle of charging session.

In the first case, the value would reset down to 0, or close to 0.
In the second case, the value would be that of the end of the session and would get summed by HA
๐Ÿค”

Maybe I could only update the value of Hypervolt Session Energy Total Increasing only when:

  1. the session ID changes
  2. charging stops

and not during the middle of charging session.

In the first case, the value would reset down to 0, or close to 0. In the second case, the value would be that of the end of the session and would get summed by HA ๐Ÿค”

Yeah I hit the stumbling block, I think the best option is to use the summeration ie the season ct energy and use it as a total increasing, I tried this editing the sensor.py but it broke completely and I had to delete the integration, this is probably my lack of understanding more than anything. A massive thank you for building and supporting this!

Cheers

Exa

Trouble with that is, the CT Energy measures everything that passes through the CT clamp which, depending on your installation, is likely to be all your household loads too, not just the Hypervolt.

Oh I did not know that, my CT clamp is inside the charger chassis, I then have another one externally that is for load balancing. Might try unplugging the external clamp and see ๐Ÿ‘

Kahn commented

I solved this for my energy dashboard with a utility meter that resets daily and is incremented by the session_energy. In my install the CT power is zero, which has been the whole drive for getting HA talking to the Hypervolt.

sensor.hypervolt_session_energy
Status
collecting
Last period
3943
Meter period
daily
Cron pattern
0 0 * * *

OK, V1.0.4 contains some updated logic for the sensor: Hypervolt Session Energy Total Increasing:

  • While charging, Hypervolt Session Energy Total Increasing takes on the maximum value seen from Hypervolt Session Energy. By using the maximum, it never drops causing an erroneous reset
  • When a new charging session is seen (detected by a new Session ID), Hypervolt Session Energy Total Increasing resets to 0

I'm going to give it a try and see what happens.

OK, V1.0.4 contains some updated logic for the sensor: Hypervolt Session Energy Total Increasing:

  • While charging, Hypervolt Session Energy Total Increasing takes on the maximum value seen from Hypervolt Session Energy. By using the maximum, it never drops causing an erroneous reset
  • When a new charging session is seen (detected by a new Session ID), Hypervolt Session Energy Total Increasing resets to 0

I'm going to give it a try and see what happens.

Updated shall test overnight, thanks again!

Appears to have worked for last night.

Here are the results, for both sensors on mobile sorry.

Screenshot_20221221-083646
Screenshot_20221221-083652

@exalyte is this still working for you? If so, we can close the issue and I'll add some notes on the new sensor to the next release's readme.

@exalyte is this still working for you? If so, we can close the issue and I'll add some notes on the new sensor to the next release's readme.

Sorry got busy yes few days in and the sensor it holding steady.
Thank you again for the hard work

Closed.