Energy: Solar productions shows negative value

I setup a system which monitors my PVS1 based SunPower Solar System. It sends every 5 minutes all available data via mqtt including the “Sunpower Energy Production Today” which I calculate based on the previous value. I always reset it after midnight to 0. I even make sure only values >0 get send to HA. The entity history looks correct to me and compared to my Envoy system it looks pretty much the same. But as you can see the energy production chart shows a negative value every night between 0-1am.

Any idea what I am doing wrong here?

approaching a black hole

Is the entity state_class: total? Looks like it is not resetting properly for statistics.

It should either be state_class: total_increasing, or it needs to update last_reset properly when it goes go 0.

Yes, correct. I use state_class: total … good catch! Let me try total_increasing!
Thanks a lot for the quick response!

Hi,
I seem to have a similar problem: Energy dashboard suddenly with negative value
My data comes from a HACS integration (GitHub - stanus74/home-assistant-saj-h2-modbus: Home Assistant Component to read SAJ H2 Inverter Modbus Data) and I don’t know how to set the state_class.
If I go to the related entity I have nothing to do this setting. Any ideas?

I tried changing the state_class of the entity as suggested from total to total_increasing.
I did this through the developer tools.
I save the new value, but when the variable is updated the state_class value is reset to ‘total’.

That’s not a valid way to change an entity.
Using customize: might work, I am not sure.
If all else fails you can make a new template entity based off that entity with the correct class.
Or file a bug on the HACS repo to let them know it is not setup correctly.

I confirm that state_class: total_increasing fixes my issue. Thanks again!