Create a sensor to tell me how much power (kWh) has been used since a date time

Hi,

In the Solomon Islands most rental properties use a pass in advance system for electricity. I have set the meter up so that I can monitor how much energy is being used, and works great.

I have set up a couple of helpers, 1 to tell HA how man kWh’s remain, and the other a datetime to tell when this was read.

Initially I was going to use the total energy value to work how much power I had remaining but it is reset every night.

So now my idea is to create a sensor which tells me how much I have used since the last time I read it. Minus this from the number of units remaining tells me how much I should have now.

However I am having problems working out how to create this sensor. I looked at the history_stats sensor but this will not do what I need.

Can anyone give me any ideas.
Thanks.
Gordon.

Create a utility meter. Feed it your energy sensor. Do not define a reset cycle.

It does not matter if the sensor you feed this utility meter resets. It will keep counting up.

You can subtract the value from this meter from your units remaining.

Use this script to reset the utility meter whenever you want (e.g. use it as a button tap action).

script:
  meter_reset:
    sequence:
      - service: utility_meter.calibrate
        target:
          entity_id: sensor.your_utility_meter_here
        data:
          value: 0
1 Like

@tom_l thanks for this, I have now been able to get it to track my remaining energy.

1 Like