custom-components / nordpool

This component allows you to pull in the energy prices into Home-Assistant.
465 stars 110 forks source link

Multiple instances? #182

Closed ruant closed 2 years ago

ruant commented 2 years ago

I'm having trouble with running it multiple times. I want one with the pure spotprice, and a second one with some additional cost (including grid fee etc.)

Anyone been able to do this? It looks to work some times, but more often than not the second one (spot price only) doesn't load anything.

Maybe it's nordpool that limiting the request?

smulle48 commented 2 years ago

I got the same problem.

Only the first instance gets populated with data. The second one does not

Hellowlol commented 2 years ago

Might be api issues. Try reloading the sensor without data

smulle48 commented 2 years ago

Still not working.

I've created 2 identical instances and just changed the precision on one of them. Here's the debug log:

nordpool-log.txt

If I use the GUI to setup the sensor, it's working with multiple instances, but not if I'm adding them in the yaml file.

Apparently only the first in the yaml file gets loaded.

I have tried to swap them in the yaml (the new one above the old working) and then the new gets populated and not the old.

Here's the config, if needed:


sensor:
  - 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: "DKK"

    # 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: "DK1"

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

    # 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
    # default {{0.0|float}}
    additional_costs: '{{0.0|float}}'

  - 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: "DKK"

    # 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: "DK1"

    # 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
    # default {{0.0|float}}
    additional_costs: '{{0.0|float}}'
ruant commented 2 years ago

My second one somehow started working today. I'll turn on some more debugging and we'll see what happens at around 13:00 CET tomorrow when new prices come.

flippz commented 2 years ago

I think it just takes a bit longer, at least thats my experience

ruant commented 2 years ago

It fails at first try, then it retries every hour it looks like and some times manages to get data then. So it looks like it eventually shows up.

But it isn't optimal, loosing the prices while it's trying to fetch isn't good. It's there a way to persiste the state of the sensor between restart? Of course there has to be something that checks that the dates stored is valid, if not retry/throw them out. But then you'll most likely have at least a few hours of valid hours available. Until the integartions gets a valid response from the API again.

smulle48 commented 2 years ago

It fails at first try, then it retries every hour it looks like and some times manages to get data then.

So it looks like it eventually shows up.

But it isn't optimal, loosing the prices while it's trying to fetch isn't good.

It's there a way to persiste the state of the sensor between restart? Of course there has to be something that checks that the dates stored is valid, if not retry/throw them out.

But then you'll most likely have at least a few hours of valid hours available. Until the integartions gets a valid response from the API again.

The weird thing is that if you add multiple instances through the gui, it pulls the data right away for all instances.

It only when they are added through the yaml file it fails (at least here with me)

flippz commented 2 years ago

How do u add it through the gui?

ruant commented 2 years ago

The weird thing is that if you add multiple instances through the gui, it pulls the data right away for all instances.

It only when they are added through the yaml file it fails (at least here with me)

Your totally correct, just tested. The only thing I don't like about the GUI, is that you don't get to configure it through the UI again. It's a one shot setup. But that's probably an easy way to fix a "Configure" button so you can for example change the additional costs template at a later time due to changes.

Or is there a hidden file in Home Assistant where this is stored and can be changed in a text editor?

Example of another integration that allows you to edit settings afterwards: image

nordpool, not so much: image

smulle48 commented 2 years ago

The weird thing is that if you add multiple instances through the gui, it pulls the data right away for all instances.

It only when they are added through the yaml file it fails (at least here with me)

Your totally correct, just tested.

The only thing I don't like about the GUI, is that you don't get to configure it through the UI again.

It's a one shot setup. But that's probably an easy way to fix a "Configure" button so you can for example change the additional costs template at a later time due to changes.

Or is there a hidden file in Home Assistant where this is stored and can be changed in a text editor?

Yeah. Same here. Our taxes has changed quiet a lot lately and if I then deleted the instance from the gui and added a new, all the old price calculations are lost, so until you can modify through gui, I prefer to stick with the yaml file

ruant commented 2 years ago

The weird thing is that if you add multiple instances through the gui, it pulls the data right away for all instances.

It only when they are added through the yaml file it fails (at least here with me)

@smulle48 follow up questions. Does it also work immediately when you restart HA? On both instances through the UI. Or do you have to wait then?

smulle48 commented 2 years ago

The weird thing is that if you add multiple instances through the gui, it pulls the data right away for all instances.

It only when they are added through the yaml file it fails (at least here with me)

@smulle48 follow up questions.

Does it also work immediately when you restart HA? On both instances through the UI.

Or do you have to wait then?

It gets populated immediately:-)

ruant commented 2 years ago

Tried moving mine over through the GUI now. I'm just getting one of them to show data after I restart HA 🤔

Hellowlol commented 2 years ago

Hi

I recommend using GUI for config as this allows for reload of sensor without rebooting the server. There was a bug that did so if you had multiple sensor one of them would often not work until next hours. This should now be fixed with 0.0.8