Monthly average to date. How?

I’m trying my best to calculate the average monthly price from Nordpool (or Tibber). Some mention the Utility Meter, but I can’t see how an increasing value shows a middle value without further templates. The MinMax and Statistic doesn’t cycle monthly. There is an Average Sensor available through HACS, but that doesn’t reset monthly either. I’m sure there is a way, but I’m lost. Can someone please share a complete write-up to find the average price from beginning of the month till the current date?

The entity is: sensor.electricity_price_average_day which updates daily.

2 Likes

Did you figure out how to do this?

i would also be interested in this if someone could help?

I’ve just set this up using this Average sensor
Set it up 1 hour ago so I can’t say for sure if it works the way I want, but it looks promising.

I have it set up like this:

- platform: average
  name: Spotpris månedssnitt
  start: "{{ now().replace(day=1).replace(hour=0).replace(minute=0).replace(second=0) }}"
  end: "{{ now() }}"
  entities:
    - sensor.spotpris

So the period to calculate the average over starts at current year, current month, but day=1

Will try to update this post next month when I know if it reset properly

1 Like

The History Stats integration uses data from the database which has a retention period of 10 days by default (data older than 10 days is discarded). It’s possible to increase the retention period to a month but it means the database’s overall size will triple.

I imagine the Average integration behaves the same way and gets its data from the database.

I use MariaDB and have 400 days with history. History shouldn’t be a problem. But I use HA build in statistic to get average data for the cost from nordpool. But having an average inside an entity would help calculating how much it cost after compensation.

Did this work as intended?
Have the use of something adjacent to this so am curious :slight_smile:

I have a sensor that calculates my “real” daily average price and displays that on my dashboard together with the average price supplied by Tibber.

I do this mostly to evaluate if my switch to hourly rate is something we save money on or not,
But I would like to have the same thing for monthly average.

did you figure out how to do that? and how do you calculate the “real” daily average?

“real” daily average does work as intended, see my code:

      - unique_id: tibber_actual_avg
        state: >
          {{ (states('sensor.accumulated_cost_my_house') | float / states('sensor.accumulated_consumption_my_house') | float) | round(2) }}
        attributes:
          friendly_name: Real avg
          icon: mdi:currency-usd

Its basically taking my running cost and divide it by running consumption.

In regards to the monthly part I got in contact with Tibber who said that the monthly average cost is not part of there API at the moment but thought it was a good suggestion and would look in to it.