Blueprint that uses Nordpool and lets you turn on devices on the cheapest hours and make automations based on that information

Thanks for (extremly fast) answer ! Blossing … when i found ~20 new automations…

Question : Is there any way of knowing when the created automation will run ?

Hi

This automation will run when every hour as that is when the values changes in the nordpool entity.

Sorry for unclear question. I meant "is there a way of knowing what output the automation will create ? ( when will the devices be turned on ?) . Some simulation ?

Hi

Not that I’m aware of, you can look at traces to see what it did the last couple of times and when it was run.

Hi,

Is it possible to set always on to a negative price? I’m using solarpanels and my country adds 0,15 taxes to the nordpool price so there are moments like right now that I want to wait for the cheaper hours with turning my water heater on.

Price is 0 now though it will be cheaper in a couple of hours.

Hi

I have not tested it with negative value in all ways on so I don’t know how that works, but you can add the tax and fees to the nordpool prize so it is the actual price.

Awesome. Good job sir. :slight_smile:

1 Like

Instead of the normal nordpool prices I now pasted my sensor that includes the taxes. That works

1 Like

Would it be possible to add some kind of logging to the blueprint traces, so i can see what reasons it had for turning on or off.
Turned on due to min price
Turned on due to 3 cheapest hour
Turned off due to max price

Hello, what could be the reason why this template is not working for me?


Hi

This must be something new in the latest version of HA, sadly my HA did not survive the last upgrade and I have not had time to reinstall it so at the moment I do not have access to any system to test on.

Hi Vidmantukas,

Those legacy things are warnings. The code you have marked with them are valid and will work. If the BP is not working, there is a different problem.

I have made a fork of the repo on github and moved all the conditional logic to variables. This should all show up in the trace in HA and make it easier to follow why the automation does what it does. I also made a pull request to merge it into the main repo of @MikaelUlvesjo

1 Like

Thanks for this, working well.

Could you tell me what you put in the ‘Template for additional costs’ box in the nordpool sensor to add the tax and fees?

Hey Michael - any plans on further developing this to work with 15 min intervals? I have understood nordpool will start to use 15minutes pricing early 2025

Br, Ville

Thank you, Mikael for this Blueprint!
I used it as a base for making my own Nordpool control. I need to switch water heater 2x a day - in the morning and in the evening. So I created Blueprint where you may select start hour and end hour and how many hours device should be on. By that - I would be able to setup 2 separate automation with different start/end hours. BUT… .something is not working… always goes to default. And there is no debugging, at least I do not know how… I am very new to HA, just 1 month. Would appreciate if someone could make it working.

blueprint:
  name: Nordpool price based on/off ATIS
  description:
    This blueprints uses the nordpool integration and lets you turn on
    devices on the chepest hours and make automations based on that information.
  domain: automation
  input:
    grid_area:
      name: Grid area sensor
      description: This is your grid area sensor
      selector:
        entity:
          domain:
            - sensor
          integration: nordpool
          multiple: false
    start_minute:
      name: Start minute
      description: Set the minute in hour to check if the price is low
      default: 0
      selector:
        number:
          min: 0.0
          max: 59.0
          mode: slider
          step: 1.0    
    hour_start:
      name: First hour of period
      description:
        First hour of period(including)
      default: 0
      selector:
        number:
          min: 0.0
          max: 22.0
          mode: slider
          step: 1.0
    hour_end:
      name: Last hour of period
      description:
        Last hour of period(including)
      default: 6
      selector:
        number:
          min: 1.0
          max: 23.0
          mode: slider
          step: 1.0
    hour_count:
      name: ON hour count
      description:
        ON hour count
      default: 3
      selector:
        number:
          min: 1.0
          max: 20.0
          mode: slider
          step: 1.0
          
    turnon:
      name: TurnOn
      description: Actions to run to turn on devices
      default: []
      selector:
        action: {}
    turnoff:
      name: TurnOff
      description: Actions to run to turn off devices
      default: []
      selector:
        action: {}
  #source_url: https://github.com/MikaelUlvesjo/homeassistant/blob/563709ff3d1719cb9504319c01656a1006aa8e8b/nordpool_simple_blueprint.yaml
