Home Assistant Energy Distribution Card Weirdness

24 comments started 2026-06-07 last 2026-06-08
Home AutomationHome Assistant
S
#1 sponev

I've been using the Energy Distribution Card which comes with Home Assistant to good effect for the last couple of months. However today the battery charge/discharge values went haywire and jumped to an unfeasibly high value. I use the Battery Charge Total and Battery Discharge Totals from GivTCP in this particular energy card.

I tried restarting GivTCP but no joy, the incorrect values for today are still present - previous days are fine.

I Googled and I found references to discussion including users here from a year or so back, but no obvious resolution. I think GCoan was actively involved plus others.

Just wondering if anyone else is seeing this and what the fix is please? I assume that it's also buggered up the stats database? Also, is there an good alternative to the native energy flow card I can use which is more reliable please, or are we saying that the core sensor is buggered.

Thanks for your help and go easy please as I'm only a couple of months into HA - it was all going so well until today. The problem may well have coincided with an Octopus integration and/or core HA update but not certain. Thanks.

R
#2 Rubikcube

sponev unfeasibly high value

As in about double? Probably didn't reset at midnight.

R
#3 Robgy

sponev The only time I've ever noticed home assistant data issues is if I have updated HA just before midnight and it hasn't finished starting until just after midnight.

S
#4 sponev

Rubikcube no, just over 6.5Mwh! I also just noticed that for a good while previously, the energy input to the battery has been showing zero. All seems to have stabilised again after I restarted GivTCP.

It's very odd but fortunately only affecting the data for the battery charging, the key items e.g. solar generation and grid import and export are unaffected. It's as of the battery momentarily started to read all time totals rather than day totals.

Any ideaa on what caused it appreciated plus how to amend the data back to something sensible - is the data in the db accessible please?

S
#5 sponev

Robgy I did update yesterday but not over midnight, could be associated I guess.

P
#6 Pete UK

sponev

I’ve had this. Not sure why either. It was just the battery as well. 16th May and also on the 1st June.
Also I’ve had half the battery input showing for a good week or so, then it went back to normal.

Could be something to do with restarting (I did a lot of that whilst adding automations/ helpers/ updates etc. but can’t remember exactly.

You getting something like this?

P
#7 Pete UK

Also, on what’s left of the GivEnergy web dashboard I noticed that my “Discharge Today” and “Charge Total” seem to be reversed. Wasn’t always like that but it has been for a good month or so.

Saying that, the odd battery numbers on HA only occured on a few days. So far. And seem normal recently.


P
#8 Pete UK

sponev the energy input to the battery has been showing zero

Yep. I had this showing as “half” of what it should be - for about a week or so. Half, as in, it appeared to only be reading one of my inverters battery energy input sensors. I’d given up, as everything was set correctly but After about a week it fixed itself !
Again, no idea why or how/what the fix is. Can’t help more than that, only to say you’re not alone.

S
#9 sponev

Pete UK Well at least good to see I'm not alone. I've just done a bit more research in the statistics menu and can see that the battery charge total stopped incrementing around 22nd May. This correlates with the battery input showing zero which I didn't spot for a good while as it not usually something I monitor closely. Then yesterday, just after I updated Octopus and core HA, the total shot up to around 6.5Mwh and stuck there before I reset GivTCP. After the reset it dropped to zero and is now incrementing again as expected.

I'm still a bit confused about which item to use - for battery charge and discharge there are "today" values and "total" values - intuitively you would expect to use the "today" values but I read somewhere to use the "total" values as this prevents weirdness with usage graphs where the previous days total gets pulled into the data between midnight and 1am the following day.

Which values should be used please and what should reset when? I'm not clear as to why the battery charge total was incrementing, got stuck a few weeks back, then shot up before falling back to zero and starting again - this happened after a GivTCP reset. Weird and frustrating but hopefully I'll learn something!

T
#10 TX200

Total values are recommended with givTCP V3 rather than daily.
But it's best to wrap the total in a custom helper and have that helper reset at midnight.
Sometimes funny things happen around resets of daily values from GivTCP and HA resets if one doesn't happen right on midnight.

Speak to the geek did a video on YouTube about the helper setup I think.

P
#11 Pete UK

sponev

Should be “Totals”.
I’m not sure I am the best person to ask, only implemented my HA Green about 5 or 6 weeks ago. So I’m still learning but I think I’ve achieved a fair bit so far. Setting up an additional sensor as suggested above seems like a better idea.

FWIW, I’ve got these setting for the HA Energy dashboard;



P
#12 Pete UK

@sponev

And then within that I’m using 2 sensors like this;

S
#13 sponev

TX200 many thanks, yes I recall that so I'll revisit the STTG video.

S
#14 sponev

Pete UK Exactly like mine and it's been solid for the last couple of months. Looks like you're on the same learning schedule as me, I'm a couple of months in and I started in pre-emption of the GIv demise.

That helper plus a reset is the way to go I reckon so I'll be revisiting that. This is the first glitch I've seen to be fair. Thanks for confirming it's not me going potty!

#15 hoggy

I don't think some of the registers are big enough (I know the battery throughput one isn't as it uses just a single one) - such that, just like an old Ford Escort, the clock rolls round back to 0 'miles' and if so I suspect that home assistant doesn't really like that.
I know mines gone around the clock several times now however I think that's just the battery one as I'm 99% certain the other totals use two so can hold larger values without rolling over.

