Skip to content

Help with calculate average price #290

Description

@Manhem

This is not a issue.
I wonder if there is anyone who can help me with a formula.
I would like to get the average price over, let's say, one month from the values from Nordpool.
Is here anyone that has done this and are willing to share this with me?

Activity

  1. t0xa commented on Feb 11, 2023

    @t0xa

    Hello,

    1. Install "Average" sensor - https://github.com/Limych/ha-average
    2. Open configuration.yaml in the "File Editor" Add-on and add following sensor
    sensor:
      - platform: average
        name: 'Average Nordpool Price'
        end: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
        duration:
          days: 30
        entities:
          - sensor.nordpool
    
    1. Restart Home Assistant.
    2. Add relevant widget on Dashboard

    Please note that sensor doesn't work retrospectively and it needs to aggregate data for 30 days to show actual value.

  2. Manhem commented on Feb 12, 2023

    @Manhem
    Author

    Thanks.
    I'm going to try this.

  3. t0xa commented on Feb 12, 2023

    @t0xa

    No problem. Could you please close the issue and reopen if you have any further issues.
    Thanks

  4. Henrik1986 commented on Feb 13, 2023

    @Henrik1986

    Is it possible to get the avg for the current month and week. For example feb, mar, apr etc... Would be great if this value was stored in nordpool sensor.

    • avg_last_month ( for today feb)
    • avg_last_week (for today week 7)
  5. t0xa commented on Feb 13, 2023

    @t0xa

    Hello @Henrik1986

    What would be your use case for the averages in context of Home Assistant? There are multiple ways to achieve this and it depends on use case.

  6. Henrik1986 commented on Feb 13, 2023

    @Henrik1986

    I don't pay hourly for my kWh, I pay for an average for the month + fees.
    Would like to calculate the monthly and weekly cost of electricity based on the average value from nordpool. Therefore it would be nice to have avg_last_month and avg_last week as attribute.

  7. t0xa commented on Feb 14, 2023

    @t0xa

    Option 1: Use "Average Sensor" component and create last week and last month sensors. You will need to increase data retention as it defaults to 10 days - https://www.home-assistant.io/integrations/recorder/#purge_keep_days.

    Option 2: Feed Nordpool data into InfluxDB and/or Grafana and then build necessary dashboards. In this option you will have the most flexibility.

  8. Henrik1986 commented on Feb 15, 2023

    @Henrik1986

    @t0xa

    Thanks for the options. Some questions to option 1. I can't see if its possible to choose the month. If I use start and end i should use timestamp. Will it work if i use this?

    start: {{ now().date().replace(day=now().day - now().day+1 ) }}
    end: {{ ((now().replace(day=1)+timedelta(days=32)).replace(day=1)-timedelta(days=1)).date() }}

    And is it possible to add the sensor to long term statistic? https://data.home-assistant.io/docs/statistics/

  9. locked and limited conversation to collaborators on Mar 27, 2023
  10. converted this issue into a discussion #307 on Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions