custom-components / nordpool

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

Version 0.0.14 does not load tomorrow’s prices #326

Closed uphillbattle closed 1 year ago

uphillbattle commented 1 year ago

Version of the custom_component

0.0.14

Homeassistant version

2023.5.3 and 2023.5.4

Configuration

UI config

Describe the bug

After updating to the latest version, the integration no longer loads tomorrow’s prices. I have to reload the integration to get next day’s prices.

Debug log

Nothing in the normal logs. I have activate debug logging now, will follow up in a comment if something pops up.

jires commented 1 year ago

Version 0.0.13 has same issue. It started yesterday. No updates performed since 2 weeks ago, so it have to be Noorpool api issue..

developerfromjokela commented 1 year ago

Double check entity/device name. Mine changed for some reason.

yozik04 commented 1 year ago

It did not load yesterday prices for today. Today it failed to load tomorrow prices as well.

Lemming16 commented 1 year ago

I'm having the same problem. Only loads the prices after restart of HA.

agrauballe commented 1 year ago

Same isse for me. Only a HA restart loads tomorrow prices.

ats57 commented 1 year ago

Or to reload integration manually. I have a feeling that this is linked to latest HA core update.

thaowl commented 1 year ago

Once per hour in home-assistant.log Reloading integration works.

-- 2023-05-27 20:00:00.201 ERROR (MainThread) [homeassistant.util.logging] Exception in handle_new_hr when dispatching 'nordpool_update_hour': () Traceback (most recent call last): File "/config/custom_components/nordpool/sensor.py", line 492, in handle_new_hr self._update() File "/config/custom_components/nordpool/sensor.py", line 340, in _update self._average = mean(today) File "/usr/local/lib/python3.10/statistics.py", line 329, in mean T, total, count = _sum(data) File "/usr/local/lib/python3.10/statistics.py", line 187, in _sum T = _coerce(T, typ) # or raise TypeError File "/usr/local/lib/python3.10/statistics.py", line 237, in _coerce raise TypeError(msg % (T.name, S.name)) TypeError: don't know how to coerce float and NoneType

Aephir commented 1 year ago

I have a few additional exceptions

Here, inn case they are useful ``` Logger: homeassistant.util.logging Source: util/logging.py:156 First occurred: 00:00:00 (23 occurrences) Last logged: 20:00:00 Exception in handle_new_day when dispatching 'nordpool_update_day': () Traceback (most recent call last): File "/usr/local/lib/python3.10/statistics.py", line 258, in _exact_ratio return (x.numerator, x.denominator) AttributeError: 'NoneType' object has no attribute 'numerator' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/config/custom_components/nordpool/sensor.py", line 475, in handle_new_day await self.handle_new_hr() File "/config/custom_components/nordpool/sensor.py", line 492, in handle_new_hr self._update() File "/config/custom_components/nordpool/sensor.py", line 340, in _update self._average = mean(today) File "/usr/local/lib/python3.10/statistics.py", line 329, in mean T, total, count = _sum(data) File "/usr/local/lib/python3.10/statistics.py", line 188, in _sum for n, d in map(_exact_ratio, values): File "/usr/local/lib/python3.10/statistics.py", line 261, in _exact_ratio raise TypeError(msg) TypeError: can't convert type 'NoneType' to numerator/denominator Exception in handle_new_hr when dispatching 'nordpool_update_hour': () Traceback (most recent call last): File "/usr/local/lib/python3.10/statistics.py", line 258, in _exact_ratio return (x.numerator, x.denominator) AttributeError: 'NoneType' object has no attribute 'numerator' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/config/custom_components/nordpool/sensor.py", line 492, in handle_new_hr self._update() File "/config/custom_components/nordpool/sensor.py", line 340, in _update self._average = mean(today) File "/usr/local/lib/python3.10/statistics.py", line 329, in mean T, total, count = _sum(data) File "/usr/local/lib/python3.10/statistics.py", line 188, in _sum for n, d in map(_exact_ratio, values): File "/usr/local/lib/python3.10/statistics.py", line 261, in _exact_ratio raise TypeError(msg) TypeError: can't convert type 'NoneType' to numerator/denominator Exception in handle_new_price when dispatching 'nordpool_update_new_price': () Traceback (most recent call last): File "/usr/local/lib/python3.10/statistics.py", line 258, in _exact_ratio return (x.numerator, x.denominator) AttributeError: 'NoneType' object has no attribute 'numerator' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/config/custom_components/nordpool/sensor.py", line 506, in handle_new_price await self.handle_new_hr() File "/config/custom_components/nordpool/sensor.py", line 492, in handle_new_hr self._update() File "/config/custom_components/nordpool/sensor.py", line 340, in _update self._average = mean(today) File "/usr/local/lib/python3.10/statistics.py", line 329, in mean T, total, count = _sum(data) File "/usr/local/lib/python3.10/statistics.py", line 188, in _sum for n, d in map(_exact_ratio, values): File "/usr/local/lib/python3.10/statistics.py", line 261, in _exact_ratio raise TypeError(msg) TypeError: can't convert type 'NoneType' to numerator/denominator ```
PetrolHead2 commented 1 year ago

