Energy - How to account for daily standing charge?

Hi All,
I had a go at a kludge for this. It seems to be working well so I thought I’d share.

I basically created a sensor that uses 0.001kW per hour. Then I take the daily supply charge, multiply by 1000 and divide by 24. This give me an hourly static price I can use to multiply by the sensor to get an hourly supply charge.
So in detail the sensor looks like this.

    - name: "Supply Charge"
      unit_of_measurement: "kWh"
      device_class: energy
      state_class: total_increasing
      state: >-
       {{ (((as_timestamp(states('sensor.date_time_iso')) / 3600)-454585) | int) / 1000}}
      attributes:         
        last_reset: '1970-01-01T00:00:00+00:00'

The formula for the sensor is basically the date & time in hours
(as_timestamp(states('sensor.date_time_iso')) / 3600)
minus an offset of hours since 1 Jan 1970 00:00.(Unix Epoch) In my case this was 454585 but it will be different depending on the time you start the sensor.
I take the integer and divide this by 1000 to get the smallest possible unit (1Wh). So this sensor now increments by 1Wh every hour forever. This will get added to your hourly grid consumption but this value should be negligible and well within the margin of error of most measuring devices.
Once I created the sensor I added it to the energy config screen under Grid Consumption as below
image

Note: The static price used is 1000 times the actual price for 1 hour supply.
In my case I pay 105.1400 cents per day supply charge, so when I adjust this to an hourly static price I get 1.051400 *1000/24 = 43.81 (you can only use 2 decimal places in the config price)

It’s not perfect but I hope it works for others.
PS. You could easily use this same approach for a “daily” sensor but I wanted to spread the cost across hours in the day so I can compare it to another system I have that does something similar.

7 Likes