Home Assistant: Nord Pool cheapest hours with AIO Energy Management

I’ve already done couple of iterations of finding Nord Pool cheapest hours every day using Home Assistant templated sensors and bunch of helpers and automations. It can really get complicated when using multiple sensors and copy-pasting the automations. Not to even mention about changes in the code for updates! But, the help is now here: I’ve done a huge revamp of the cheapest hours system and everything is now much easier to configure and maintain. Behold the AIO Energy Management integration!

But, before continuing let’s go back a bit.. During early summer I started finding a way for my solar energy to be used along with Nord Pool. Trying to decide when to use solar and when to use grid energy. Things got really out of hands and the automation came out as a mess. Then it hit me: I’ll write a Home Assistant custom component as an integration, so I can write everything with Python and re-use code without making tons of copy-pasting from an automation to another. The work is now done for the Nord Pool part, but solar management is still to be implemented. Now it’s a good time to make the first MVP release..

What is AIO Energy Management?

AIO Energy Management is a custom component for Home Assistant that currently supports finding cheapest or most expensive hours for energy using Nord Pool prices, so mostly targeted for nordic European people using Home Assistant! It’s meant to replace my old creation of cheapest hours and cheapest hours with calendar.

Why it’s called All-In-One Energy Management, if it’s just using Nord Pool you might ask? Well, this integration is planned to become a solution handling all my energy management needs including solar power and later also include other regions of electric stock market*. A long way to go for actually becoming AIO solution, but hopefully I’ll get there someday..

*Need to support for your regions electric stock market? Write an issue to my GitHub repository or write a comment below and lets see what can be done..

Setting up the integration

Definitely the best way to install AIO Energy Management is to use HACS. Using HACS will provide you automatic installation and providing updates. On updates your job is only to check for possibly breaking changes and press the update button.

To install using HACS either press ‘Open HACS repository on Home Assistant‘ -button below or manually setup the custom repository.

Automatic setup:

Manual Setup:

  • Go to `HACS` -> `Integrations`
  • Select `` from upper right corner
  • Select `Custom repositories`
  • Add `https://github.com/kotope/aio_energy_management` and select Category as `Integration`
  • Search for `AIO Energy Management` and select it
  • Press `Download`
  • Restart Home Assistant

Using Nord Pool cheapest hours binary sensor

The first released component of AIO Energy Management is the Nord Pool cheapest hours sensor. This sensor will provide a binary_sensor type that will turn ‘on’ when the cheapest hour is active and ‘off’ when not making it easy for automations to make proper device actions (see ‘automations’ section for more details).

To use the Nord Pool cheapest hours binary sensor, a Nord Pool integration must be installed and configured first. To do that, check installation instruction from the Nord Pool integration GitHub.

The cheapest hours configuration has all the same features as earlier version of the automation: finding number of hours from a specified time frame, getting the expensive hours and of course a failsafe functionality in case of data fetch failure.

All the configuration is done through configuration.yaml and no config flow is supported at the moment. The table shown below presents all the configuration parameters to make the cheapest hours sensor to suit best for your needs!

configurationmandatorydescription
nordpool_entityyesEntity id of the nord pool integration sensor. Look this from your nord pool integration!
unique_idyesUnique id of this entity
nameyesFriendly name of the sensor. Is the one shown on UI and marked on energy management calendar if in use.
number_of_hoursyesNumber of cheapest hours to seek. This can either be a number between 24-1 or dynamic entity_id. If entity_id is given, the value will be read from that entity when locking in the next cheapest hours sequences.
first_houryesStarting hour (0-23) (Leading zeros not allowed)
last_houryesEnding hour (0-23) (Leading zeros not allowed)
starting_todayyesTrue if the look up should be started on today. Note that if set to true, the starting hour must be after nord pool price publish (about 14.00 CET).
False if only tomorrow prices should be looked for.
sequentialyesTrue if required to find sequential cheapest hours. False if multiple slots are ok.
failsafe_starting_hournoFailsafe starting if nord pool price data can’t be received by external reason.
Setting for example to 22, the binary_sensor value will be set as ‘on’ at 22.00 if no electric prices are received by that time.
inversednoWant to find the most expensive hours? Set to true!
Configuration parameters of AIO Energy Management Nord Pool cheapest hours sensor

Ok, the parameters are now introduced.. here’s a full example that can be set into configuration.yaml. The following example has two sensors: one for cheapest and one for most expensive hours. Note that the example of expensive hours uses a helper input_number entity to get dynamic number of hours to seek.

aio_energy_management:
  cheapest_hours:
    - nordpool_entity: sensor.nordpool
      unique_id: my_cheapest_hours_sensor
      name: My Cheapest Hours
      first_hour: 21
      last_hour: 12
      starting_today: true
      number_of_hours: 3
      sequential: False
      failsafe_starting_hour: 22
    - nordpool_entity: sensor.nordpool
      unique_id: my_expensive_hours_sensor
      name: My Expensive Hours
      first_hour: 20
      last_hour: 16
      starting_today: true
      number_of_hours: 2
      sequential: False
      inversed: true