There is some issue with the data from nordpool, your error msg indicates that some data is missing (NoneType). And it started 00:00 today. I have some other issues with nordpool and missing data and that also started at midnight.

PetrolHead2 commented 1 year ago

I had to manually change the sensor.py to get it to work:

def _update(self):
    """Set attrs"""
    today = self.today

    if not today:
        _LOGGER.debug("No data for today, unable to set attrs")
        return

    if not filter(None, today):
        _LOGGER.debug("No filtered data for today, unable to set attrs")
        return

    self._average = mean(filter(None, today))
    self._min = min(filter(None, today))
    self._max = max(filter(None, today))
    self._off_peak_1 = mean(filter(None, today[0:8]))
    self._off_peak_2 = mean(filter(None, today[20:]))
    self._peak = mean(filter(None, today[8:20]))
    self._mean = median(filter(None, today))
Hellowlol commented 1 year ago

Just do a restart

boogieman1402 commented 1 year ago

This issue is likely because the prices on the spot market weren't established at the regular time today and yesterday (and once before, a few weeks ago). The nordpool integration appears to only try to fetch the prices once, randomly between 13:00 and 14:00 hours. Today, the prices for tomorrow were delayed by 3 hours for NL (see https://www.epexspot.com/en/market-data) :

[ExC_01]: Thresholds reached - Reopening of the order books

Dear Member,

Due to the exceeding of the predefined price thresholds, a Second Auction is triggered.

Consequently, the PX order books will be reopened at 12:50 for exactly 15 minutes.

Therefore, the publication of the Market Coupling Results is delayed.

Low prices are detected for:

  • The Netherlands (NL) on the following hours: 14,15 and 16

Disclaimer: The timings are expressed as CET timings.

Disclaimer for entering or modifying orders:

In case a Second Auction is triggered, an Exhange Member is authorized to adjust its orders according to the following rules:

a) For all hours(s) for which thresolds have been reached:

  • In case of low prices: add purchase volumes, remove sale volumes, increase the prices of the sell and/or purchase Orders;

b) For all hours(s) for which thresolds have not been reached:

  • Order modification is authorized if the Exchange Member can justify its intention to improve the situation of the markt Area >and hour(s) for which thresolds have been reached.

Please refer to the NEMO Operational Rules for other specific cases.

I suppose the best solution would be to add a periodic check every hour starting at 13: (the current logic) and repeating until valid date has been received.

shadowano commented 1 year ago

Or to reload integration manually. I have a feeling that this is linked to latest HA core update.

How do you reload a Hacs integration? Tried redownloading and restart HA without success, still no prices for today

lovekull76 commented 1 year ago

IMG_1644

lovekull76 commented 1 year ago

I do have the same problem since updating HA from 2023.4 to 2023.5 😕

shadowano commented 1 year ago

IMG_1644

I don't have the nordpool hacs integration visible in HA integration. I only see it in Hacs. It's not filtered away

gulli1986 commented 1 year ago

Same problem with core 2023.5.4, looks like today's prices didn't load.

Repsionu commented 1 year ago

How to reload integration when it is defined in configuration.yaml? Only restart? Best, JR

Hellowlol commented 1 year ago

I will investigate and attempt to fix it today. Please provide debug logs.

priiduonu commented 1 year ago

Same problem with 2023.4.6 - tomorrow's prices n/a. Maybe related to negative prices?

boogieman1402 commented 1 year ago

Same problem with 2023.4.6 - tomorrow's prices n/a. Maybe related to negative prices?

https://github.com/custom-components/nordpool/issues/326#issuecomment-1565663161

Not the negative prices per se, but a delay in the markets (from how I'm interpreting it, because a balance could not be found at the first attempt, so repeat auctions were required) combined with just a single attempt from the sensor to fetch the prices.

riksarchen commented 1 year ago

Same issue here. Only restart of HA will solve the issue.

StSaens commented 1 year ago

Until a fix is in. Just auto restart the integration right after midnight (or whatever works for you)

CrallH commented 1 year ago

IMG_1644

I don't have the nordpool hacs integration visible in HA integration. I only see it in Hacs. It's not filtered away

Have you added it as an integration or do you still use the old yaml config?

shadowano commented 1 year ago

Yeah, I was using the config. I added it as an integration instead and that solved it. But the problem is not solved by reloading the integration, only by restarting HA

ThePatricide commented 1 year ago

Interestingly enough, even when I've restarted HA multiple times (using YAML config), still no prices for today show up. Yesterday this fixed the issue. I'll see if I can retrieve debug logging. Edit: apparently the sensor name changed.

Hellowlol commented 1 year ago

@ThePatricide check if the sensor got a new name. Some of the settings are using in the entity id name. In the lastest release i merged a pr that changed back to the default vat thus changing the entity id for Finland

amund7 commented 1 year ago
Log Details (ERROR)
Logger: homeassistant.util.logging
Source: util/logging.py:156
First occurred: May 27, 2023 at 00:00:00 (69 occurrences)
Last logged: 10:00:00

Exception in handle_new_day when dispatching 'nordpool_update_day': () Traceback (most recent call last): File "/usr/local/lib/python3.10/statistics.py", line 258, in _exact_ratio return (x.numerator, x.denominator) AttributeError: 'NoneType' object has no attribute 'numerator' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/config/custom_components/nordpool/sensor.py", line 475, in handle_new_day await self.handle_new_hr() File "/config/custom_components/nordpool/sensor.py", line 492, in handle_new_hr self._update() File "/config/custom_components/nordpool/sensor.py", line 340, in _update self._average = mean(today) File "/usr/local/lib/python3.10/statistics.py", line 329, in mean T, total, count = _sum(data) File "/usr/local/lib/python3.10/statistics.py", line 188, in _sum for n, d in map(_exact_ratio, values): File "/usr/local/lib/python3.10/statistics.py", line 261, in _exact_ratio raise TypeError(msg) TypeError: can't convert type 'NoneType' to numerator/denominator
Exception in handle_new_hr when dispatching 'nordpool_update_hour': () Traceback (most recent call last): File "/usr/local/lib/python3.10/statistics.py", line 258, in _exact_ratio return (x.numerator, x.denominator) AttributeError: 'NoneType' object has no attribute 'numerator' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/config/custom_components/nordpool/sensor.py", line 492, in handle_new_hr self._update() File "/config/custom_components/nordpool/sensor.py", line 340, in _update self._average = mean(today) File "/usr/local/lib/python3.10/statistics.py", line 329, in mean T, total, count = _sum(data) File "/usr/local/lib/python3.10/statistics.py", line 188, in _sum for n, d in map(_exact_ratio, values): File "/usr/local/lib/python3.10/statistics.py", line 261, in _exact_ratio raise TypeError(msg) TypeError: can't convert type 'NoneType' to numerator/denominator
Exception in handle_new_price when dispatching 'nordpool_update_new_price': () Traceback (most recent call last): File "/usr/local/lib/python3.10/statistics.py", line 258, in _exact_ratio return (x.numerator, x.denominator) AttributeError: 'NoneType' object has no attribute 'numerator' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/config/custom_components/nordpool/sensor.py", line 506, in handle_new_price await self.handle_new_hr() File "/config/custom_components/nordpool/sensor.py", line 492, in handle_new_hr self._update() File "/config/custom_components/nordpool/sensor.py", line 340, in _update self._average = mean(today) File "/usr/local/lib/python3.10/statistics.py", line 329, in mean T, total, count = _sum(data) File "/usr/local/lib/python3.10/statistics.py", line 188, in _sum for n, d in map(_exact_ratio, values): File "/usr/local/lib/python3.10/statistics.py", line 261, in _exact_ratio raise TypeError(msg) TypeError: can't convert type 'NoneType' to numerator/denominator
Repsionu commented 1 year ago

Do not know the cause, but after 3 days of misbehavior today tomorrow's prices automagically showed up :-) So it seems that the problem was on NPS side :-/ ? Best, JR

Josefen commented 1 year ago

Do not know the cause, but after 3 days of misbehavior today tommorow's prices automagically showed up :-) So it seems that the problem was on NPS side :-/ ? Best, JR

Can confrim both the problem, and also that it suddenly works :)

