erlendsellie/priceanalyzer

Summertime - fails to get new data

ArveVM opened this issue · 3 comments

Version of the custom_component

PriceAnalyzer 1.3

Homeassistant version

HA core 2023.3.3

Configuration

Add your logs here.



Describe the bug

Yesterday (the day before adjusting summertime), PriceAnalyzer failed to get data for tomorrow.
Today (the day when summertime have been adjusted), PriceAnalyzer fails to get any data at all.
Seems from the log that there are calcualtions that fails due to there not beeing data for one of the hours?

Yesterday (after both reload integration and restart of HA):

image

Today (after reload integration):

image

Debug log


Logger: homeassistant.components.sensor
Source: custom_components/priceanalyzer/data.py:497
Integration: Sensor (documentation, issues)
First occurred: 08:30:36 (4 occurrences)
Last logged: 10:18:08

Error adding entities for domain sensor with platform priceanalyzer
Error while setting up priceanalyzer platform for sensor
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/homeassistant/helpers/entity_platform.py", line 442, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/lib/python3.10/site-packages/homeassistant/helpers/entity_platform.py", line 717, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/lib/python3.10/site-packages/homeassistant/helpers/entity.py", line 806, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/config/custom_components/priceanalyzer/sensor.py", line 341, in async_added_to_hass
    await self._data.check_stuff()
  File "/config/custom_components/priceanalyzer/data.py", line 852, in check_stuff
    self._update(today)
  File "/config/custom_components/priceanalyzer/data.py", line 497, in _update
    self._off_peak_1 = mean(offpeak1)
  File "/usr/lib/python3.10/statistics.py", line 329, in mean
    T, total, count = _sum(data)
  File "/usr/lib/python3.10/statistics.py", line 187, in _sum
    T = _coerce(T, typ)  # or raise TypeError
  File "/usr/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


My guess is that the proposed nordpool-integration fix might work as a workaround for Priceanalyzer as well?

custom-components#302

My guess is that the proposed nordpool-integration fix might work as a workaround for Priceanalyzer as well?

custom-components#302

You are right!
This should be implemented right about here.
https://github.com/erlendsellie/priceanalyzer/blob/master/custom_components/priceanalyzer/data.py#L499

I don't have a pc with me, but if anyone want to make a PR, I'll merge it right away.

Hopefully fixed in 1.4