S
#16 sponev

hoggy useful to know, thanks. Does the "total" register reset at midnight please? Previously it just seemed to be incrementing but then "stuck" for several days before shooting up to several mwh - this then reset to zero and started incrementing again after I restarted GivTCP.

#17 hoggy

sponev the daily ones reset at midnight obviously but not the 'total' ones - they just increment endlessly. I'm not sure if the rollover would appear like you describe but then again I don't use GivTCP so maybe its the data smoother / error handler not really knowing what to do about it.

I don't even know if that is what's causing your problem to be honest, I just know that it's a quirk/flaw on some of the energy registers.

S
#18 sponev

hoggy OK thanks. I'll keep an eye on it and all steady since the reset.

#19 Maxwell

Not seeing any issues with the daily battery charge/discharge totals.

The bar chart shows the daily totals from "Battery_Charge_Energy_Today_kWh" & ""Battery_Discharge_Energy_Today_kWh"

You can compare today's values from the chart against what the portal shows


Although, i can see a slight difference in the daily totals if i work those out from the running totals for battery charge and discharge. But, no real pattern.

I am not using HA. But the data comes from givtcp, is stored in influx (via mqtt/telegraf) and i use grafana to generate the graphs. The calculated daily totals come from this grafana query. There is a similar one for discharge total.

SELECT difference(last("e_battery_charge_total")) FROM "raw_data" WHERE $timeFilter GROUP BY time(1d) fill(null)

S
#20 sponev

Maxwell reminds me of my old MySQL days!

Thanks but I think I know what the issue is. I'd failed to create the utility helpers correctly and corruption was happening at restarts and also at or close to midnight. I've since recreated them with daily resets and just waiting for all of them to populate before I re-include them. Unfortunately it does mean my graphs from the last 5 weeks or so are essentially borked but hopefully this will fix it moving forwards.

#21 Maxwell

@sponev Well looks like we have

SELECT ask("sqlquestions") FROM "spoonev" WHERE $timeisurgent GROUP BY time(60s) fill(null). 😉. (I’m sure those sql folks will be cringing as they read)

S
#22 sponev

Maxwell No... stop 😭

One the plus side, it all behaved properly at midnight and everything looks good this morning. If I can be ar$ed I'll have a dig into the last 5 weeks data using other methods to see if I can sanitise it.

S
#23 Stu131

The statistics sometimes get muddled up in Home-assistant for various reasons. In your case it looks like an erroneous Battery reading. This can be easily rectified following these instructions:

  1. Go into home-assistant Settings.
  2. Go into Developer tools
  3. Click on the header Statistics.
  4. Type Battery in search bar and press enter
  5. Click on the (Adjust sum) icon at the end of Battery Charge energy total
  6. Click on Outliers and search for ( in Your Case ) 502.9 kWh
  7. Click on the line with 502.9 kWh and enter 0 for the new value then click adjust.
  8. Now check your graph and figures for that period and it should be a more plausible reading.
S
#24 sponev

Stu131 that's very useful, thank you.