shadowano commented 1 year ago

Same here, tomorrow price is shown without any restart or anything

ats57 commented 1 year ago

Same here too

lovekull76 commented 1 year ago

Does NOT work for me, it still don't load anything actually. At manual reload it works (data for tomorrow as well) but for some reason the data is gone after midnight (they are gone in the morning anyway). Negative prices here in Sweden today, again. Could have something to do with that maybe.

bialad commented 1 year ago

I had to delete the integration and add it again to get it working.

general-albatross commented 1 year ago

I suppose the best solution would be to add a periodic check every hour starting at 13: (the current logic) and repeating until valid date has been received.

Periodic check would be best solution, as a quick fix, I changed the hour integration fetches tommorow's prices from 13: to 19: - even if there is prolonged auction, it will be already done by that time. IMO it does not impact in negative way, as prices from day before cover time up till midnight, and personally I do not use any advanced 'Heat Accumulator' scheme that might potentially be impacted by data delay.

priiduonu commented 1 year ago

again - negative prices today - no updates for tomorrow

Logger: homeassistant.util.logging
Source: util/logging.py:156
First occurred: 00:00:00 (21 occurrences)
Last logged: 18:00:00

Exception in handle_new_day when dispatching 'nordpool_update_day': () Traceback (most recent call last): File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 327, in _exact_ratio return (x.numerator, x.denominator) ^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'numerator' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/homeassistant/.homeassistant/custom_components/nordpool/sensor.py", line 475, in handle_new_day await self.handle_new_hr() File "/home/homeassistant/.homeassistant/custom_components/nordpool/sensor.py", line 492, in handle_new_hr self._update() File "/home/homeassistant/.homeassistant/custom_components/nordpool/sensor.py", line 340, in _update self._average = mean(today) ^^^^^^^^^^^ File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 430, in mean T, total, n = _sum(data) ^^^^^^^^^^ File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 193, in _sum for n, d in map(_exact_ratio, values): File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 330, in _exact_ratio raise TypeError(msg) TypeError: can't convert type 'NoneType' to numerator/denominator
Exception in handle_new_hr when dispatching 'nordpool_update_hour': () Traceback (most recent call last): File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 327, in _exact_ratio return (x.numerator, x.denominator) ^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'numerator' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/homeassistant/.homeassistant/custom_components/nordpool/sensor.py", line 492, in handle_new_hr self._update() File "/home/homeassistant/.homeassistant/custom_components/nordpool/sensor.py", line 340, in _update self._average = mean(today) ^^^^^^^^^^^ File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 430, in mean T, total, n = _sum(data) ^^^^^^^^^^ File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 193, in _sum for n, d in map(_exact_ratio, values): File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 330, in _exact_ratio raise TypeError(msg) TypeError: can't convert type 'NoneType' to numerator/denominator
Exception in handle_new_price when dispatching 'nordpool_update_new_price': () Traceback (most recent call last): File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 327, in _exact_ratio return (x.numerator, x.denominator) ^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'numerator' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/homeassistant/.homeassistant/custom_components/nordpool/sensor.py", line 506, in handle_new_price await self.handle_new_hr() File "/home/homeassistant/.homeassistant/custom_components/nordpool/sensor.py", line 492, in handle_new_hr self._update() File "/home/homeassistant/.homeassistant/custom_components/nordpool/sensor.py", line 340, in _update self._average = mean(today) ^^^^^^^^^^^ File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 430, in mean T, total, n = _sum(data) ^^^^^^^^^^ File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 193, in _sum for n, d in map(_exact_ratio, values): File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 330, in _exact_ratio raise TypeError(msg) TypeError: can't convert type 'NoneType' to numerator/denominator
Hellowlol commented 1 year ago

