Any good ideas are welcome. Nordpool Energy Price per hour

How to get new Finnish 10% VAT to the sensor?

you can go edit sensor.py
You can find it → /config/custom_components/nordpool
I think you can figure out the rest :wink:
but your sensor name will change. Atleast mine did.

1 Like

Hi,

I’ve been now figuring things out for a while, and this thread has been my lifesaver.
Now I’m in some kind of halt, because after thorough googling, I cant figure out how can i resolve this problem:
I would like to use a slider (input.number) to select x many cheapest hours. Currently I’m picking cheapest hours by:

value_template: >-
      {% set l=state_attr('sensor.nordpool_kwh_fi_eur_3_10_01', 'raw_today')|sort(attribute='value') %}
      {{ (now() >= l[0].start and now() <= l[0].end) }}

So I had in mind to make this thing through multiple automations, that will go on or off depending input number, but there has to be a better way to do this?
Hopefully I was clear enough to be understood.

FYI, this is to make a dumb EV and dumber EV charger a little bit more intelligent.

Thanks @rapu123

So I changed Finlands 0.24 to 0.10 here in sensor.py
The new sensor name is sensor.nordpool_kwh_fi_eur_3_10_01

    "DK1": ["DKK", "Denmark", 0.25],

    "DK2": ["DKK", "Denmark", 0.25],

    "FI": ["EUR", "Finland", 0.10],

    "EE": ["EUR", "Estonia", 0.20],

    "LT": ["EUR", "Lithuania", 0.21],

    "LV": ["EUR", "Latvia", 0.21],

    "Oslo": ["NOK", "Norway", 0.25],

    "Kr.sand": ["NOK", "Norway", 0.25],

    "Bergen": ["NOK", "Norway", 0.25],

    "Molde": ["NOK", "Norway", 0.25],

    "Tr.heim": ["NOK", "Norway", 0.25],

    "Tromsø": ["NOK", "Norway", 0.25],

    "SE1": ["SEK", "Sweden", 0.25],

    "SE2": ["SEK", "Sweden", 0.25],

    "SE3": ["SEK", "Sweden", 0.25],

    "SE4": ["SEK", "Sweden", 0.25],

    # What zone is this?

    "SYS": ["EUR", "System zone", 0.25],

    "FR": ["EUR", "France", 0.055],

    "NL": ["EUR", "Netherlands", 0.09],

    "BE": ["EUR", "Belgium", 0.21],

    "AT": ["EUR", "Austria", 0.20],

    # Tax is disabled for now, i need to split the areas

    # to handle the tax.

    "DE-LU": ["EUR", "Germany and Luxembourg", 0],

2 Likes

Hi,

I am having issues not getting updates for energy prices tomorrow. This than throws off the cheapest energy calculation (from ha_nordpool_cheapest_hours/nordpool_cheapest_hours.yaml at 8a8e78612e29634cd370cadcfe3ef0a926e8913c ¡ kotope/ha_nordpool_cheapest_hours ¡ GitHub) giving

sensor.cheapest_hours_energy_tomorrow rendered invalid timestamp

Any ideas?

There are also these related issues:

Logger: homeassistant.helpers.template_entity
Source: helpers/template_entity.py:356
First occurred: 1:08:16 PM (2 occurrences)
Last logged: 1:08:16 PM

TemplateError('ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ states('sensor.transmission_down_speed')|float * 1024 }}' but no default was specified') while processing template 'Template("{{ states('sensor.transmission_down_speed')|float * 1024 }}")' for attribute '_attr_native_value' in entity 'sensor.transmission_down_speed'
TemplateError('ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ states('sensor.transmission_up_speed')|float * 1024 }}' but no default was specified') while processing template 'Template("{{ states('sensor.transmission_up_speed')|float * 1024 }}")' for attribute '_attr_native_value' in entity 'sensor.transmission_up_speed'

and

Logger: homeassistant.helpers.event
Source: helpers/template.py:425
First occurred: 1:08:16 PM (2 occurrences)
Last logged: 1:08:16 PM

Error while processing template: Template("{{ states('sensor.transmission_down_speed')|float * 1024 }}")
Error while processing template: Template("{{ states('sensor.transmission_up_speed')|float * 1024 }}")
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1710, in forgiving_float_filter
    return float(value)
ValueError: could not convert string to float: 'unknown'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 423, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1942, in _render_with_context
    return template.render(**kwargs)
  File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1713, in forgiving_float_filter
    raise_no_default("float", value)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1411, in raise_no_default
    raise ValueError(
ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ states('sensor.transmission_down_speed')|float * 1024 }}' but no default was specified

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 540, in async_render_to_info
    render_info._result = self.async_render(variables, strict=strict, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 425, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ states('sensor.transmission_down_speed')|float * 1024 }}' but no default was specified

If tomorrow’s hours show, there is no issue with the “kotope” code. So I suppose the issue is more with the Nordpool integration.

