custom-components / nordpool

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

Nordpool takes over 10 seconds to start #399

Closed valexi7 closed 2 months ago

valexi7 commented 2 months ago

Sometimes Norpool sensor takes ages to load and it slows down the entire HA startup. I enabled debug logging and it reports this error:

2024-08-30 11:42:44.137 WARNING (MainThread) [homeassistant.components.sensor] Setup of sensor platform nordpool is taking over 10 seconds.
2024-08-30 11:43:51.441 DEBUG (MainThread) [custom_components.nordpool.aio_price] requested https://www.nordpoolgroup.com/api/marketdata/page/10?currency=EUR&endDate=30-08-2024 {'currency': 'EUR', 'endDate': '30-08-2024'}
2024-08-30 11:43:51.567 DEBUG (MainThread) [custom_components.nordpool.aio_price] requested https://www.nordpoolgroup.com/api/marketdata/page/10?currency=EUR&endDate=31-08-2024 {'currency': 'EUR', 'endDate': '31-08-2024'}
2024-08-30 11:43:51.588 DEBUG (MainThread) [custom_components.nordpool.aio_price] requested https://www.nordpoolgroup.com/api/marketdata/page/10?currency=EUR&endDate=29-08-2024 {'currency': 'EUR', 'endDate': '29-08-2024'}
2024-08-30 11:43:51.675 INFO (MainThread) [custom_components.nordpool.aio_price] Backing off fetch(...) for 18.2s (custom_components.nordpool.aio_price.InvalidValueException: Invalid value in {'start': datetime.datetime(2024, 8, 30, 22, 0, tzinfo=<UTC>), 'end': datetime.datetime(2024, 8, 30, 23, 0, tzinfo=<UTC>), 'value': inf} for area 'FI')
2024-08-30 11:44:10.780 DEBUG (MainThread) [custom_components.nordpool.aio_price] requested https://www.nordpoolgroup.com/api/marketdata/page/10?currency=EUR&endDate=30-08-2024 {'currency': 'EUR', 'endDate': '30-08-2024'}
2024-08-30 11:44:10.864 DEBUG (MainThread) [custom_components.nordpool.aio_price] requested https://www.nordpoolgroup.com/api/marketdata/page/10?currency=EUR&endDate=31-08-2024 {'currency': 'EUR', 'endDate': '31-08-2024'}
2024-08-30 11:44:11.029 DEBUG (MainThread) [custom_components.nordpool.aio_price] requested https://www.nordpoolgroup.com/api/marketdata/page/10?currency=EUR&endDate=29-08-2024 {'currency': 'EUR', 'endDate': '29-08-2024'}
2024-08-30 11:44:11.170 INFO (MainThread) [custom_components.nordpool.aio_price] Backing off fetch(...) for 4.4s (custom_components.nordpool.aio_price.InvalidValueException: Invalid value in {'start': datetime.datetime(2024, 8, 30, 22, 0, tzinfo=<UTC>), 'end': datetime.datetime(2024, 8, 30, 23, 0, tzinfo=<UTC>), 'value': inf} for area 'FI')
2024-08-30 11:44:16.081 DEBUG (MainThread) [custom_components.nordpool.aio_price] requested https://www.nordpoolgroup.com/api/marketdata/page/10?currency=EUR&endDate=30-08-2024 {'currency': 'EUR', 'endDate': '30-08-2024'}
2024-08-30 11:44:16.176 DEBUG (MainThread) [custom_components.nordpool.aio_price] requested https://www.nordpoolgroup.com/api/marketdata/page/10?currency=EUR&endDate=29-08-2024 {'currency': 'EUR', 'endDate': '29-08-2024'}
2024-08-30 11:44:16.214 DEBUG (MainThread) [custom_components.nordpool.aio_price] requested https://www.nordpoolgroup.com/api/marketdata/page/10?currency=EUR&endDate=31-08-2024 {'currency': 'EUR', 'endDate': '31-08-2024'}
2024-08-30 11:44:16.332 INFO (MainThread) [custom_components.nordpool.aio_price] Backing off fetch(...) for 14.2s (custom_components.nordpool.aio_price.InvalidValueException: Invalid value in {'start': datetime.datetime(2024, 8, 30, 22, 0, tzinfo=<UTC>), 'end': datetime.datetime(2024, 8, 30, 23, 0, tzinfo=<UTC>), 'value': inf} for area 'FI')
2024-08-30 11:44:30.971 DEBUG (MainThread) [custom_components.nordpool.aio_price] requested https://www.nordpoolgroup.com/api/marketdata/page/10?currency=EUR&endDate=30-08-2024 {'currency': 'EUR', 'endDate': '30-08-2024'}
2024-08-30 11:44:31.004 DEBUG (MainThread) [custom_components.nordpool.aio_price] requested https://www.nordpoolgroup.com/api/marketdata/page/10?currency=EUR&endDate=31-08-2024 {'currency': 'EUR', 'endDate': '31-08-2024'}
2024-08-30 11:44:31.068 DEBUG (MainThread) [custom_components.nordpool.aio_price] requested https://www.nordpoolgroup.com/api/marketdata/page/10?currency=EUR&endDate=29-08-2024 {'currency': 'EUR', 'endDate': '29-08-2024'}
2024-08-30 11:44:31.189 INFO (MainThread) [custom_components.nordpool.aio_price] Backing off fetch(...) for 12.5s (custom_components.nordpool.aio_price.InvalidValueException: Invalid value in {'start': datetime.datetime(2024, 8, 30, 22, 0, tzinfo=<UTC>), 'end': datetime.datetime(2024, 8, 30, 23, 0, tzinfo=<UTC>), 'value': inf} for area 'FI')

Then it will continue this for 500 seconds until the HA will quit trying...

sysdump commented 2 months ago

It's waiting to tomorrow's prices that is not yet available. Version 0.0.15b1 was recently pre-released and contains a fix for this.