@priiduonu the integration can handle negative prices. The problem is if we get a null value as the price for one of the hours. Removing all None values are trivsl but it will most likely end up with other bugs. Example the api sends crap data with only None values.

Do you have a log of the attemps?

developerfromjokela commented 1 year ago

again - negative prices today - no updates for tomorrow

Logger: homeassistant.util.logging
Source: util/logging.py:156
First occurred: 00:00:00 (21 occurrences)
Last logged: 18:00:00

Exception in handle_new_day when dispatching 'nordpool_update_day': () Traceback (most recent call last): File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 327, in _exact_ratio return (x.numerator, x.denominator) ^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'numerator' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/homeassistant/.homeassistant/custom_components/nordpool/sensor.py", line 475, in handle_new_day await self.handle_new_hr() File "/home/homeassistant/.homeassistant/custom_components/nordpool/sensor.py", line 492, in handle_new_hr self._update() File "/home/homeassistant/.homeassistant/custom_components/nordpool/sensor.py", line 340, in _update self._average = mean(today) ^^^^^^^^^^^ File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 430, in mean T, total, n = _sum(data) ^^^^^^^^^^ File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 193, in _sum for n, d in map(_exact_ratio, values): File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 330, in _exact_ratio raise TypeError(msg) TypeError: can't convert type 'NoneType' to numerator/denominator
Exception in handle_new_hr when dispatching 'nordpool_update_hour': () Traceback (most recent call last): File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 327, in _exact_ratio return (x.numerator, x.denominator) ^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'numerator' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/homeassistant/.homeassistant/custom_components/nordpool/sensor.py", line 492, in handle_new_hr self._update() File "/home/homeassistant/.homeassistant/custom_components/nordpool/sensor.py", line 340, in _update self._average = mean(today) ^^^^^^^^^^^ File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 430, in mean T, total, n = _sum(data) ^^^^^^^^^^ File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 193, in _sum for n, d in map(_exact_ratio, values): File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 330, in _exact_ratio raise TypeError(msg) TypeError: can't convert type 'NoneType' to numerator/denominator
Exception in handle_new_price when dispatching 'nordpool_update_new_price': () Traceback (most recent call last): File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 327, in _exact_ratio return (x.numerator, x.denominator) ^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'numerator' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/homeassistant/.homeassistant/custom_components/nordpool/sensor.py", line 506, in handle_new_price await self.handle_new_hr() File "/home/homeassistant/.homeassistant/custom_components/nordpool/sensor.py", line 492, in handle_new_hr self._update() File "/home/homeassistant/.homeassistant/custom_components/nordpool/sensor.py", line 340, in _update self._average = mean(today) ^^^^^^^^^^^ File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 430, in mean T, total, n = _sum(data) ^^^^^^^^^^ File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 193, in _sum for n, d in map(_exact_ratio, values): File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 330, in _exact_ratio raise TypeError(msg) TypeError: can't convert type 'NoneType' to numerator/denominator

Same happened in finland, tomorrow's prices didn't show up until i restarted HA

priiduonu commented 1 year ago

@Hellowlol sorry, no logs for now. turned on debug and restarted HA, will collect logs next time.

priiduonu commented 1 year ago

the prices for tomorrow were not updated today and there were the following log messages:

Logger: homeassistant.util.logging
Source: util/logging.py:156
First occurred: 00:00:00 (23 occurrences)
Last logged: 21:00:00