Hi!
I feel like a totally newbie and a nutjob, since I tried to add the additional costs to the sensor, even after reading the Nordpool documentation, but with no luck. I just can’t spin my head around this - if I must create a script and save or if it´s enough to paste a bunch of text when configuring the integration. I’m completly lost here. I live in Sweden (SE3) and have 0,7 SEK as additional costs. Can someone please explain it to me as I am a five year old or something, or just paste an example or PM me. Thanks!
/Fanan

Hej!
Put the following under the sensor section in you configuration file.

  - platform: nordpool

    # Should the prices include vat? Default True
    VAT: True

    # What currency the api fetches the prices in
    # this is only need if you want a sensor in a non local currecy
    #currency: "SEK"

    # Helper so you can set your "low" price
    # low_price = hour_price < average * low_price_cutoff
    low_price_cutoff: 0.95

    # What power regions your are interested in.
    # Possible values: "DK1", "DK2", "FI", "LT", "LV", "Oslo", "Kr.sand", "Bergen", "Molde", "Tr.heim", "Tromsø", "SE1", "SE2", "SE3","SE4", "SYS", "EE"
    region: "SE3"

    # How many decimals to use in the display of the price
    precision: 3

    # What the price should be displayed in default
    # Possible values: MWh, kWh and Wh
    # default: kWh
    price_type: kWh

    # This option allows the usage of a template to add a tariff.
    # now() always refers start of the hour of that price.
    # this way we can calculate the correct costs add that to graphs etc.
    # The price result of the additional_costs template expects this additional cost to be in kWh and not cents as a float
    additional_costs: "{{0.7|float}}"
1 Like

Hi, trying to get additional_costs to work. Getting

Error loading /config/configuration.yaml: while scanning for the next token found character ‘%’ that cannot start any token in “/config/sensors/sähkö.yaml”, line 54, column 22

with code below, line 54 being the first one. sähkÜ.yaml is included in configuration.yaml

  additional_costs: '{% set s = {
    "hourly_fixed_cost": 0.0049,
    "day": 0.0288,
    "night": 0.0154
    }
    %}
    {% if now().hour >=7 and now().hour <22 %}
      {{s.day+s.hourly_fixed_cost|float}}
    {% else %}
      {{s.night+s.hourly_fixed_cost|float}}
    {% endif %}'

Pretty new with home assistant, have tried to look for examples for additional costs and documentation for nordpool but can’t get it to work. Any help would be welcome.

You need to format your code differently. See this documentation: https://yaml-multiline.info/

My sensor looks like this:

  additional_costs: >
    {%
      set s = {
          "night": 0.3685,
          "day": 0.4310,
          "cert": 0.01
      }
    %}
    {%  if states('binary_sensor.workday') and (now().hour >=6 and now().hour <22) %}
      {{s.day+s.cert|float}}
    {%else%}
        {{s.night+s.cert|float}}
    {% endif %}

Thanks, got it to work. Formatting isn’t my strong suit, especially with jinja.

Heya! So have someone already done a code where I could have the 3 (or selected) cheapest hours in a row during a given time? Including both today and tomorrow’s prices?

I would like to use it for heating during the night. And with this kind of template I could make the heater go in 3 hours when the price is as cheapest.

Take a look at this post, there are some examples in the comments as well.

1 Like

Take a look at this custom integration:

I would be a bit careful with that integration, I tried it for 36 hours and it did performed worse than just splitting the days prices into 3 different categories and setting the temperature -1, 0 and +1 in that way.

Although I might have just been unlucky with my data for that day, but you should probably dry run it and see if it actually makes sense.

My Nordpool integration stopped working today for no apparent reason. I narrowed it down to current_price * 0.1 not working. Finland dropped the VAT price for electricity from 24 to 10 percent which the integration doesn’t support. I deleted the integration and tried adding it both via UI and YAML but the integration remains Unknown with the additional cost template. It worked just fine for weeks. Any suggestions?

I did sensor via template for getting price in EUR/kWh. This works fine and gives me correct result in eur.

state_class: measurement
unit_of_measurement: EUR/kWh
friendly_name: Nordpool_EUR

But no my energy-dashboard looks like this, what could be a reason ?

I managed to get the Nordpool sensor working reasonably well in HA and managed to create an entity for “lowest price” from the attributes, but would like something more refined for my automations.

Sadly the Templates linked above from creatingsmarthome don’t seem to work for me…syntax errors if I add them…

Does anyone have a better source for Nordpool -based Templates?

What you are trying to do ?

Several things.

My main objectives: charge my PV battery from the Grid when the price is lowest. Charge my Tesla when the price is low and of course turn my Heat Pump up when electricity is cheap. The heat pump isn’t installed yet, so that is for the future, the charging of the PV battery works as does the Tesla, but currently I only have an entity that tracks the “lowest” price, nothing like the lowest range and it always considers the lowest within 24hours, so if it was 13ct. at 01:00 and then rises to 14ct the trigger will ignore that, even if the PV battery hasn’t reached it’s desired SoC yet.

Look no further: GitHub - erlendsellie/priceanalyzer: Priceanalyzer for Home Assistant, based on Nordpool Prices.

1 Like