How can I reset energy meters each day, please?

I’ve been running HA for a couple of years, but I’m very much a hardware person and will freely admit to struggling when it comes to writing/adapting code.

I’ve knocked together a box that contains five energy meters (Owen Brothers OB115). I have these set up through a Modbus adapter connected to an ESP32 and the hardware is working fine, I can read the individual meter registers OK and have HA displaying the data with no problems at all.

The issue I have is that these meters continuously increment energy data, and I’d like to be able to break out just the energy used per day, from midnight one day to midnight the next. The idea is to be able to display the energy each circuit in the house has used each day, so I can get an “at a glance” indication as to whether any particular circuit is using more or less than normal, keep track of heating and hot water daily energy use, etc.

I’m at a loss as to how best to do this. I gather I need to set up something that, at midnight, resets a counter to zero, then increments it through the day in an entity that I can use to display the energy used during that day. There’s no way to reset the hardware, as its registers are locked down and read-only.

In essence it seems a fairly simple thing, but I’ve spent a couple of days on it and cannot for the life of me see how to do this. I think that what I need is some form of register within HA that can increment every time an entity value increments and then reset at midnight ready for the next day’s data. Seems a simple thing to do in hardware, set up a counter that increments through each day, then resets at midnight, but it seems a lot harder than that as code.

As an example, I have a variable titled “sensor.services_area_hot_water_energy”. That is just the contents of a Modbus register, and increments every 5 seconds with the latest value from the meter. It cannot be reset, so what I’m looking for is something that stores the value at midnight each day, then only records incremental changes for the following 24 hours. i.e each day the data starts at at zero, with it updating every time the meter register changes to hold “current register reading” minus “previous day’s midnight register reading”.

If anyone has any advice it would be most welcome, but please bear in mind that I’m a bit of a numpty when it comes to coding, I know just enough to be dangerous!

Just add a utility meter entity. You can create one in the helper section, no coding required. You can specify if you want dayly, weekly, monthly or yearly reset.

Very many thanks, that’s worked a treat!

Had a slight problem with an error I made (finger trouble) and then found I couldn’t remove the helper to start again. No idea why - seems there’s no option to do this - others seem to have the same issue which is reassuring as at least I know it most probably wasn’t my fault.

I set up another helper (correctly) and it seems fine. It reset at midnight last night and is showing the energy used since then accurately, so all’s well.

Thanks again for your help, it’s much appreciated.

You need to go in the settings of the helper (cog icon) and there you will find the remove button in the bottom left.