Exception in handle_new_day when dispatching 'nordpool_update_day': () Traceback (most recent call last): File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 327, in _exact_ratio return (x.numerator, x.denominator) ^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'numerator' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/homeassistant/.homeassistant/custom_components/nordpool/sensor.py", line 475, in handle_new_day await self.handle_new_hr() File "/home/homeassistant/.homeassistant/custom_components/nordpool/sensor.py", line 492, in handle_new_hr self._update() File "/home/homeassistant/.homeassistant/custom_components/nordpool/sensor.py", line 340, in _update self._average = mean(today) ^^^^^^^^^^^ File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 430, in mean T, total, n = _sum(data) ^^^^^^^^^^ File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 193, in _sum for n, d in map(_exact_ratio, values): File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 330, in _exact_ratio raise TypeError(msg) TypeError: can't convert type 'NoneType' to numerator/denominator
Exception in handle_new_hr when dispatching 'nordpool_update_hour': () Traceback (most recent call last): File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 327, in _exact_ratio return (x.numerator, x.denominator) ^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'numerator' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/homeassistant/.homeassistant/custom_components/nordpool/sensor.py", line 492, in handle_new_hr self._update() File "/home/homeassistant/.homeassistant/custom_components/nordpool/sensor.py", line 340, in _update self._average = mean(today) ^^^^^^^^^^^ File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 430, in mean T, total, n = _sum(data) ^^^^^^^^^^ File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 193, in _sum for n, d in map(_exact_ratio, values): File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 330, in _exact_ratio raise TypeError(msg) TypeError: can't convert type 'NoneType' to numerator/denominator
Exception in handle_new_price when dispatching 'nordpool_update_new_price': () Traceback (most recent call last): File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 327, in _exact_ratio return (x.numerator, x.denominator) ^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'numerator' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/homeassistant/.homeassistant/custom_components/nordpool/sensor.py", line 506, in handle_new_price await self.handle_new_hr() File "/home/homeassistant/.homeassistant/custom_components/nordpool/sensor.py", line 492, in handle_new_hr self._update() File "/home/homeassistant/.homeassistant/custom_components/nordpool/sensor.py", line 340, in _update self._average = mean(today) ^^^^^^^^^^^ File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 430, in mean T, total, n = _sum(data) ^^^^^^^^^^ File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 193, in _sum for n, d in map(_exact_ratio, values): File "/home/homeassistant/.pyenv/versions/3.11.2/lib/python3.11/statistics.py", line 330, in _exact_ratio raise TypeError(msg) TypeError: can't convert type 'NoneType' to numerator/denominator
shadowano commented 1 year ago

Sorry for commenting on a closed thread, but two times this week I had to reload the integration because prices were not automatically fetched for next day. Even after the new day started no data was visible, and around 02 in the night I reloaded the integration and prices appeared.

Seems like this issue is not solved, or maybe it is not published yet?

agrauballe commented 1 year ago

Sorry for commenting on a closed thread, but two times this week I had to reload the integration because prices were not automatically fetched for next day. Even after the new day started no data was visible, and around 02 in the night I reloaded the integration and prices appeared.

Seems like this issue is not solved, or maybe it is not published yet?

I noticed the same. Had to reload Saturday and today (Wednesday)

lovekull76 commented 1 year ago

Same here, checked Nordpool and Tibber, they did not update until around 15.00 (UTC+1).

jtfidje commented 1 year ago

Nordpool did not publish the prices on time, unfortunately.


Mvh / BR

Jahn Thomas Fidje+47 915 88 028

On Wed, 1 Nov 2023 at 21:57, agrauballe @.***> wrote:

Sorry for commenting on a closed thread, but two times this week I had to reload the integration because prices were not automatically fetched for next day. Even after the new day started no data was visible, and around 02 in the night I reloaded the integration and prices appeared.

Seems like this issue is not solved, or maybe it is not published yet?

I noticed the same. Had to reload Saturday and today (Wednesday)

