Energy Usage chart has gaps and export activity

I have recently installed Home Assistant on a raspberry pi 4 and have got almost everything working (thank you docs) with the better part of the house automated - still waiting on a few bits to automate the rest.

However, I do not understand why my energy usage charts have gaps and minus (export) activity.

I do not have any devices capable of exporting electricity to the grid so export is just impossible and must be due to some bug/error/misconfiguration. The export usage shows on the second chart regardless of whether there is a gap on the first (see above).

The household is on an electricity-only tariff (no gas) and we are tracking just electricity usage.

This is the data from the entity used by the energy charts to track kWh usage throughout the day.

I thought maybe this was related to the entity zeroing out every day around midnight so I tried to create a config change:

template:
  - sensor:
      - name: "Cumulative Energy Usage"
        unit_of_measurement: "kWh"
        device_class: energy
        state_class: total_increasing
        state: >
          {{ states('sensor.x') | float(0) + states('sensor.x') | float(0) }}

(removed entity id for privacy)

Unfortunately the new entity is still resetting every day. I’m not really sure whether this is even causing the issue and I really do not want to mess up my HA setup so figured it would be worth an ask here.

Any ideas or suggestions?

Note that since I am a new user I cannot put multiple embeds into my message so I will try post this as a reply.

Core: 2024.10.4
Supervisor: 2024.11.2
OS: 13.2
Frontend: 20241002.4

This is the same timeframe as the image in the original post.

This is the entity history used by the energy charts to track kWh (before I switched to the custom config, as mentioned in the original post). Note that the custom entity looks pretty much the same as this.

The resetting comes from the integration. You need an Utility Meter for that sensor.

Yes, it comes from the integration but I’m not sure what your suggestion was?

The utility meter reports the values via the integration. I have a SMETS meter in the UK and am using the Bright (Hildebrand) integration.

I thought maybe this was related to the entity zeroing out every day around midnight

This is normal and you don’t need to work around it. Entities are perfectly able to reset daily and still work for energy dashboard.

If you have gaps, it’s likely because your sensor is not updating fast enough. If there is no measured increase in energy between 1-2am, it will have a blank space on the graph.

Yeah sorry, you are right. I looked at the devices and misread the negative spikes.
The negative spikes in the individual device graph are caused, because your devices use energy, but there is no grid consuption measured so the algorithm zeroes it out.

I ended up setting up a new entity which had more timely updates and the problem seems to be resolved.

The issue is that the entity it was using lagged behind actual usage. i.e if it showed 10 kWh, this was actually the reading from an hour or two ago - since the integration only updates so often.

I’m using a more or less real-time entity now which tracks kWh usage throughout the day.

Hope this helps someone in the future.