Once the configuration is in place, just restart your Home Assistant and enjoy the newly created sensor(s)! The sensors can be easily found from settings -> devices & services -> entity -tab. Just look for ‘AIO Energy Management‘ integration 🙂

AIO Energy Management Calendar

AIO Energy Management can create you a calendar to present all upcoming energy management events, like upcoming cheapest hours or expensive hours slot. The calendar is purely optional, but it can be used to trigger an automation as in with my old template/helper/automation based implementation.

To configure calendar to be used, just setup ‘calendar’ slot in the ‘aio_energy_management’ configuration section and add ‘unique_id’ and ‘name’ as parameters. Everything else is done automatically, just enable and restart Home Assistant!

Once restarted, go to Home Assistant -> Calendar and you should see a newly created calendar with the name you gave during configuration!

Example configuration below:

aio_energy_management:
    calendar:
      name: My Energy Management Calendar
      unique_id: my_energy_management_calendar

NOTE: Cheapest hours sensor failsafe is not marked on the calendar!

Automations

Then the most interesting one, how can I do the automations based on the cheapest hours? Well, it’s almost too easy with AIO Energy Management Cheapest Hours component: just set the automation to follow ‘on‘ and ‘off‘ states of the binary_sensor!

Here’s an example aution of using triggers ids to check for ‘on’ and ‘off’ states of the binary_sensor to toggle dummy input_boolean helper. This way everything can just use a single automation! Of course it’s possible to create one for ‘on‘ and one for ‘off‘ states, it’s up to you really which way you prefer, just follow the binary_sensor status 🙂

alias: Cheapest hours turn on switch
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.my_cheapest_hours
    from: "off"
    to: "on"
    id: turn_on
  - platform: state
    entity_id:
      - binary_sensor.my_cheapest_hours
    from: "on"
    to: "off"
    id: turn_off
condition: []
action:
  - if:
      - condition: trigger
        id:
          - turn_on
    then:
      - service: input_boolean.turn_on
        target:
          entity_id: input_boolean.test_toggle
    else:
      - service: input_boolean.turn_off
        target:
          entity_id: input_boolean.test_toggle
mode: single

Technical details of cheapest hours sensor

If you have no interest about internal and advanced functionality you can just skip this section. But if you want to make some more complicated automations on some specific occasions, you might find this information useful.

The logic of Nord Pool cheapest hours is quite simple: As soon as the Nord Pool data is received from Nord Pool sensor, the data is stored into Home Assistant. The sensor attributes described below might come handy:

Expiration: The data stored contains expiration time that will tell us when we are ready to get new Nord Pool data as we don’t want to make the decision if already on a cheapest hours. The expiration is set just after last_hour.

Updated_at: This value is being set as the time we got the data from Nord Pool. This attribute can be followed on an automation, if we want to trigger some actions when the cheapest hours list is ready.

Failsafe_active: This value will be set to true when we are running on failsafe. Failsafe will be run at given failsafe_starting_hour, if the data expiration has been passed and no new Nord Pool data has been received, Might be useful if we want to do something different when on failsafe..

Active_number_of_hours: this presents the actual value used to get amount of hours. Is either the same value as set on number_of_hours or received from entity if entity_id is used on configuration. This is updated right after data is received from the nord pool sensor and values are calculated! Entity value changes afrer calculations won’t change this!

List: Actual list data of cheapest hours! Might become useful if you want to export the cheapest hours to some external device itself rather than letting Home Assistant to control it.

What next…

Cheapest and expensive hours is now up and running with a failsafe support! However, the work continues. There’s a lot to be done for the cheapest hours implementation and especially with all the other features like solar energy calculations!

Here’s few things you might be seeing in very near future:

  • Trigger time.. if you want to wait for some other input before locking in the cheapest hours. Currently the cheapest hours slot is locked as soon as the energy prices are published by Nord Pool!
  • Multi state sensor. Want to avoid high prices and prioritise the low prices? A sensor with ‘low’, ‘normal’ and ‘high’ should do the trick
  • Use of solar forecast integration to make entries of the best solar hours!

And in a long run .. mixing up solar forecast and Nord Pool cheapest hours to get the best out of all!

Anything else? Need a support for another electric stock market or other new fancy feature? GitHub contributions are always welcome and please leave a comment below if you are looking for something specific!

Update: Want to use Entso-E instead of Nord Pool? It’s now available with AIO Energy Management 0.2.0


Did you find this guide helpful? You can keep the blog going by bidding me a coffee!