— Reply to this email directly, view it on GitHub https://github.com/custom-components/nordpool/issues/326#issuecomment-1789673244, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADUBG22B4Q4TOXGLJV4X6ULYCKZSBAVCNFSM6AAAAAAYRGPCAGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBZGY3TGMRUGQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

uphillbattle commented 1 year ago

Add these automations to your configurations. One automatically reloads the Nordpool integration after midnight if the tomorrow_valid flag has not been cleared, the other keeps reloading the integration every half hour after 13:00 if tomorrow_valid has not been set (if, for example, the prices are not publish on time. I've never had issues with the Nordpool prices after I set these up.

(Note: replace the sensor name in entity_id at the end of each automation and in the is_state_attr functions with the name of your Nordpool sensor.)

- id: reload_nordpool_after_midnight_if_tomorrow_not_removed
  alias: Reload Nordpool after midnight if tomorrow not removed
  trigger:
    platform: time
    at: '00:05:00'
  condition:
    - condition: template
      value_template: >
        {{ is_state_attr('sensor.nordpool_kwh_oslo_nok_4_10_025','tomorrow_valid', True) }}
  action:
    service: homeassistant.reload_config_entry
    data: {}
    target:
      entity_id: sensor.nordpool_kwh_oslo_nok_4_10_025

- id: reload_nordpool_after_13_hrs_if_tomorrow_not_valid
  alias: Reload Nordpool after 13 hrs if tomorrow not valid
  trigger:
    - platform: time_pattern
      minutes: 20
    - platform: time_pattern
      minutes: 50
  condition:
    - and:
      - condition: template
        value_template: >
          {{ is_state_attr('sensor.nordpool_kwh_oslo_nok_4_10_025','tomorrow_valid', False) }}
      - condition: template
        value_template: >
          {{ now().hour >= 13 }}
  action:
    service: homeassistant.reload_config_entry
    data: {}
    target:
      entity_id: sensor.nordpool_kwh_oslo_nok_4_10_025
shadowano commented 1 year ago

Add these automations to your configurations. One automatically reloads the Nordpool integration after midnight if the tomorrow_valid flag has not been cleared, the other keeps reloading the integration every half hour after 13:00 if tomorrow_valid has not been set (if, for example, the prices are not publish on time. I've never had issues with the Nordpool prices after I set these up.

(Note: replace the sensor name in entity_id at the end of each automation and in the is_state_attr functions with the name of your Nordpool sensor.)

- id: reload_nordpool_after_midnight_if_tomorrow_not_removed
  alias: Reload Nordpool after midnight if tomorrow not removed
  trigger:
    platform: time
    at: '00:05:00'
  condition:
    - condition: template
      value_template: >
        {{ is_state_attr('sensor.nordpool_kwh_oslo_nok_4_10_025','tomorrow_valid', True) }}
  action:
    service: homeassistant.reload_config_entry
    data: {}
    target:
      entity_id: sensor.nordpool_kwh_oslo_nok_4_10_025

- id: reload_nordpool_after_13_hrs_if_tomorrow_not_valid
  alias: Reload Nordpool after 13 hrs if tomorrow not valid
  trigger:
    - platform: time_pattern
      minutes: 20
    - platform: time_pattern
      minutes: 50
  condition:
    - and:
      - condition: template
        value_template: >
          {{ is_state_attr('sensor.nordpool_kwh_oslo_nok_4_10_025','tomorrow_valid', False) }}
      - condition: template
        value_template: >
          {{ now().hour >= 13 }}
  action:
    service: homeassistant.reload_config_entry
    data: {}
    target:
      entity_id: sensor.nordpool_kwh_oslo_nok_4_10_025

Thank you for this! I will test it later when I get time for it. Thanks for sharing

StSaens commented 1 year ago

Doesn’t seem to be an issue that’s hard to handle properly in the addon is it?

It’s a situation (=prices not available at a certain time) that obviously happens from time to time. So a re-check every random minutes until the prices have been received properly.

Repsionu commented 1 year ago

Ditto :-)

JenusL commented 12 months ago

@Hellowlol Maybe it's time to do a release with this fix so it gets out to the masses?

JannikL87 commented 5 months ago

@Hellowlol, still alive? :-)