Gelisob
(Gelisob)
March 19, 2023, 6:44pm
414
I failed with porting that one over so I took the example 5 code and brute forced my day and night numbers into that and added together other tariffs into the “hourly fixed cost” value.
It can be made prettier but I think I’ll leave it here like that for anyone who also wants true total cost values and maybe has summer-winter differences that they want to use. Also changed hours.
Fairly good starting point for anyone I think who meddles with config on that level.
here’s the additional cost value to have nordpool graph with tarrifs:
additional_costs: '{% set s = {
"hourly_fixed_cost": 0.0226,
"winter_night": 0.021,
"winter_day": 0.0369,
"summer_day": 0.0369,
"summer_night": 0.021,
"cert": 0.001
}
%}
{% if now().month >= 5 and now().month < 11 %}
{% if now().hour >= 7 and now().hour < 22 %}
{{ s.summer_day + s.hourly_fixed_cost + s.cert | float }}
{% else %}
{{ s.summer_night + s.hourly_fixed_cost + s.cert|float }}
{% endif %}
{% else %}
{% if now().hour >= 7 and now().hour < 22 %}
{{ s.winter_day + s.hourly_fixed_cost + s.cert | float }}
{% else %}
{{ s.winter_night + s.hourly_fixed_cost + s.cert | float }}
{% endif %}
{% endif %}'
1 Like
arva
(Arva)
March 19, 2023, 6:44pm
415
Thanks i’ll check the prices. Haven’t done it in a while.
And yes, this makes sense that it uses the current value for all hours, because nordpool integration does not know anything about the helper logic.
Try to port the template code into the nordpool configuration like in example 5, and let us know how it went.
Gelisob
(Gelisob)
March 19, 2023, 7:09pm
416
okay here’s prettified code version to generate graph with hourly price differences. If you dont have seasonal differences, just put same number to both periods.
if you dont have something in the list, just use value 0.
# VAT 1.2 means additional costs get 20% vat added after adding together. Not sure how nordpool VAT: True manages additional costs.
additional_costs: '{% set s = {
"operator_margin": 0.0102,
"electricity_excise": 0.001,
"renewable_tariff": 0.0124,
"winter_day": 0.0369,
"winter_night": 0.021,
"summer_night": 0.021,
"summer_day": 0.0369,
"electricity_excise": 0.001,
"VAT": 1.2
}
%}
{% if now().month >= 5 and now().month < 11 %}
{% if now().weekday() in (5,6) %}
{{ (s.summer_night + s.operator_margin + s.renewable_tariff + s.electricity_excise) * s.VAT | float }}
{% else %}
{% if now().hour >= 7 and now().hour < 22 %}
{{ (s.summer_day + s.operator_margin + s.renewable_tariff + s.electricity_excise) * s.VAT | float }}
{% else %}
{{ (s.summer_night + s.operator_margin + s.renewable_tariff + s.electricity_excise) * s.VAT | float }}
{% endif %}
{% endif %}
{% else %}
{% if now().weekday() in (5,6) %}
{{ (s.summer_night + s.operator_margin + s.renewable_tariff + s.electricity_excise) * s.VAT | float }}
{% else %}
{% if now().hour >= 7 and now().hour < 22 %}
{{ (s.winter_day + s.operator_margin + s.renewable_tariff + s.electricity_excise) * s.VAT | float }}
{% else %}
{{ (s.winter_night + s.operator_margin + s.renewable_tariff + s.electricity_excise) * s.VAT | float }}
{% endif %}
{% endif %}
{% endif %}'
edit: forgot the weekends. Added weekend if’s to use summer night rates.
1 Like
tho1981
(Tho1981)
March 20, 2023, 12:43pm
417
Please apologise for the delay. I had to re-install my Raspberry due to stupidness of myself.
Here you go. I also tried to format it as “0,25” instead “0.25” but have the same result.
"
EdwardTFN
(Edward Firmo)
March 20, 2023, 12:51pm
418
The problem is on your sensor id missing the sensor.
in the beginning:
It should be
sensor.nordpool_kwh_dk1_dkk_3_10_025
.
By the way, you will make my life easier if you share your YAML instead of screenshots.
EdwardTFN
(Edward Firmo)
March 20, 2023, 12:53pm
419
When looking at Developer Tools > Status, don’t copy the screen from the “Set State” box. That one if for changing the state, not to see the current state, which is in the big table bellow this box.
tho1981
(Tho1981)
March 20, 2023, 12:59pm
421
Haha. Okay, fair enough.
Still same error though.
# Loads default set of integrations. Do not remove.
default_config:
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
# Text to speech
tts:
- platform: google_translate
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
powercalc:
template:
- sensor:
- name: Electricity selling price
unique_id: electricity_selling_price
unit_of_measurement: "DKK/kWh"
device_class: monetary
availability: "{{ is_number('sensor.nordpool_kwh_dk1_dkk_3_10_025') }}"
state: "{{ states('sensor.nordpool_kwh_dk1_dkk_3_10_025') | float(0) - 0.25 }}"
sensor:
- platform: template
sensors:
# Template sensor for values of power import (active_power > 0)
power_import:
friendly_name: "Power Import"
unit_of_measurement: 'W'
value_template: >-
{% if (states('sensor.shelly3em_channel_a_power')|float + states('sensor.shelly3em_channel_b_power')|float + states('sensor.shelly3em_channel_c_power')|float) > 0 %}
{{ states('sensor.shelly3em_channel_a_power')|float + states('sensor.shelly3em_channel_b_power')|float + states('sensor.shelly3em_channel_c_power')|float }}
{% else %}
{{ 0 }}
{% endif %}
availability_template: "{{
[ states('sensor.shelly3em_channel_a_power'),
states('sensor.shelly3em_channel_b_power'),
states('sensor.shelly3em_channel_c_power')
] | map('is_number') | min
}}"
# Template sensor for values of power export (active_power < 0)
power_export:
friendly_name: "Power Export"
unit_of_measurement: 'W'
value_template: >-
{% if (states('sensor.shelly3em_channel_a_power')|float + states('sensor.shelly3em_channel_b_power')|float + states('sensor.shelly3em_channel_c_power')|float) < 0 %}
{{ (states('sensor.shelly3em_channel_a_power')|float + states('sensor.shelly3em_channel_b_power')|float + states('sensor.shelly3em_channel_c_power')|float) * -1 }}
{% else %}
{{ 0 }}
{% endif %}
availability_template: "{{
[ states('sensor.shelly3em_channel_a_power'),
states('sensor.shelly3em_channel_b_power'),
states('sensor.shelly3em_channel_c_power')
] | map('is_number') | min
}}"
# Template sensor for values of power consumption
power_consumption:
friendly_name: "Power Consumption"
unit_of_measurement: 'W'
value_template: >-
{% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) < 0 %}
{% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.power_solargen')|float(0) - states('sensor.power_export')|float(0)) > 0 %}
{{ (states('sensor.power_solargen')|float(0)) - states('sensor.power_export')|float(0) }}
{% else %}
{{ states('sensor.power_import')|float(0) + states('sensor.power_solargen')|float(0) }}
{% endif %}
# Sensor for Riemann sum of energy import (W -> Wh)
- platform: integration
source: sensor.power_import
name: energy_import_sum
unit_prefix: k
round: 2
method: left
# Sensor for Riemann sum of energy export (W -> Wh)
- platform: integration
source: sensor.power_export
name: energy_export_sum
unit_prefix: k
round: 2
method: left
# Sensor for Riemann sum of energy consumption (W -> Wh)
- platform: integration
source: sensor.power_consumption
name: energy_consumption_sum
unit_prefix: k
round: 2
method: left
utility_meter:
energy_import_daily:
source: sensor.energy_import_sum
name: Energy Import Daily
cycle: daily
energy_import_monthly:
source: sensor.energy_import_sum
name: Energy Import Monthly
cycle: monthly
energy_export_daily:
source: sensor.energy_export_sum
name: Energy Export Daily
cycle: daily
energy_export_monthly:
source: sensor.energy_export_sum
name: Energy Export Monthly
cycle: monthly
energy_consumption_daily:
source: sensor.energy_consumption_sum
name: Energy Consumption Daily
cycle: daily
energy_consumption_monthly:
source: sensor.energy_consumption_sum
name: Energy Consumption Monthly
cycle: monthly
EdwardTFN
(Edward Firmo)
March 20, 2023, 2:16pm
422
yeap!
This is the right one.
But what if you filter for the sensor sensor.nordpool_kwh_dk1_dkk_3_10_025
instead?
EdwardTFN
(Edward Firmo)
March 20, 2023, 2:34pm
424
Ok, change the availability to this:
availability: "{{ is_number(states('sensor.nordpool_kwh_dk1_dkk_3_10_025')) }}"
tho1981
(Tho1981)
March 20, 2023, 6:42pm
425
Wooooohoo. The error message is gone. Now I need to see if the number counts upwards in approximately 14 hours when the sun is doing its thing.
I don’t know why yourself and many others are helping all the noobs like myself but I find it super cool!
1 Like
droidgren
(Droidgren)
March 21, 2023, 9:55am
427
Today I don’t see the current value of the consumption in the header anymore, instead it shows the last value. It should be around 1,5 and not 0,7 Why?
Here is my code
type: custom:apexcharts-card
header:
show: true
title: Nordpool price 24h
show_states: true
colorize_states: true
graph_span: 1d
now:
show: true
span:
start: day
series:
- entity: sensor.nordpool
data_generator: |
return entity.attributes.raw_today.map((p) => {
return [new Date(p.start), p.value];
});
kirill
(Kirill)
March 28, 2023, 7:01pm
428
Hello! Does any one send a notification with average, min, max prices as well as times when nordpool prices get updated? Care to share your code?
Anyone able to help me
I had done a few different versions of a sensor, but only needed one so i wanted to trim my configuration.yaml, and i am a fool so i did not make a copy of the original file, i just deleted and saved, and now this sensor is not working
It says configuration is invalid when i try to restart HA so i have to comment it out and save to be able to reload.
Sensor should just be doing simple math, subtracting one sensor from another to know what surplus i have.
I probably deleted something i should have, when deleting the other sensors.
This is what’s left in the configuration.yaml file.
sensors:
delta_t_solar_heating3:
friendly_name: Surplus solar 3
unit_of_measurement: W
value_template: >-
{{ ( states('sensor.pv_power') | float |
round(0)) - ( states('sensor.load_power') | float
| round(0))}}
EdwardTFN
(Edward Firmo)
April 1, 2023, 8:05pm
430
hmadsen:
sensors:
Try remov8ng the “s” at the end of sensors:
…
It will look like this:
sensor:
delta_t_solar_heating3:
friendly_name: Surplus solar 3
unit_of_measurement: W
value_template: >-
{{ ( states('sensor.pv_power') | float |
round(0)) - ( states('sensor.load_power') | float
| round(0))}}
Thank you
Seems i messed up a bit more than i thought
If i do as you say i get another error
Here is the full file, can you spot what is wrong
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Text to speech
tts:
- platform: google_translate
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
climate:
- platform: touchline
host: http://10.0.0.59
sensor:
delta_t_solar_heating3:
friendly_name: Surplus solar 3
unit_of_measurement: W
value_template: >-
{{ ( states('sensor.pv_power') | float |
round(0)) - ( states('sensor.load_power') | float
| round(0))}}
After changing it to sensor i get this error when checking
Invalid config for [sensor]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 18).
PS. yes this is the full file, i am not a very advanced user
RT1080
(Ronald)
April 2, 2023, 7:57am
432
you forgot the platform, this is template. And then indeed you can follow with “sensors” (as opposed to sensor).
Template - Home Assistant (home-assistant.io)
platform: template
sensors:
delta_t_solar_heating:
friendly_name: Surplus solar 3
unit_of_measurement: W
value_template: >-
{{ ( states('sensor.pv_power') | float | round(0)) - ( states('sensor.load_power') | float | round(0))}}
sensor2:
etc
RT1080
(Ronald)
April 2, 2023, 8:00am
433
might be though mine is the old-fashioned syntax - does work.