84 Replies to “Home Assistant: Nord Pool cheapest hours with AIO Energy Management”

    1. Hi!

      But you can see the correct calendar?
      Does your binary_sensor attributes contain ‘list’-attribute with values?

      You could also enable debug logging by adding following line(s) to the configuration.yaml to see what’s going on:
      logger:
      default: warning
      logs:
      custom_components.aio_energy_management: debug

      1. Hi!
        I do have the calendar (literally copy-pasted all your settings). I have the “My Energy Management” calendar and I also have one of your previous blog posts, the “electricity” calendar. I also have the “Cheapest hours energy” under the “electricity” calendar, not in “My Energy Management” calendar, which does not make sense to me but ok. In Settings > services > entities I have the My Cheapest Hours (binary_sensor.my_cheapest_hours) and the My Expensive Hours (binary_sensor.my_expensive_hours) BUT they have a mark of red circle and “not provided” status. Does this all make sense?

        Also, couldnt run debugger, said Failed to restart Home Assistant
        Invalid domain custom_components.aio_energy_management, but I just downloaded and reinstalled it, did everything from top to bottom in this blog post.

        Thank you for your effort in resolving it 🙂

        1. Hi!

          Just realised that maybe the guide is not 100% clear on the configuration part. calendar and cheapest_hours sensors need to both be in the same block under aio_energy_management and there should not be aio_energy_management component defined twice. Could this be the case on your issue?

          Here’s an example of the config I’m using myself.
          aio_energy_management:
          calendar:
          unique_id: energy_management_calendar
          name: Energy Management Calendar
          cheapest_hours:
          - nordpool_entity: sensor.nordpool_kwh_fi_eur_3_10_024
          unique_id: my_cheapest_hours
          name: My Cheapest Hours
          first_hour: 21
          last_hour: 12
          starting_today: true
          number_of_hours: 3
          sequential: false
          failsafe_starting_hour: 1
          - nordpool_entity: sensor.nordpool_kwh_fi_eur_3_10_024
          unique_id: my_expensive_hours
          name: Expensive Hours
          first_hour: 0
          last_hour: 22
          starting_today: false
          number_of_hours: 2
          sequential: false
          failsafe_starting_hour: 1
          inversed: true

          If you wish, you could send me your configuration.yaml to creatingsmarthome (at) gmail.com and I’ll have a look. 🙂

  1. Nice work! Im going to try out this one. Is there a possibility to add multiple time ranges in to on sensor? like 00-06 and 12-18 and seek one hour in both ranges?

    And does the upcoming 15min market effect on to this? Would love to see adjustable span to optimize heat pumps etc for enought long periods to heat up dhw ie.

    1. Yes it’s possible to add another time range of course, just add another entity into configuration like the expensive hours in the example.

      15min market is still quite far away, but of course when it’s released from Nord pool this will support it at the time. Would be a breaking change though 🙂

      1. Yeah I did it that way but all automation requires both entities now. Testing out it with DHW currently which only requires two cycles in a day.

        Does the automation fetch all hours after reciving new spot prices from Nord pool or before first hour?

        1. This integration (aio energy management) calculates all data as soon as Nord pool prices have been fetched.
          Only exception is if the last_hour is set after price publishing. In that case, the new prices will be calculated once last_hour has passed. Called “expiration” in attributes.

          I’m currently improving the functionality by adding an optional ‘trigger_time’ so you can specify a time after the prices should be calculated. This feature is not yet ready though.

          1. Oh I see. I think thats why it didnt work on the first cycle. Additional trigger time or even a force button would be nice if you upgrade the sensors itll require full cycle before it starts to work.

  2. Hello,
    First – thanks 🙂

    I have installed everything and it works – but I cannot see the “my_expensive_hours” – sensor under entities.
    I only have the cheapest_hour -sensor.
    Not sure what you mean with “Note that the example of expensive hours uses a helper input_number entity to get dynamic number of hours to seek.”
    Do I need to create that helper for it to work?

    I have used your configuration examples in configuration.

    1. Hi!

      You can also add integer value instead of an entity. Similar to cheapest hours example (number_of_hours: 3)
      If you wish to use dynamic value from a helper, you need to create that helper yourself of course.

    1. Hi!

      I’ve checked that out briefly, but it feels quite complicated.
      Though eventually my integration could end up to be as complex as well, since the logic is not straight forward in all the cases.. but let see 😀

  3. Hello Toni, thanks for the good explanation. It is working fine for me now. In my calendar i see the cheapest and expensive hours. It is just not clear to me how i can set my waterboiler to make use of this so that it can heat at the cheapest hour.

    1. Hi!

      You should just turn on the waterheater when cheapest hours binary_sensor changes it state to ‘on’ and vice versa.

      Create a new automation and the example configuration below that controls the input_boolean.
      I guess you have a switch entity to control the water heater so change your data to match the example 🙂

      AIO Energy Management cheapest hours example action

      Let me know if you need more help. You can also mail me at creatingsmarthome (at) gmail.com.

  4. I used your scripts before but this seems much better, but cannot get it to work.

    Im apparently doing something wrong. But I only copied your config and changed to another nordpool entity (swedish kronor). And get this error.

    Any idea what could be wrong?

    2024-08-28 20:29:29.985 DEBUG (MainThread) [custom_components.aio_energy_management.coordinator] Query data from store for my_cheapest_hours
    2024-08-28 20:29:29.985 DEBUG (MainThread) [custom_components.aio_energy_management.nordpool_binary_sensor] No stored value found for my_cheapest_hours or value is expired. Request new data from nord pool integration
    2024-08-28 20:29:29.986 ERROR (MainThread) [custom_components.aio_energy_management.math] Invalid configuration for non-sequential cheapest hours sensor
    2024-08-28 20:29:29.986 DEBUG (MainThread) [custom_components.aio_energy_management.nordpool_binary_sensor] No valid data found. Check failsafe

    1. Hi Joel!

      If you’ve copied the example as is, you should define helper for input_number.my_input_number used on my_expensive_hours.
      The example uses dynamic hours for this specific entity 🙂

      You can replace input_number.my_input_number with some static number as well.

      If you still have problem after this change, you can mail your configuration me to creatingsmarthome (at) gmail.com and I canhave a look if there’s something odd in there

  5. at what time does the new nordpool data comes in? after Expiration ie 21 if thats my last hour?

    1. Hi!

      Yes, current versio fills new data after expiration, if Nord pool data is available. If not available yet, then right after data is published.

      Next version will have the new data set as soon as it is published.

  6. Really nice and easy to integrate. Is it possible to add half hours or minutes. By example 1:30 or 90 minutes?

    1. Hi!

      Currently only full hours are supported.
      I’ll add this feature request to end of me TODO list and see if something can be done at some point (don’t hold your breath though as TODO list is quite big already..) 🙂

  7. Hi Toni!
    Amazing work!

    Just wondering can u make multiple calendar entry.

    Example: 5 cheapest hours and 3 cheapest hours and also 2 expensive hours.
    For my config calendar accepts only last calendar entity.
    Binary sensors work great, but calendar won’t work.

    1. Hi and thanks for the feedback! 🙂

      Multiple calendar entities should work, at least it’s working in my env as should.

      Make sure you’ve defined your calendar only once in the configuration, e.g. calendar should not be defined in every sensor.

      Also current version will remove the calendar entry as soon as the data expires. That is after last_hour has been passed. If you think that could be reason in your case, check again after nord pool prices has been published again.

      If you think it’s still not working properly, you could open an issue on the GitHub project page and try to describe the error situation as detailed as you can. I’ll try to fix it then 🙂

      1. Jep. My bad. I try to use same unique id in sensor and calendar. When i take “silmän käteen” and read your instructions… Everything works fine. 🙂 Thanks!

    1. Thank you very much for your feedback! ..and even more thanks for the coffees 🙂

  8. Hi Toni.
    Awesome work and thank you for adding the max_price parameter.
    Should it be possible to use input slider as a input for the max_price?
    I have troubles to get it to work. Does it matter which decimal separator is used comma/dot?

    Error i got:

    This error originated from a custom integration.

    Logger: custom_components.aio_energy_management.binary_sensor
    Source: custom_components/aio_energy_management/binary_sensor.py:71
    integration: AIO Energy Management (documentation)
    First occurred: 20:15:19 (1 occurrences)
    Last logged: 20:15:19

    Configuration validation error for nord pool cheapest hours sensor: expected float for dictionary value @ data[‘max_price’]

    1. Hi!

      Currently max_price only supports decimal so no dynamic slider can be used. I will add it to next release though.

      Use dot as decimal separator. Full integers should also be entered as decimal numbers. E.g 5 should be configured as 5.0 on max_price

  9. Hi Toni!

    I’ve previously also used your HA integration to select cheapest hours. Recently I noticed on your github page this new integration and its trigger_time possibility with number_of_hours set by input_number entity. And hurried upgrading to this new integration. The end goal was to being able to set the required number_of_hours entity to heat up the water heater with actually needed hours, based on a script calculating it.
    After I did not get it to working, I came to here and noticed that number_of_hours is locked when Nordpool data is received. Bummer. And the trigger_time is not implemented yet. Double bummer. I commented out the trigger_time and got the integration working. But my simple script ain’t doing its job as it should, because it keeps changing, but it’s value is taken in use 7-8 hours before I anticipated it would.
    Well, I have to keep checking here, to see when they are implemented. 🙂
    Thanks!

    1. Hi!

      trigger_time is already implemented with latest 0.3.0 and should work if you are running the latest version 🙂

      1. Oh sorry, you meant that trigger_time should be from entity. That’s not quite there yet.
        The next version should be ready next week and hopefully I can get it implemented for that release. Shouldn’t be a big task.

        1. I meant that trigger_time is set in configuration.yaml, but the number_of_hours should be read from the input_number entity at the time set with trigger_time in configuration.yaml.
          IIRC, when I was building the automation I noticed that the number_of_hours input_number entity was read when new nordpool data came available. And because my input_number entity keeps updating higher as the water heater temp goes down, the amount of hours selected was 8-10 hours old value, not the value it had at the trigger_time moment.

          1. It should update again at the point when trigger_time is reached with the latest 0.3.1 version.

            Maybe update should not be done before trigger_time at all, but anyhow the lock-in should happen on trigger_time hit.
            I’ll fix the update to be ignored before trigger_time hit for the next release.

  10. Hello, Toni!

    Thank you for the excellent integration. I’ve been using it for about a year now.

    Currently, I’m using the AIO Nordpool configuration, and it’s been working well overall. However, after the recent daylight saving time adjustment, it seems like the times are now shifted by an hour. For example, today we have the highest Nordpool price between 15:00-16:00 (for a setup for 2 expensive hours), but in the calendar, it’s showing as 15:00-17:00.

    Thank you for your help!

    Haralds

    1. Hi Haralds!

      Just checked my calendar and it seems to work as should (now GMT+2). Which timezone are you in and which Nord Pool region are you using?
      The winter/summertime conversions are not currently implemented, so Sunday + Monday could have gone a one hour off in theory, but it should work by now already.

      First I’d suggest to restart Home Assistant and see if tomorrow is going to be ok.

      Br, Toni

      1. Restart helped. Now it generated tomorows hours and it looks correct.

        Thank You!

  11. Thanks for your integration. I’m not sure if I fully understand all the parameters, espessally starting_today, sequential and failsafe_starting_hour is confusing.

    I want to get 16 cheapest hours during the day (24h) to trigger my water heater, this is my config:

    aio_energy_management:
    cheapest_hours:
    – nordpool_entity: sensor.nordpool_kwh
    unique_id: nordpool_cheapest_hours
    name: Nordpool Cheapest Hours
    first_hour: 0
    last_hour: 23
    starting_today: false
    number_of_hours: 16
    sequential: False
    failsafe_starting_hour: 01
    – nordpool_entity: sensor.nordpool_kwh
    unique_id: nordpool_expensive_hours
    name: Nordpool Expensive Hours
    first_hour: 0
    last_hour: 23
    starting_today: false
    number_of_hours: 8
    sequential: False
    inversed: true

    Cheapest sensor have this attributes:
    List
    – start: ‘2024-11-09T00:00:00+01:00’
    end: ‘2024-11-09T15:00:00+01:00’
    – start: ‘2024-11-09T16:00:00+01:00’
    end: ‘2024-11-09T17:00:00+01:00′
    Active number of hours
    16
    Failsafe
    start: ’01:00:00′
    end: ’17:00:00’
    Expiration
    November 10, 2024 at 12:00:00 AM
    Updated at
    November 8, 2024 at 5:00:28 PM
    Fetch date
    November 8, 2024

    Maybe it will reset tomorrow?

    1. Hi!

      Config looks ok, but avoid using leading zeros on hour configuration. Should be failsafe_starting_hour: 1

      – starting_today should be set to true if you want to seek cheapest hours on two different days (eg. 22:00 (today) – 08:00 (tomorrow))
      – failsafe is used if Nord pool data is not received by the time failsafe starting is set (e.g. nordpool service or network error for full day..)
      – sequential is used when consequtive cheapest slot needs to be found.

      Your values will update every day as soon as Nord pool publishes new next day prices. So tomorrow next time.

      Btw, you must have huge water heater if you need to heat 16 hours 🙂

      1. Hi,

        thanks for your reply.

        You’re right about number of hours, 16h is probably to much. But the hot water tank is almost empty after morning showers, and I need to be sure it’s warm again in the evening when kids are coming home from sports. So in essens, I want it to heat during the night and during the day – say 10-16. I don’t have any external temp sensor on the tank, and my girls (kids and wife) will kill me if shower is ice cold 🙂

        1. Ha, I understand 😀

          Maybe a better approach instead would be to avoid highest hours in your case?
          You can do it by setting ‘inversed: true’ and change number_of_hours to hours avoid, in your case: ‘number_of_hours: 8’
          ..And of course change to automation to turn on the water heater on ‘off’ state and vice versa.

  12. Hi Toni,

    Thanks for a great work on your new version of cheapest hours. But I have some questions that I don’t really understand. When I look in my local calendar, I can’t find the calendar that is installed automatically from the configuration file. Is that normal? And How can I be able to clean up cached data with the service call “aio_energy_management.clear_data” and how can i run that service call?

    Sorry to have to ask but I’m a bit of a newbie in HA.

    1. Hi Jan!

      You should add the ‘calendar’ section under the aio_energy_management configration on the .yaml file if you haven’t done so yet:

      calendar:
      name: Energy Management
      unique_id: energy_management_calendar

      If you already have it, you should find the calendar on the ‘My Calendars’ section on Home Assistant left side menu. In there you should have a calendar with the name you entered on the configuration.

      For the data clear, it depends on your use case how to use it.
      To just manually clear the data you can use Home Assistant Menu -> Developer Tools -section -> Actions and search for aio_energy_management 🙂

      1. Hi Toni.

        I can see the calendar okay in that section so it is working. I just wondered why i cant see it under Settings -> Integrations -> Local Calendar. I normally use that place to disable or delete a created calendar if it would be needed.

        For Data Clear, it’s okay to use it in the way you explain it until I’ve learned more. I just couldn’t find where it was, thanks for the info to the right place.

        Thanks again for the help and effort you are doing to get me/us to better understand.

  13. Thanks a lot for this new update!

    Is it in any way possible to calculate the cheapest hours including the transfer costs?
    I have yösähkö (night electricity) with the transfer costs being around 4 cents during the day and 2 cents during the night.

    So it would be needed to add the transfer costs in order to get the best solution.

    Also looking forward to the solar automation, as I have that as well!

    Thanks alot!

    1. You can use Nord Pool integration ‘additional costs’ entity to add tariffs.
      Just tested it out with static price and those are correctly added to the Nord Pool dat array as well.
      I’m not 100% certain how well does it work with flexible tariffs, but at least Nord Pool integration says it possible.
      And just to clarify, as long as the additional costs are included in the price array of Nord Pool, those are also taken account in the aio energy management.

      In aio energy management integration itself, there’s no possibility to add additional costs at the moment.

      1. Yes but the additional costs was only (to my knowledge) possible to add when the Nordpool integration is created (and not editable afterwards).

        I was able to create another sensor based on the nordpool that took the values and converted them afterwards to datetime + cost + additional costs. But it was of course not possible to use for this AIO since it used other structure (and the today / tomorrow flags etc).

        Anyways, thanks a lot for this!

  14. Thanks for alle the hard work Toni! (you must be drowning in coffee by now as mine was submitted to the tank:))

    Everything was looking fine and dandy installing and configuring everything, until I figured out that the calendar algorithm does not refresh, so it does not run any next cycle after installing it the first time.
    So the cheapest and expensive hours event were created once in the agenda, but not amended/refreshed by the next day-ahead cycle.
    The Nordpool integration does come up with the right price and does run the next cycle.

    Thanks for your support!

    This is my configuration.yaml listed out:
    list: []
    active_number_of_hours: 3
    failsafe:
    start: “23:00:00”
    end: “02:00:00”
    expiration: “2024-11-25T14:00:00+01:00”
    updated_at: “2024-11-24T13:16:21.242258+01:00”
    fetch_date: “2024-11-24”
    name: My Cheapest Hours
    type: CheapestHoursBinarySensor
    first_hour: 15
    last_hour: 23
    starting_today: true
    number_of_hours: 3
    failsafe_starting_hour: 23
    is_sequential: false
    failsafe_active: false
    inversed: false
    icon: mdi:clock
    friendly_name: My Cheapest Hours

    1. Hi and thanks for the positive feedback 🙂

      First of all I would not suggest to use starting_today as true and ending today as well. starting_today is meant to inform the component that the calculation should start today and continue through night (or at least some part of it). I’d suggest of changing your starting_today as false so it would create events only for tomorrow. Also, I see no point of creating events only for tonight as you could make them for tomorrow and end in the same use case eventually 🙂

      It might work, but I have not developed or tested it to be used like that.

      Also ensure that you are running the latest version of v0.3.2 as there were bug in previous version with quite similar symptoms you are having.

      If these do not help, feel free to ask for more info or even email me to creatingsmarthome (at) gmail.com 🙂

      1. Thanks for support!

        I’ve implemented your suggesttions and I am currently testing it over time.

  15. Hi,

    Thank you for an great integration! I’m configuring it now for the first time but I can already tell it will be amazing. 🙂

    One question, is it possible to set a fixed price, where below this price the device will be always on until the price is above the limit again? I.e. the automations will only be active if the electricity prices are above a certain price?
    Sorry if I missed something obvious or if this already has been discussed. 🙂

    1. Hi!

      You could add number_of_hours to 24 (full day) and price_limit to something you like. That way you should get binary sensor + calendar events to run every hour when the price is below certain point.

      If you set number_of_hours to something less, you get that amount of hours marked maximum.

        1. Hi again,

          When I add the price_limit in the configuration, the binary sensor doesn’t get added with the rest of the sensors.
          I also didn’t see it mentioned above with the rest of the supported configuration paramters. Do I need to add a separate yaml-config for this functionality?

          Thanks!

          – nordpool_entity: sensor.nordpool_kwh_se3_sek_3_095_025
          unique_id: my_cheapest_hours_sensor_below_50_ore
          name: My Cheapest Hours – Under 50 öre
          first_hour: 15
          last_hour: 15
          starting_today: true
          number_of_hours: 24
          sequential: False
          price_limit: 50

          1. Hi!

            price_limit should be ok, but the problem is with the last_hour. You’re asking for 25 hour timeslot now (15.00 – 16.00) as last_hour is the final hour starting, not absolute ending.
            So correct last_hour to 14 and you get timeframe from 15.00 to 15.00.

      1. Ah, I see. Thanks for explaining. However it still won’t pop up among the rest of the sensors. As soon as I remove the price_limit parameter it pops up (after HA reboot).
        Does it have to be in a certain place in the list of paramters?

        1. Order should not matter.
          Please check the logs if you see any errors related to aio_energy_management.
          If theres a configuration error it should be visible without enabling debug logs.

          1. Hi,
            In the logs it says:

            Logger: custom_components.aio_energy_management.binary_sensor
            Source: custom_components/aio_energy_management/binary_sensor.py:75
            integration: AIO Energy Management (documentation)
            First occurred: 4:39:15 PM (1 occurrences)
            Last logged: 4:39:15 PM

            Configuration validation error for nord pool cheapest hours sensor: expected float for dictionary value @ data[‘price_limit’]

          2. Ah of course..

            You should use float value instead of integer (I know, you should be able to use either, but I have not implemented it to be used as int yet).

            So change your price limit from:
            price_limit: 50
            to
            price_limit: 50.0

      2. That did the trick, thanks!

        Should it then be possible to make this value changeable from the GUI using a slider if set to float? I.e something like “price_limit: “{{ states(‘input_number.elpris_limit’) | float }}””

        When I try it I get the same error as before but it could be something I’m missing in the helper as well (first time using it for me):

        input_number:
        elpris_limit:
        name: Elpris limit
        initial: 50
        min: 0
        max: 100
        step: 5
        mode: box
        unit_of_measurement: öre

        1. Hi!

          Dynamic price limit is implement and works as following:
          price_limit: input_number.elpris_limit

          No need to do any fancy templating 🙂

  16. Hi I wonder how to best configure first hour and last hour and if today or not. I need to check for both cheapest and most expensive prise for the whole coming day all hours.

    1. Easiest way to use is starting_today: false, first_hour: 0 and last_hour: 23. That way you get timespan from 0:00-0:00 and get the request amount of cheapest hours for tomorrow full day.

      You could use also use timespan something like 22.00-22.00 if you wish. starting_today: true, first_hour: 22, last_hour: 21. It quite much depends of your use case and the device you’d like to control 🙂

  17. Hi and thanx for great work and integration!
    I am using your old integration “cheapest” and “most expensive” hours to run some automations for solar batterie.
    Have now installed your new integration aio_energy management, and want multiple cheap/Expensive events during each day.

    I have not deleted the old integration, until the new is set up.
    Maybe this causes bad interactions?
    – I have set up 4 entities; Chepaest hours day, Cheapest night, and Expensive morning, Expensive evening;

    But under entities, only the “my_expensive_hours_evening” is set up??

    aio_energy_management:
    cheapest_hours:
    – nordpool_entity: sensor.nordpool_kwh_se3_sek_3_10_025
    unique_id: my_cheapest_hours_day
    name: My Cheapest Hours Day
    first_hour: 08
    last_hour: 20
    starting_today: false
    number_of_hours: 3
    sequential: true
    failsafe_starting_hour: 12
    inversed: false

    – nordpool_entity: sensor.nordpool_kwh_se3_sek_3_10_025
    unique_id: my_expensive_hours_evening
    name: My Expensive Hours Evening
    first_hour: 16
    last_hour: 06
    starting_today: true
    number_of_hours: 3
    sequential: true
    failsafe_starting_hour: 18
    inversed: true

    – nordpool_entity: sensor.nordpool_kwh_se3_sek_3_10_025
    unique_id: my_cheapest_hours_night
    name: My Cheapest Hours Night
    first_hour: 22
    last_hour: 08
    starting_today: true
    number_of_hours: 3
    sequential: true
    failsafe_starting_hour: 02
    inversed: false

    – nordpool_entity: sensor.nordpool_kwh_se3_sek_3_10_025
    unique_id: my_expensive_hours_morning
    name: My Expensive Hours morning
    first_hour: 04
    last_hour: 14
    starting_today: false
    number_of_hours: 3
    sequential: true
    failsafe_starting_hour: 08
    inversed: true

    calendar:
    name: AIO Energy Management

    1. Hi!

      The problem with these are the leading zeros. The current integration only allows integers on failsafe_starting_hour, first_hour and last_hour. So remove leading zero from those:
      first_hour: 04 -> first_hour: 4

      Hopefully this helps. You’re not the first bumping into this problem so clearly I should make a FAQ or even improve the integration to allow leading zeros 🙂

      1. Hi Toni and thanx for quick and clear reply!
        I will remove the zeros immediatly 🙂
        And as a quicky just add “no leading zeros” to the comment in the table in the article.
        Best!

        1. Thanks for the feedback, just added ‘leading zeros not allowed’ in the table 🙂

          1. I can verify that this was the problem. Integration now runs as expected. Thanks for great work!
            🙂

  18. Hi and thnx again for great work!
    Request/wish:
    Would it be possible to store and retrieve the actual cheapest/expensive hourly prices values to the created sensor? As a sensor attribute list maybe? Or to an external helper? So that these values also could be retrieved by other automations, and make it possible to set additional conditions:

    What I would like to do is set condition so that i can compare the expensive hours with the cheapest, and thus set a pricedelta feks. for charging/discharging the battery.

    Best!

    1. I think it could be usefull to have an array of hours with attributes like price, rank (of price), sensor state etc.

      Maybe with an override function on the sensor state.

      Then you could use the “updated event” to trigger an external function to tweak the results. A lot of the different wishes expressed her could be managed like this, I.e max/min price, max/min consecutive hours.

      Regards

  19. Hi I have sometimes problems for when the cheapest hour is found in AIO version compared to the old version that you have made.

    As an Example: I have chosen to get the cheapest times between 22:00 to 06:00 the next day with a time period of 5 hours. In AIO, the time will be between 02:00 to 07:00. In the old version it will be right and there is the time between 01:00 to 06:00.

    When I look in Nordpool, it is the time between 02:00 and 07:00 that is the cheapest 5 hours, but it should still take the time between 01:00 and 06:00 because of my choice of just 5 hours.

    I have taken some print screens on this if you need a better understanding on my issue that i can email you if you wish.

    Is there any setting that I am missing?

    1. Hi!

      It’s difficult to say what could be the problem.
      Could you send me the screenshots, your aio energy management configuration along with current attributes of Nord Pool sensor so I can see if there’s a bug in AIO code or a configuration mistake? 🙂
      Send those to creatingsmarthome (at) gmail.com, if you can please.

  20. Hei Toni

    First of all, thanks for your interesting blog and great work on AIO EM.

    Regarding which, I understand that if I set `starting_today: false` then the cheapest hours will be calculated from tomorrow’s prices.

    But if I set, let’s say

    starting_today: true
    first_hour: 15
    last_hour: 23

    does that mean that the timespan is today 15 – tomorrow 24? When will `last_hour` happen in this case?

    Thanks!

    1. Hi and thanks for the nice feedback!

      last_hour needs to be always tomorrow, no possibility at the moment to use calculation only for today.
      I don’t see a point of making calculations only for today as you can use tomorrow values and when the day has passed it’s still active.

      E.g. you set startind_today as false, first_hour 15 and last_hour 23. You get the cheapest hours marked tomorrow between 15:00-00:00. That will then be repeated the day after etc, so eventually you will get the timespan you like for each upcoming day.

      starting_today is originally implemented to support overnight usage. E.g. 22:00 – 08:00. As we don’t know the values of the after tomorrow, we can’t calculate the night day after yet.

      I hope this cleared things up 🙂
      If you wish to get Finnish support, you can also mail to creatingsmarthome (at) gmail.com and I’ll try to explain in our native language 😀

      1. So `starting_today: true` only affects which day `first_hour` occurs – as the name suggests?

        If so, then cheap/expensive hours can be picked every day at ~14 (once Nordpool publishes the prices) from the next 34 hour period (today 14:00 – tomorrow 23:59)?

        Did I get these right? 🙂

        Thanks!

        1. Maximum timespan for a single period is 24h as otherwise slots might get lapped with each other once new prices are published the day after.

          Eg. you set the period from 15:00 today to 15:00 tomorrow. (starting_today: true, first_hour: 15, last_hour: 14).
          Next day you get the prices again and new cheapest hours will be automatically received for the same timespan and this continues each day 🙂

  21. That’s a silly question, but where can I find the configuration parameters? The Configuration.yaml file only has a reference to “default_config:”.

    1. There’s no such thing as silly question. 🙂

      If you’re having quite fresh install of Home Assistant you might not have anything else in the configuration.yaml than ‘default_config:’.

      So, just copy-paste the configuration example of AIO Energy Management at the end of configuration.yaml file and modify parameters as you require.

Leave a Reply

Your email address will not be published. Required fields are marked *