variables:
  grid_area_var: !input grid_area
  start_minute_var: !input start_minute
  hour_start_var: !input hour_start
  hour_end_var: !input hour_end
  hour_count_var: !input hour_count
trigger:
- platform: time_pattern
  minutes: !input start_minute
action:
- choose:
  - conditions:
    - condition: template
      value_template: '{% set prices = state_attr(grid_area_var, ''Today'') | list %}
              {% set h = now().hour %}
              {% set current_price = prices[h] %}
              {% set needed_price_range = prices[hour_start_var : hour_end_var] %} 
              {% set sorted_prices = needed_price_range | sort %}
              {% set cheapest_sorted_prices = sorted_prices[0:hour_count_var] %}
              {% set occurrences = cheapest_sorted_prices.count(current_price)%} 
              {{ occurrences|int > 0  and h|int >= hour_start_var|int and h|int < hour_end_var|int }}'
    sequence: !input turnon
  default: !input turnoff

Hi, can you explain a bit more:
how does the Max percent between minimum and maximum price of the day to turn on devices work?

Furthermore, how does it affect the Hours On setting?

Thanks

1 Like

I made a sensor for calculating this and added it to the HA energy dashboard directly. The difference made by variable fees in high/low hours is ~0,01€ in my case, not that important for cost-control. Either way here is that sensor, perhaps you can use it as inspiration for a template to put into the nordpool integration

{############## variables ###############}
{% set støtte_terskelverdi = 0.75 %}
{% set støtte_prosentsats = 0.90 %}
{% set mva = 0.25 %}
{% set energiledd_dagsats_inklAvgifter = 0.425 %}
{% set energiledd_nattHelgsats_inklAvgifter = 0.325 %}
{% set tibber_max_påslag = 0.0295 %}

{# nettleie pris tidsrom #}
{% set natt_timer = [ 22, 23, 0, 1, 2, 3, 4, 5 ] %}
{% set helgedager = [ 5, 6 ] %} {# merk tar ikke høyde for helligdager #}

{############ Calculations ###############}
{# get prices and initial states #}
{% set spotpris = states("sensor.nordpool_kwh_no1_nok_3_10_025") | float %}
{% set totalpris = spotpris %}

{# Strømstøtte #}
{% if spotpris > støtte_terskelverdi %}
  {% set totalpris = støtte_terskelverdi + (spotpris - støtte_terskelverdi)*(1 - støtte_prosentsats) %}
{% endif %}

{# mva på strøm #}
{% set totalpris = totalpris * (1 + mva) %} 

{# nettleie - Energiledd med avgifter og mva - kan evt hentes fra Elvia integrasjon i fremtiden. #}
{% if now().weekday() in helgedager or now().hour in natt_timer %}
  {% set totalpris = totalpris + energiledd_nattHelgsats_inklAvgifter %}
{% else %}
  {% set totalpris = totalpris + energiledd_dagsats_inklAvgifter %}
{% endif %}

{# påslag tibber #}
{% set totalpris = totalpris + tibber_max_påslag %}

{{totalpris}}

The percent says that if the current hour is e.g. in the 50% cheapest hours of today → turn on power. So if one hour of the day is super expensive and the rest cheap, this rule will turn on power in all of those cheap hours.

Hours on just sorts all the prices of today and says to turn on the energy in the cheapest e.g. 6 hours.

As these conditions have ‘or’ in between them, if one of them equals to true - the power will turn on

This will change a lot. My least-work first idea would just be to avg. the quarters into hours and keep the rest.

In my case I use this blueprint to run some energy-intensive devices in turn, not at the same time. So it turns all of them off each hour, and then each on in turn until they don’t draw anymore power. So the 3rd device would e.g. be off for 3minutes each hour given that 1st and 2nd devices quickly turn off again. (Waterboilers don’t draw any power when they have reached target temp)

Now 3 minutes each hour is not a problem - but 3 minutes each 15 minutes is a lot. So perhaps I have to reconsider the whole setup