nordpool icon indicating copy to clipboard operation
nordpool copied to clipboard

Daylight saving time

Open rihokirss opened this issue 2 years ago • 10 comments

Hello,

I'm getting an error if I want to sort the hours by the value of the energy price. {% set l=state_attr('sensor.nordpool_mwh_ee_eur_3_10_02', 'raw_today')|sort(attribute='value') %}

TypeError: '<' not supported between instances of 'NoneType' and 'float'

It looks like it is related with the daylight saving time, since there is hour from 4:00 - 4:00 and value is "null"

  • start: '2022-03-27T02:00:00+02:00' end: '2022-03-27T04:00:00+03:00' value: 63.744
  • start: '2022-03-27T04:00:00+03:00' end: '2022-03-27T04:00:00+03:00' value: null

rihokirss avatar Mar 27 '22 06:03 rihokirss

2022-03-27 12:33:56 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform nordpool Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 614, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 800, in add_to_platform_finish await self.async_added_to_hass() File "/config/custom_components/nordpool/sensor.py", line 484, in async_added_to_hass await self.check_stuff() File "/config/custom_components/nordpool/sensor.py", line 445, in check_stuff self._update(today) File "/config/custom_components/nordpool/sensor.py", line 315, in _update self._off_peak_1 = mean(offpeak1) File "/usr/local/lib/python3.9/statistics.py", line 316, in mean T, total, count = _sum(data) File "/usr/local/lib/python3.9/statistics.py", line 165, in _sum T = _coerce(T, typ) # or raise TypeError File "/usr/local/lib/python3.9/statistics.py", line 216, in _coerce raise TypeError(msg % (T.__name__, S.__name__)) TypeError: don't know how to coerce float and NoneType

stigvi avatar Mar 27 '22 10:03 stigvi

Logger: homeassistant.util.logging Source: util/logging.py:114 First occurred: 00:00:00 (19 occurrences) Last logged: 17:00:00

Exception in check_stuff when dispatching 'nordpool_update': () Traceback (most recent call last): File "/config/custom_components/nordpool/sensor.py", line 460, in check_stuff self._update(self._data_today) File "/config/custom_components/nordpool/sensor.py", line 315, in _update self._off_peak_1 = mean(offpeak1) File "/usr/local/lib/python3.9/statistics.py", line 316, in mean T, total, count = _sum(data) File "/usr/local/lib/python3.9/statistics.py", line 165, in _sum T = _coerce(T, typ) # or raise TypeError File "/usr/local/lib/python3.9/statistics.py", line 216, in _coerce raise TypeError(msg % (T.name, S.name)) TypeError: don't know how to coerce float and NoneType

michaelsidenius avatar Mar 27 '22 16:03 michaelsidenius

The sensor didn't work today because of a "Null" value in the price table (summer-time-adjustment today): Dagens pris er [2.77, 2.75, None, 2.75, 2.75, 2.75, 2.75, 2.75, 2.75, 2.72, 2.68, 2.61, 2.55, 2.36, 2.34, 2.38, 2.56, 2.6, 2.65, 2.72, 2.72, 2.69, 2.68, 2.65]

@Hellowlol , would be very nice if the integration would skip non-numeric or something in your next release :-)

kjbu avatar Mar 27 '22 17:03 kjbu

The sensor didn't work today because of a "Null" value in the price table (summer-time-adjustment today): Dagens pris er [2.77, 2.75, None, 2.75, 2.75, 2.75, 2.75, 2.75, 2.75, 2.72, 2.68, 2.61, 2.55, 2.36, 2.34, 2.38, 2.56, 2.6, 2.65, 2.72, 2.72, 2.69, 2.68, 2.65]

@Hellowlol , would be very nice if the integration would skip non-numeric or something in your next release :-)

wouldnt it be very easy to do a conversion of NULL to 0 before data is loaded into the sensor?

kljakobsen avatar Mar 28 '22 12:03 kljakobsen

wouldnt it be very easy to do a conversion of NULL to 0 before data is loaded into the sensor?

The value should be removed rather than converted to 0. The hour between 02:00+01 and 03:00+02 does not exist, hence the null price. If converted to 0 it would be treated as a valid price, very very cheap, when using the data.

On the night of entering DST the hour 02 is non-existent, as the time goes from 01:59:59+01 to 03:00:00+02. That day and night only contains 23 hours in localtime, not 24. In the fall, when leaving DST again, we will have a day and night containing 25 hours in localtime when the hour 02 exists twice (first 02:00+02 and then 02:00+01).

mikke49 avatar Mar 29 '22 20:03 mikke49

Agree that it should not be set to 0. For instance I use the data to calculate the 3 consecutive hours with the lowest price. If the price is 0 the calculation will for sure be wrong.

JonasPed avatar Mar 31 '22 15:03 JonasPed

Same problem, sort would not work with "null" value. Any way to avoid this?

yksxjan avatar Apr 03 '22 19:04 yksxjan

I'll handle DST in an upcoming version.

Hellowlol avatar Apr 03 '22 19:04 Hellowlol

Sorry if it goes against Github etiquette. This issue still persist. Using null value bit hampers when piping attribute values to a list with Jinja2. ( {{ --- | map(attribute="value") | list }} )

antsalm avatar Mar 25 '23 17:03 antsalm

Hi,

Yeah, there is a regression bug. I should have checked i[value]

Hellowlol avatar Mar 25 '23 19:03 Hellowlol