Monthly average sensor

What is the easiest way to get a sensor that calculates the average value on a electricityprice-sensor? I have a sensor that updates once each hour.

I only want it to calculate “current month so far” so that I can get a rough estimate on how much my bill will be.

I dont really understand the statistics sensor, could it do this?

The hassio built in energy panel can do this already, fill in the detail configuration > energy.

Or you can have a look at utility meter
Utility Meter - Home Assistant (home-assistant.io)

No wonder I couldnt see the energy dash, I needed to manually add “energy:” to the yaml. The price seems to update well there, however I’m having trouble adding all my entities due to the “bug” even tho my entities have the device_class and measurement attribute they dont show up.

I cannot see how any of this could solve the problem.
The energy dashboard gives me the total cost for my consumption so far this month, fine.
But what we need is the average of the hourly price per unit

Not sure i understand you, the price is from your energy provider, you use that to put into HA and from your energy usage it calculates the cost, not the otherwayround

Fortunately I get the current invoice updated each day from my provider as a sensor in ha. So I took that value and divided it by my used kWh and got the current price per kwh so far of the current month.

I gave up on getting the “average price per day so far” every month but I’m sure it can be done for anyone who can code json better than me. One only needs to know the number of the current day of the month and divide the summed up invoice by that number

If you are just looking for (number of days pass so far).
Just add a counter entity and have an automation to count up daily.

- alias: Counter
  trigger:
    - platform: time
      at: '00:00'
  action:
    - service: counter.increment
      data:
        entity_id: counter.counter_helper

Nice, thats not even that much extra entities, I think I’ll use that