I am hoping to be able to display the previous, current and the 2 next hours prices in my dashboard.
Is there a way to create sensors for these?
Yes, but needs a bit of coding
- Current - you have it from NP data
- For previous - update the sensor or input number value so that it is written to be current price at each hour, 59 minutes 55 seconds for instance, this is easiest.
- Next 2 hours - you have to access the raw prices list and do calculations there, a bit more tricky. Get current hour, find it from the list, take the next 2 elements from list…
Complety neewbie here, but I’m not the only one I can see
I want to get this running: https://github.com/custom-components/nordpool
It works fine, but what I cannot get to work is the additional_costs (by using a constant it works fine) But I need to change the value at 17 to 20 clock everydya, and that I cannot get to work, can anybody point me in direction on what I do wrong?
This is my configuration.yaml
########################################
# Configure a default setup of Home Assistant (frontend, api, etc)
########################################
default_config:
########################################
# THEMES SETUP
########################################
frontend:
themes: !include_dir_merge_named themes
########################################
# Text to speech SETUP
########################################
tts:
- platform: google_translate
########################################
# includes
########################################
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
#sensor: !include sensor.yaml
########################################
# DANFOSS VENTILATION SETUP
########################################
danfoss_air:
host: 192.168.86.36
########################################
# KNX SETUP
########################################
knx:
light:
- name: "Kontor"
address: "0/1/20"
switch:
- name: "Cooper_pluged_in"
address: "15/1/0"
#sensor:
########################################
# NORDPOOL SETUP
# konstant_net_tariff = 0.17,
# Elselskab_tariff = 0, -- changed to vindstød, they do not charge extra
# Stat_nedsat_tariff = 0.15,
# Stat_ikke_nedsat_tariff = 0.28,
# Konstant_ekstra_tariff_17_20 = 0.18,
########################################
sensor:
- platform: nordpool
VAT: True
currency: "DKK"
low_price_cutoff: 0.95
region: "DK1"
precision: 3
price_type: kWh
friendly_name: "Strøm Priser"
# additional_costs: "{{0.6|float}}"
additional_costs: '{% set s = {
"konstant_net_tariff": 0.17,
"konstant_rush_hour_17_20": 0.18,
"elselskab_tariff": 0.0,
"stat_nedsat_tariff: 0.15,
"stat_ikke_nedsat_tariff": 0.28}
%}
{% if now().hour >= 17 and now().hour <= 19 %}
{{s.konstant_net_tariff + s.elselskab_tariff + s.stat_nedsat_tariff + s.stat_ikke_nedsat_tariff + konstant_rush_hour_17_20|float}}
{% else %}
{{s.konstant_net_tariff + s.elselskab_tariff + s.stat_nedsat_tariff + s.stat_ikke_nedsat_tariff|float}}
{% endif %}'
########################################
# Ford Mustang Mach - E SETUP
########################################
- platform: template
sensors:
ford_hv_battery_percent:
friendly_name: "Batteriniveau"
value_template: "{{ state_attr('sensor.fordpass_elveh', 'Battery Fill Level') }}"
unit_of_measurement: "%"
icon_template: mdi:map-marker-distance
device_class: battery
ford_12v_battery:
friendly_name: "12V batteri spænding"
value_template: "{{ state_attr('sensor.fordpass_battery', 'Battery Voltage') }}"
unit_of_measurement: "Volt"
device_class: battery
ford_distance_to_empty_template:
friendly_name: "Afstand til tom"
value_template: "{{ (state_attr('sensor.fordpass_elveh', 'elVehDTE')) | round(0) }}"
unit_of_measurement: "Km"
icon_template: mdi:map-marker-distance
device_class: battery
ford_plug_status:
friendly_name: "Tilsluttet lader"
icon_template: mdi:ev-plug-ccs2
value_template: >-
{% if is_state_attr('sensor.fordpass_elveh', 'Plug Status', 0) %}
Unplugged
{% elif is_state_attr('sensor.fordpass_elveh', 'Plug Status', 1) %}
Plugged In
{% else %}
{% endif %}
Hi Tue!
Experienced the same issue as you until a few minutes ago THe problem by changing the constants the name also change which will mean that automation’s using the sensor will break… When i was answering your post i realized that you can create several instances of the sensor by just adding several blocks in your config.yaml. It is not as clean as sending parameters but i would guess that it works. I just tried to create one additional sensor with another threshold and it seems to work.
What do you think?
I’ve just added these sensors into template.yaml to test:
- name: endhour_kwh_nok
unit_of_measurement: NOK/kWh
state: ‘{{ states(’‘sensor.nordpool_kwh_krsand_nok_3_095_025’’) if now().minute == 59 else states(’‘sensor.endhour_kwh_nok’’)}}’ - name: lasthour_kwh_nok
unit_of_measurement: NOK/kWh
state: ‘{{ states(’‘sensor.endhour_kwh_nok’’) if now().minute == 0 else states(’‘sensor.lasthour_kwh_nok’’)}}’ - name: nexthour_kwh_nok
unit_of_measurement: NOK/kWh
state: ‘{{ state_attr(’‘sensor.nordpool_kwh_krsand_nok_3_095_025’’,’‘today’’)[now().hour+1] if now().hour < 23 else state_attr(’‘sensor.nordpool_kwh_krsand_nok_3_095_025’’,’‘tomorrow’’)[now().hour+1-24] }}’
In theory, endhour_kwh_nok should be updated at at XX:59, and then lasthour_kwh_nok should be updated at XX:00.
I’ll leave it up to gasolli or anyone else to create a sensor nextsecondhour_kwh_nok.
One problem is after the templates has been reloaded, endhour_kwh_nok and lasthour_kwh_nok will be unknown. This can be helped with an automation that stores endhour_kwh_nok in the helper lasthour_kwh_nok at the beginning of each hour.
I’ve started to work on something not exactly that but it could be built further I believe. Work and family consumes a lot of time… So far its three sensors, past 72h mean, past72h median and today median. In my head it should be easy to add past and today and use it as a value.
Anyway im not sure witch of the three is the best approach for the level calculation any input on that would be nice
region: "SE3"
- platform: statistics
name: "Elpris_medel_past72"
unique_id: 50371632
entity_id: sensor.nordpool_kwh_se3_sek_3_10_025
state_characteristic: mean
precision: 4
sampling_size: 144
max_age:
hours: 72
- platform: template
sensors:
pricelevel_medel_past72:
unique_id: 76937444
friendly_name: "Elprisnivå_medel_past72"
unit_of_measurement: 'Level'
value_template: >-
{% if states('sensor.nordpool_kwh_se3_sek_3_10_025')|float(0.5) >= states('sensor.elpris_medel_past72')|float(0.5) *0.9
and states('sensor.nordpool_kwh_se3_sek_3_10_025')|float(0.5) < states('sensor.elpris_medel_past72')|float(0.5) *1.15 %}
{{3}}
{% elif states('sensor.nordpool_kwh_se3_sek_3_10_025')|float >= states('sensor.elpris_medel_past72')|float *0.6
and states('sensor.nordpool_kwh_se3_sek_3_10_025')|float < states('sensor.elpris_medel_past72')|float *0.9 %}
{{2}}
{% elif states('sensor.nordpool_kwh_se3_sek_3_10_025')|float < states('sensor.elpris_medel_past72')|float *0.6 %}
{{1}}
{% elif states('sensor.nordpool_kwh_se3_sek_3_10_025')|float >= states('sensor.elpris_medel_past72')|float *1.15
and states('sensor.nordpool_kwh_se3_sek_3_10_025')|float < states('sensor.elpris_medel_past72')|float *1.4 %}
{{4}}
{% elif states('sensor.nordpool_kwh_se3_sek_3_10_025')|float >= states('sensor.elpris_medel_past72')|float *1.4 %}
{{5}}
{% endif %}
- platform: statistics
name: "Elpris_median_past72"
unique_id: 70542100
entity_id: sensor.nordpool_kwh_se3_sek_3_10_025
state_characteristic: median
precision: 4
sampling_size: 144
max_age:
hours: 72
- platform: template
sensors:
pricelevel_median_past72:
unique_id: 33469883
friendly_name: "Elprisnivå_median_past72"
unit_of_measurement: 'Level'
value_template: >-
{% if states('sensor.nordpool_kwh_se3_sek_3_10_025')|float(0.5) >= states('sensor.Elpris_median_past72')|float(0.5) *0.9
and states('sensor.nordpool_kwh_se3_sek_3_10_025')|float(0.5) < states('sensor.Elpris_median_past72')|float(0.5) *1.15 %}
{{3}}
{% elif states('sensor.nordpool_kwh_se3_sek_3_10_025')|float >= states('sensor.Elpris_median_past72')|float *0.6
and states('sensor.nordpool_kwh_se3_sek_3_10_025')|float < states('sensor.Elpris_median_past72')|float *0.9 %}
{{2}}
{% elif states('sensor.nordpool_kwh_se3_sek_3_10_025')|float < states('sensor.Elpris_median_past72')|float *0.6 %}
{{1}}
{% elif states('sensor.nordpool_kwh_se3_sek_3_10_025')|float >= states('sensor.Elpris_median_past72')|float *1.15
and states('sensor.nordpool_kwh_se3_sek_3_10_025')|float < states('sensor.Elpris_median_past72')|float *1.4 %}
{{4}}
{% elif states('sensor.nordpool_kwh_se3_sek_3_10_025')|float >= states('sensor.Elpris_median_past72')|float *1.4 %}
{{5}}
{% endif %}
- platform: template
sensors:
pricelevel_median_today:
friendly_name: "Elprisnivå_median_today"
unique_id: 95789542
unit_of_measurement: 'Level'
value_template: >-
{% set today=states.sensor.nordpool_kwh_se3_sek_3_10_025.attributes.raw_today| sort(attribute='value')-%}
{%set median= (today[11].value+today[12].value)/2%}
{% if states('sensor.nordpool_kwh_se3_sek_3_10_025')|float(0.5) >= median|float(0.5) *0.9
and states('sensor.nordpool_kwh_se3_sek_3_10_025')|float(0.5) < median|float(0.5) *1.15 %}
{{3}}
{% elif states('sensor.nordpool_kwh_se3_sek_3_10_025')|float >= median|float *0.6
and states('sensor.nordpool_kwh_se3_sek_3_10_025')|float < median|float *0.9 %}
{{2}}
{% elif states('sensor.nordpool_kwh_se3_sek_3_10_025')|float < median|float *0.6 %}
{{1}}
{% elif states('sensor.nordpool_kwh_se3_sek_3_10_025')|float >= median|float *1.15
and states('sensor.nordpool_kwh_se3_sek_3_10_025')|float < median|float *1.4 %}
{{4}}
{% elif states('sensor.nordpool_kwh_se3_sek_3_10_025')|float >= median|float *1.4 %}
{{5}}
{% endif %}
- platform: template
sensors:
elpris_median_today:
friendly_name: "Elpris_median_today"
unique_id: 89574231
unit_of_measurement: 'SEK/kWh'
value_template: >-
{% set today=states.sensor.nordpool_kwh_se3_sek_3_10_025.attributes.raw_today| sort(attribute='value')-%}
{%set median= (today[11].value+today[12].value)/2%}
{{median}}
Here’s the code I ended up with using for an average of the last 72 hours + tomorrow. Now that I look at it I see that I may not have included the prices of today that have not yet occured.
- platform: statistics
name: "elpris_3d_snitt"
state_characteristic: mean
entity_id: sensor.nordpool_kwh_se3_sek_5_095_025
precision: 5
sampling_size: 144
max_age:
hours: 72
template:
- sensor:
- name: elpris_long_avg
unit_of_measurement: 'SEK/kWh'
state: >-
{% set pasthours = 72 %}
{% set prices=state_attr('sensor.nordpool_kwh_se3_sek_5_095_025', 'raw_today') + state_attr('sensor.nordpool_kwh_se3_sek_5_095_025', 'raw_tomorrow') -%}
{% set list = namespace(prices=[]) -%}
{% set pastavg = states('sensor.elpris_3d_snitt')|float(default=0.5) %}
{% for price in prices -%}
{%- if price.end > now() -%}{% set list.prices = list.prices + [price] -%}{%- endif -%}
{% endfor -%}
{% set futureprices = (list.prices | map(attribute='value')|join(',')).split(',') -%}
{% set past_count = (state_attr('sensor.elpris_3d_snitt', 'age_coverage_ratio')|float(default=0))*pasthours %}
{% set pastweighted = pastavg*past_count %}
{% set futuresum = (list.prices | sum(attribute='value'))-futureprices[0]|float-%}
{% set future_count = (futureprices | count)-1 %}
{% set futureavg = futuresum/future_count %}
{% set futureweighted = futureavg*future_count %}
{% set longavg = (pastweighted+futureweighted)/(past_count+future_count) %}
{{ longavg | round(5, default=1) }}
Edit: Updated code to redact current hour from list of future prices. A more elegant way would perhaps be to add an hour to the timezone offset, but I’m not sure how to do that.
Hi
For future refererence if someone comes in here with this problem.
I had set the color scheme to show green from 0 to 0,8 in my currency
Suddenly it would not show, but when i looked at Nordpool i saw negative numbers.
So i set the green to be from -2 to 0,8 and now it show correctly again.
So basically today is going to be sunny and windy to the point where i will GET money for getting power.
Sadly, when the price is -0,2 this still means that i have to pay the 1,5 in electricity tax to the state, so the price will still be about 1,3 but if i had an electric car, and no solar cells this would be the time i would charge.
For them that might need it, I have tweaked a template I found on the net somwhere (can not give the right guy credit, sorry):
{% set today_price = states.sensor.nordpool_kwh_dk1_dkk_2_095_025.attributes.today %}
{% set tomorrow_price = states.sensor.nordpool_kwh_dk1_dkk_2_095_025.attributes.tomorrow %}
{% set ev_car_battery_size = 89 -%}
{% set ev_car_end_charge_level = 100 -%}
{% set ev_car_battery_charge_speed = 10 -%}
{% set ev_car_charge_kwh = (ev_car_battery_size / 100 * (ev_car_end_charge_level - states('sensor.ford_hv_battery_percent') | float)) %}
{% set ev_car_charge_time_min = ((ev_car_charge_kwh / ev_car_battery_charge_speed) * 60) | round(0) -%}
{% set ev_car_charge_time_hour = (ev_car_charge_time_min / 60) | round(0, 'ceil') %}
{% set future_price = today_price[now().hour:] + tomorrow_price -%}
{% set inteval_start_tomorrow = 0 -%}
{% set interval_start_hour = now().hour + 1 -%}
{% set interval_end_tomorrow = 1 -%}
{% set interval_end_hour = 23 -%}
{% set low_interval_length = ev_car_charge_time_hour -%}
{% set all_price = today_price + tomorrow_price -%}
{% set interval_price = all_price[interval_start_hour + 24 * inteval_start_tomorrow : interval_end_hour + 24 * interval_end_tomorrow] -%}
{% set last_considered_interval_index = (interval_price | length) - low_interval_length + 1 -%}
{% set ns = namespace(current_best_average=1000, current_best_index=-1) -%}
{% for price in interval_price[:last_considered_interval_index] -%}
{% set current_average = interval_price[loop.index0:loop.index0+low_interval_length] | average -%}
{% if current_average < ns.current_best_average -%}
{%-set ns.current_best_average = current_average -%}
{% set ns.current_best_index = loop.index0 -%}
{% endif -%}
{% endfor -%}
{%- set start_index = ns.current_best_index %}
{%- set best_interval_price = interval_price[start_index:start_index + low_interval_length] %}
{% set best_interval_start_hour = 24 * inteval_start_tomorrow + interval_start_hour + start_index -%}
{%- set best_interval_price = interval_price[start_index:start_index + low_interval_length] %}
{% set ev_car_start_charge_datetime = (now() + timedelta(hours=best_interval_start_hour - now().hour)) - timedelta(minutes = now().minute) %}
{% set ev_car_stop_charge_datetime = ev_car_start_charge_datetime + timedelta(minutes=ev_car_charge_time_min+10) %}
{% if ev_car_end_charge_level > states('sensor.fordhv_battery_percent') | float -%}
Mustang GT Ladning: {{ states('sensor.ford_hv_battery_percent') | float }}% til {{ ev_car_end_charge_level }}%
Beregning udført : {{ now().strftime('%H:%M den %d/%m') }}
Ladetid : {{ ev_car_charge_time_hour - 1 }} time(r) og {{ ev_car_charge_time_min % 60 }} min
Hvor meget strøm : {{ ev_car_charge_kwh | round(1) }} kWh
Det koster ca : {{ (ev_car_charge_kwh * (best_interval_price| average))| round(0, 'ceil') }} kr
kWh prisen er : {{ (best_interval_price| average)| round(2) }} kr
Start lader : {{ ev_car_start_charge_datetime.strftime('%Y-%m-%dT%H:%M') }}
Stop lader : {{ ev_car_stop_charge_datetime.strftime('%Y-%m-%dT%H:%M') }}
{% else -%}
Mangler ikke ladning
{% endif -%}
It will read my car
and give the charge scheame for a easee charger
This is really nice! Gives a lot of cool info and helps plan the next charging session. But I cant figure out how you get Home Assistant to act on the info? I can only add the template to Development tools and get all the info, but how to add it to an automation, script or sensor? How are you integrating it to your configuration? I would be really greatful for an example of that!
Best regards!
Not really 100 procent my self yet, working progress and learning my self on how to (also new to HA)
Thank you for replying! Then we might cooperate to make something good of it! I’m also pretty new to the more advanced programming of this type of functions. If you are OK with it, please share what you have this far and maybe I can continue to build on it and share back in turn
Hi there
The only thing I have so far is that I shall have a look at state based templates Template - Home Assistant
And that I can do a call that trigger to set values:
- service: input_number.set_value
data:
entity_id: input_number.ev_car
value: Mustang
entity_id: input_number.ev_charge_to
value: 90
entity_id: input_number.ev_bat_size
value: 89
And then I can set tresholds from lovelance
And from here I’m lost
Thank you for the additional information! “Fun” fact: when changing from normal time to daylight saving time as we do tonight, the template script wont work as there are no price for electricity for hour 3 tomorrow… I will continue to experiment when we have valid data to work with again
Made this, think it works, it will only use price for tomorrow if valid:
{% if state_attr('nordpool_kwh_dk1_dkk_2_095_025', 'tomorrow') == none %}
{% set interval_end_tomorrow = 0 -%}
{% set interval_end_hour = 23 -%}
{% else %}
{% set interval_end_tomorrow = 1 -%}
{% set interval_end_hour = states('input_number.mini_charger_ready_tomorrow') | int -%}
And the use a helper to set the time when it must be ready to morrow (made in configuration.yaml)
input_number:
mini_charger_ready_tomorrow:
name: Mini klar kl
icon: mdi:clock-check
mode: slider
initial: 7
step: 1
min: 5
max: 23
unit_of_measurement: Kl
I also created a automation there starts the charger when power is under a certan cheap price, and sends a notify if the car is home and not plugedin. This automation waits 55 minutes if second car is low (under 70%). We have 2 EV car’s one with 33kWh and one with 89kWh battery and loadbalancing on the chargers. 1 car chargning = 11kW, 2 cars 5.5kW each
alias: EV MUSTANG - kWh < "input_number.ev_charge_start_always" kr start ladning.
description: ''
trigger:
- platform: numeric_state
entity_id: sensor.nordpool_kwh_dk1_dkk_2_095_025
below: input_number.ev_charge_start_always
condition: []
action:
- wait_for_trigger:
- platform: numeric_state
entity_id: sensor.cooper_se_charging_level_hv
above: '70'
timeout: '00:55:00'
- choose:
- conditions:
- condition: state
entity_id: sensor.mustang_gt_easee_status
state: disconnected
- condition: device
device_id: 364f4a1d24de696091ae6d4f79a873d8
domain: device_tracker
entity_id: device_tracker.fordpass_tracker
type: is_home
sequence:
- device_id: 7ceb2dfb14ec52a79e1eef4d4540ce9c
domain: mobile_app
type: notify
message: >-
Sæt ladekabel i, der er billig strøm nu, du har {{
states('sensor.ford_hv_battery_percent') }}% batteri, kWh koster:
{{ states('sensor.nordpool_kwh_dk1_dkk_2_095_025') }} kr.
title: Kastanily - Mustang
- conditions:
- condition: state
entity_id: sensor.mustang_gt_easee_status
state: awaiting_start
sequence:
- device_id: 7ceb2dfb14ec52a79e1eef4d4540ce9c
domain: mobile_app
type: notify
message: >-
Lader nu: {{ states('sensor.ford_hv_battery_percent') }}% batteri
og kWh koster: {{ states('sensor.nordpool_kwh_dk1_dkk_2_095_025')
}} kr.
title: Kastaniely - Mustang
default: []
- service: easee.resume
data:
charger_id: XXXXXXX
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.mustang_charger_status_charge
mode: restart
And then the car is pluged in
alias: EV MUSTANG - Ladekabel sat i
description: ''
trigger:
- platform: state
entity_id: sensor.mustang_gt_easee_status
from: disconnected
for:
hours: 0
minutes: 0
seconds: 0
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: input_boolean.mustang_charger_status_charge
state: 'off'
sequence:
- service: easee.pause
data:
charger_id: XXXXXX
default:
- device_id: 7ceb2dfb14ec52a79e1eef4d4540ce9c
domain: mobile_app
type: notify
message: Ladekabel i
mode: restart
So when the car is plugedin the script puts the charger into pause if it has not been told to charge from the “EV MUSTANG - kWh < “input_number.ev_charge_start_always” kr start ladning” (by using a helper to keep track of charge on or off
and then eletricity prices gets above helper value it stops charge and sends notification:
alias: EV MUSTANG - KWh > "input_number.ev_charge_start_always" kr stop ladning
description: ''
trigger:
- platform: numeric_state
entity_id: sensor.nordpool_kwh_dk1_dkk_2_095_025
above: input_number.ev_charge_start_always
condition:
- condition: state
entity_id: sensor.mustang_gt_easee_status
state: charging
action:
- device_id: 7ceb2dfb14ec52a79e1eef4d4540ce9c
domain: mobile_app
type: notify
message: >-
Stopper ladning, kWh kr: {{
states.sensor.nordpool_kwh_dk1_dkk_2_095_025.attributes.current_price
}}kr, ladet til: {{ states('sensor.ford_hv_battery_percent') }}%
title: Kastaniely - Mustang
- service: easee.pause
data:
charger_id: XXXXXX
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.mustang_charger_status_charge
mode: restart
The above makes sure that when electrity is cheap we charge, no matter what nedded
Now I have also made some template sensors that constant gives me these information:
Those are I planing to use from automation
in pseudocode:
if mustang < AA% and kWh awg price is < xx charge to BB%
if mustang < CC% and kWh awg price is < yy charge to DD%
if mustang < EE% and kWh awg price is < zz charge to EE%
Next look into my calender to morrow and se how far do I have to go and then make sure there is enough power for that (I work out from home)
So basicly I want to charge, under these conditions:
CAR 1:
!. Eletricity price cheap
2. If not enough charge for what I have to drive to morrow
CAR 2:
!. Eletricity price cheap
2. If not enough charge for what I have to drive to morrow
Also needs to think in load sharing in the Easee charger if both have to charge same day…
So I have a long way to go yet:-)
Run into a problem:
How do i write to a helper from template?
{# Car and charger settings #}
{% set ev_car_battery_size = 89 -%}
{% set interval_end_hour = (states('input_number.mustang_charger_ready_tomorrow') | int) -%}
{% set ev_car_end_charge_level = (states('input_number.mustang_charger_stop_state') | int)-%}
{% set ev_car_chargestate = (states('sensor.ford_hv_battery_percent') | float) %}
{# define charge spped (11kW or 5.5kW in my setup, if both cars is chargning #}
{% set ev_car_battery_charge_speed = (states('input_number.mustang_charger_speed') | float) %}
{# Nordpool eletricity price settings #}
{% set today_price = states.sensor.nordpool_kwh_dk1_dkk_2_095_025.attributes.today %}
{% set tomorrow_price = states.sensor.nordpool_kwh_dk1_dkk_2_095_025.attributes.tomorrow %}
{# Charger efficinty 90% in my case#}
{% set ev_car_battery_charge_speed = ev_car_battery_charge_speed * 0.9 %}
{% set today_price_from_now = today_price[now().hour:] -%}
{% set all_price = today_price + tomorrow_price -%}
{% set interval_start_tomorrow = 0 -%}
{% set interval_start_hour = now().hour + 1 -%}
{% set interval_end_tomorrow = 1 -%}
{# test if valid prices tomorrow? #}
{% if tomorrow_price[0] == None %}
{% set interval_end_tomorrow = 0 -%}
{% set interval_end_hour = 23 -%}
{% endif %}
{% if ev_car_end_charge_level >= ev_car_chargestate -%}
{% set ev_car_charge_kwh = (ev_car_battery_size / 100 * (ev_car_end_charge_level - ev_car_chargestate)) %}
{% set ev_car_charge_time_min = ((ev_car_charge_kwh / ev_car_battery_charge_speed) * 60) | round(0) -%}
{% set ev_car_charge_time_hour = (ev_car_charge_time_min / 60) | round(0, 'ceil') %}
{% set low_interval_length = ev_car_charge_time_hour -%}
{% set interval_price = all_price[interval_start_hour + 24 * interval_start_tomorrow : interval_end_hour + 24 * interval_end_tomorrow] -%}
{% set last_considered_interval_index = (interval_price | length) - low_interval_length + 1 -%}
{% set ns = namespace(current_best_average=1000, current_best_index=-1) -%}
{% for price in interval_price[:last_considered_interval_index] -%}
{% set current_average = interval_price[loop.index0:loop.index0+low_interval_length] | average -%}
{% if current_average < ns.current_best_average -%}
{%-set ns.current_best_average = current_average -%}
{% set ns.current_best_index = loop.index0 -%}
{% endif -%}
{% endfor -%}
{%- set start_index = ns.current_best_index %}
{%- set best_interval_price = interval_price[start_index:start_index + low_interval_length] %}
{% set best_interval_start_hour = 24 * interval_start_tomorrow + interval_start_hour + start_index -%}
{%- set best_interval_price = interval_price[start_index:start_index + low_interval_length] %}
{% set ev_car_start_charge_datetime = (now() + timedelta(hours=best_interval_start_hour - now().hour)) - timedelta(minutes = now().minute) %}
{% set ev_car_stop_charge_datetime = ev_car_start_charge_datetime + timedelta(minutes=ev_car_charge_time_min + 15) %}
start_charger: {{ ev_car_start_charge_datetime.strftime('%Y-%m-%dT%H:%M') }}
stop_charger : {{ ev_car_stop_charge_datetime.strftime('%Y-%m-%dT%H:%M') }}
charge_time : {{ ev_car_charge_time_hour - 1 }} time(r) og {{ ev_car_charge_time_min % 60 }} min
kWh_needed : {{ ev_car_charge_kwh | round(1) }} kWh
charge_price : {{ (ev_car_charge_kwh * (best_interval_price| average))| round(0, 'ceil') }} kr
kwh_avg_price: {{ (best_interval_price| average)| round(2) }} kr
{% else -%}
0
{% endif -%}
I want to set this helper to the load balancer from my charger?:
'input_number.mustang_charger_speed'
- type: custom:config-template-card
variables:
threshold: states['sensor.electricity_price'].attributes.peak
min_price: states['sensor.electricity_price'].attributes.min - 0.5
max_price: states['sensor.electricity_price'].attributes.max
entities:
- sensor.electricity_price
card:
type: custom:apexcharts-card
graph_span: 24h
span:
start: day
all_series_config:
stroke_width: 2
header:
show: true
title: Electricity Price
show_states: true
colorize_states: true
now:
show: true
color: white
label: NOW
experimental:
color_threshold: true
yaxis: # only 1 yaxis, no need for id or yaxis_id
- min: ${min_price}
# if the sensor doesn't go above 50, the max of the axis will be 50
# else the max will be the maximum value of the sensor
max: ${max_price}
apex_config:
tickAmount: 4
series:
- entity: sensor.electricity_price
color: "#e57300"
color_threshold:
- value: 0
color: "00cc00"
- value: 2.8
color: "#e57300"
show:
in_header: after_now
data_generator: |
return entity.attributes.raw_today.map((entry) => {
return [new Date(entry.start), entry.value];
});
type: column
offset: -30min
for future reference with the config template card, you can achive dynamic threshold
Are there any way to easily display average monthly prices on Nordpool?
So it seems that Nordpool changed something.
The webpage i have as a bookmark now says
Oops!
That page doesn’t seem to exist! Try to use the search bar at the top bar to find content you are looking for.
Also the integration says “Import error”
Maybe the nordpool integration needs a bit of love
I’ve got an interesting situation.
I have 2 separate systems under same local network. Raspberry Pi 4 4GBs with HAOS + all the latest updates. Both have Norpool component installed from HACS and corresponding definitions in configuration.yaml. I believe there is also a graphical way of setting up them, but since I needed to do some testing with variables (mainky additional costs, precision etc.), I took the yaml route.
The 2 systems are coonnected with remote home asistant -integration.
Now, it seems that when both systems initialize during restart, they of course run the settings from the yaml. It looks like that running the yaml from either machine has an effect on the other one as well, that is, when restarting the other, the other one also initializes. I can see this from the fact that the entity (nordpool_kwh_fi_eur_4_095_024) set by Nordpool goes for brief to undefined or null etc. ( I do not recall what exatcly)
Also, the system does not seem to alwyas know, how it should apply the additional costs -setting.
When looking at core.config_entries at /config/.storage folder of Pi, I can see that it differs to config I have in yaml, most dominantly the additional cocts, which in configuration.yaml is
additional_costs: 0.0756372
but in core.config_entries it has the default setting:
{
"entry_id": "xxxxxxxxxxxxxxxxxxxxxxxxx",
"version": 1,
"domain": "nordpool",
"title": "Nordpool",
"data": {
"region": "FI",
"currency": "EUR",
"VAT": true,
"precision": 4,
"low_price_cutoff": 0.95,
"price_in_cents": true,
"price_type": "kWh",
"additional_costs": "{{0.0|float}}"
},
"options": {},
"pref_disable_new_entities": false,
"pref_disable_polling": false,
"source": "user",
"unique_id": null,
"disabled_by": null
},
I have in general not been messing around manually with core.config_entries due to it’s nature as a system -type of file
Q1: Is there a problem, when 2 separate systems from the same ip connects with the Nordpool component to their system? Can it cause some kind of confusion?
Q2: Should I do something (what?) with the obvious conflict between configyration.yaml and core.config_entries described above?