This blueprint lets uses nordpool data to rank hours from cheapest to most expensive so you can select how many hours you want to count as cheap and you can in addition to that select where in the price span from cheapest(0%) to most expensive(100%) you count as cheap this way if you select that you want 12 hours of on time or below 50% of the price span as minimum the devices will be on for 12 hours but if the price is low most of the day but have a short peek price it may be enabled for more hours.
If you set start and end minutes to different values the devices will be on from start minute to end minute if the price is lower than Always off price that can be useful for when controlling heating that you want to run at least for a short time every hour to not let the temp drop to much if there is a long expensive period.
Parameters:
Start minute
Set the minute in hour to check if the price is low
End minute
If this is different than Start minute the turn on action will be performed by if price is lower than allways_off and on the end minute the turnoff action will be performed if expencive hour
Hours on
Set the minimum of hours per day that the devices should be on
Hour percent
Max percent between minimum and maximum price of the day to turn on devices
Always on price
if the price is below this the device is always on (ignoring Hours on and Hour percent)
Always off price
if the price is above this the device is always off (ignoring Hours on and Hour percent)
With start and end minute to allow the device to be on every hour between start and end minute:
With only start minute when time on every hour is not needed:
blueprint:
name: Nordpool price based on off
description: This blueprints uses the nordpool integration and lets you turn on devices on the cheapest 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
end_minute:
name: End minute
description: If this is different than Start minute the turn on action will be
performed by if price is lower than allways_off and on the end minute the turnoff
action will be performed if expencive hour
default: 0
selector:
number:
min: 0.0
max: 59.0
mode: slider
step: 1.0
hour_rank:
name: Hours on
description: Set the minimum of hours per day that the devices should be on
default: 12
selector:
number:
min: 0.0
max: 24.0
mode: slider
step: 1.0
hour_ratio:
name: Hour percent
description: Max percent between minimum and maximum price of the day to turn
on devices
default: 50
selector:
number:
min: 0.0
max: 100.0
mode: slider
step: 5.0
allways_on:
name: Always on price
description: if the price is below this the device is always on (ignoring Hours
on and Hour percent)
default: 0.0
selector:
number:
min: 0.0
max: 20.0
mode: slider
step: 0.1
allways_off:
name: Always off price
description: if the price is above this the device is always off (ignoring Hours
on and Hour percent)
default: 20
selector:
number:
min: 0.0
max: 20.0
mode: slider
step: 0.1
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/8f301205b12c1a391dd1f87a988cc91be35de125/nordpool_blueprint.yaml
variables:
grid_area_var: !input grid_area
hour_rank_var: !input hour_rank
hour_ratio_var: !input hour_ratio
allways_on_var: !input allways_on
allways_off_var: !input allways_off
start_minute_var: !input start_minute
end_minute_var: !input end_minute
trigger:
- platform: time_pattern
minutes: !input start_minute
- platform: time_pattern
minutes: !input end_minute
action:
- choose:
- conditions:
- condition: template
value_template: >-
{% set prices = state_attr(grid_area_var, 'today') | list %}
{% set h = now().hour %}
{% set m = now().minute %}
{% set price = prices[h] %}
{% set sorted_prices = prices | sort %}
{% set above_low = prices[h] - sorted_prices[0] %}
{% set diff = sorted_prices[23] - sorted_prices[0] %}
{% set ratio = ( above_low / diff ) * 100 | round %}
{% set rank = sorted_prices.index(price) + 1 %}
{% set seton = ( m | int == start_minute_var | int and start_minute_var | int != end_minute_var | int ) or price | float <= allways_on_var | float or ratio | int <= hour_ratio_var | int or rank | int <= hour_rank_var | int %}
{{ price | float < allways_off_var | float and seton }}
sequence: !input turnon
default: !input turnoff
Be nice to me this is my first attempt at creating a blueprint
Hi!
very nice made blueprint. Big thank you!
Can you explain for me in more details.
For example: Start Minute in hour to check price should be 59 and end minute should be 1? Because in this way it will check last hour and will compare with new hour (ongoing hour)?
Always off hour max is 20. Which measurement unit is 20 or what currency?
For example if I want that automation will start at 6.00 and finish 22.00 I just need to set conditions for Turn On (Action to turn on devices)
Fixed Time → After 6.00 and Fixed time → Before 22.00
Turn Off ( Action to turn off devices). Just set device what I want to turn off and no conditions?
Thank you in advance for more information how to set this automation correct.
1: If start minute and end minute differs then it will be “on” between those times if they are the same the price will be checked. So start should be less then end and its better to have them in the low range e.g start 0 and end 15 to be on for the first 15 minutes every hour.
2: the currency depends on your nordpool integration so check the value from the selected grid area sensor.
3: yes you can add additional conditions to turn on and turn off actions, but be aware that if you want it to always be on or off when not within the period you need to add the same conditions to both turn on and and turn off but with the wanted state.
Hi!
Thank you for quick replay!
My idea is that I want to keep some of my lights on from 6.00 to 22.00. But only if price is cheap.
When price is expensive lights should be turned off and automatically turned on when price it´s again cheap. All that cycle should be from 6.00 to 22.00
My grid are is: nordpool_kwh_oslo_nok_3_10_025
My settings looks like this now:
Start minute: 0 End minute: 0
Hours on: 16
Hour percent: 50
Always on price: 0
Always off price: 20 (my currency is NOK)
Device on ( Test Confirm the time is after 06:00 and before 22:00)
Device off ( Test Confirm the time is after 06:00 and before 22:00)
Should all this setup work in this way how I want? What is your opinion?
By the way price right now - 2.78Kr ( which is expensive) and my device turned on because hour changed and it was time with 00 of minute in the end. I mean for example 14:00.
I think it should not tun of because of the price?
the settings you have will keep the light on for at least 16 hours (the 16 cheapest) and if the price curve is quite flat with a peek it might be on more depending on the curve.
Device on ( Test Confirm the time is after 06:00 and before 22:00)add an or case that turn the lights off if the time is not within that time.
Device off ( Test Confirm the time is after 06:00 and before 22:00)if you want the lights to be off when expensive or 22-06 then you do not need the condition here.
With the changes in on and of parts I think it will work as you want.
By the way the price here in SE4 is topping out at 7.49 Sek (7.54 Nok) today!
Hi,
It looks like it works. When there was price spike above 7NOK it turned off lights and when price normalized light came back. Now I need to see if light will be not triggered between 22.00 and 6.00.
If everything will work as I would like then you will be my hero! It will be the first blueprint with minimal adaptation to my system.
I still don´t understand value of (Always off price) which in your blueprint is set by default for 20.
Is it 20SEK and in my case it´s 20NOK or it´s something different?
Thank you!
The always on and always off prices can be set so for example if you set them to 1.0 and 3.0 it will always be on if the price is lower or equal to 1.0 nok in your case and allways off if the price is above 3.0 nok so if the max price one day is 0.9 nok it will be on 24h and if the min price is 3.1 it will be off 24h if start and end minutes are the same.
Hi,
sorry for all those questions. , but sadly with time frame ( from 22.00pm to 6.00am light always should be off) blue print not working. Perhaps I don´t know how to setup properly.
I have perfectly working other blueprint for humidity extractor and with my given time frame it works like a charm. Of course in that blueprint you can set when time frame. Don´t need to use conditions.
I think you only missing the 22-6 condition in the turn on section of the script that set the light to off, may sound strange but for your wanted function it is needed.
Thanks for your help Mikael!
I am trying all different scenarios. Of course it takes time ( because it´s in real time and I need wait for price difference ans so on).
But for sure I will try your suggested option. Right now I am trying with conditions (IF)
Device ON
added conditions:
If → confirm time is after 6:00. Device on.
Else → Turn off
Device OFF
added conditions:
If → confirm time is after 22:00. Device off.
Else → Turn on
I created those conditions yesterday in the evening around 23.00
This morning 9.00 lights turned on and they are still on. Hour percent set to 5
Great blueprint MikaelUlvesjo thanks for that, and i have a questione.
Is it also posible too plan a limit for 3 hours a day from 18:00 till 8:00 on the cheapest 3 hours to charged a bike battery, becource is not good for this battery to connect it the hole night long?
Thanks for a great blueprint!
Would it be possible to add a visual representation of the sliders input. I.E that the available data from the nordpoolsensor is visualised in a graph with green bars and when I set my always off price all bars that are above that will turn red. When I adjust the hours on, the bars change depending on the setting. This will make it a lot easier to adjust it to the appropriate setting.
Thanks in advance