Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Daylight saving time #129

Open
rihokirss opened this issue Mar 27, 2022 · 10 comments
Open

Daylight saving time #129

rihokirss opened this issue Mar 27, 2022 · 10 comments
Labels
bug Something isn't working

Comments

@rihokirss
Copy link

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
@stigvi
Copy link

stigvi commented Mar 27, 2022

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

@michaelsidenius
Copy link

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

@kjbu
Copy link

kjbu commented Mar 27, 2022

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 :-)

@kljakobsen
Copy link

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?

@mikke49
Copy link

mikke49 commented Mar 29, 2022

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).

@JonasPed
Copy link

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.

@Hellowlol Hellowlol added the bug Something isn't working label Mar 31, 2022
@yksxjan
Copy link

yksxjan commented Apr 3, 2022

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

@Hellowlol
Copy link
Collaborator

I'll handle DST in an upcoming version.

@antsalm
Copy link

antsalm commented Mar 25, 2023

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 }} )

@Hellowlol
Copy link
Collaborator

Hi,

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

10 participants