MTrab / energidataservice

Fetches spot prices from Energi Data Service
GNU General Public License v3.0
192 stars 27 forks source link

Integration hangs on starup #526

Closed Jazzic closed 3 months ago

Jazzic commented 5 months ago

Describe the issue

Hangs on initial installation and in HA startup process.

What version of Home Assistant Core has the issue?

core-2024.6.4

What was the last working version of Home Assistant Core?

core-2023.something.something

What type of installation are you running?

Home Assistant OS

Diagnostics information

home-assistant_energidataservice_2024-06-25T23-11-56.851Z.log

Anything in the logs that might be useful for us?

Logger: homeassistant.config_entries
Source: config_entries.py:594
First occurred: 1:02:53 AM (1 occurrences)
Last logged: 1:02:53 AM

Error setting up entry Energi Data Service for energidataservice
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/energidataservice/__init__.py", line 54, in async_setup_entry
    result = await _setup(hass, entry)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/energidataservice/__init__.py", line 187, in _setup
    await api.async_get_tariffs()
  File "/config/custom_components/energidataservice/api.py", line 298, in async_get_tariffs
    self.tariff_data = await tariff.async_get_tariffs()
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/energidataservice/tariffs/energidataservice/__init__.py", line 59, in async_get_tariffs
    await self.async_get_system_tariffs()
  File "/config/custom_components/energidataservice/tariffs/energidataservice/__init__.py", line 165, in async_get_system_tariffs
    dataset = await self.async_call_api(query)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/async_retrying_ng/__init__.py", line 124, in wrapped
    ret = await ret
          ^^^^^^^^^
  File "/config/custom_components/energidataservice/tariffs/energidataservice/__init__.py", line 193, in async_call_api
    resp = await self.client.get(f"{BASE_URL}?{query}", headers=headers)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 608, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 976, in start
    message, payload = await protocol.read()  # type: ignore[union-attr]
                       ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/streams.py", line 640, in read
    await self._waiter
asyncio.exceptions.CancelledError: Global task timeout

Additional information

No response

MTrab commented 5 months ago

Please update to latest version

Jazzic commented 5 months ago

This is version 1.5.8:

{ "domain": "energidataservice", "name": "Energi Data Service", "after_dependencies": [ "http" ], "codeowners": [ "@MTrab" ], "config_flow": true, "documentation": "https://github.com/MTrab/energidataservice/blob/master/README.md", "iot_class": "cloud_polling", "issue_tracker": "https://github.com/MTrab/energidataservice/issues", "requirements": [ "async-retrying-ng==0.1.3", "CurrencyConverter==0.17.21" ], "version": "1.5.8" }

MTrab commented 5 months ago

Strange. I haven't heard of any other having issues with latest HA and EDS

TermeHansen commented 5 months ago

might be related to the warning I just saw in 2024.7 and reported in #529 :

homeassistant  | 2024-07-03 21:06:46.167 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to listdir with args ('/config/custom_components/energidataservice/tariffs',) inside the event loop by custom integration 'energidataservice' at custom_components/energidataservice/tariffs/__init__.py, line 27: for module in sorted(listdir(f"{dirname(__file__)}")): (offender: /config/custom_components/energidataservice/tariffs/__init__.py, line 27: for module in sorted(listdir(f"{dirname(__file__)}")):), please create a bug report at https://github.com/MTrab/energidataservice/issues
homeassistant  | For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#listdir
homeassistant  | Traceback (most recent call last):
homeassistant  |   File "<frozen runpy>", line 198, in _run_module_as_main
homeassistant  |   File "<frozen runpy>", line 88, in _run_code
homeassistant  |   File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module>
homeassistant  |     sys.exit(main())
homeassistant  |   File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main
homeassistant  |     exit_code = runner.run(runtime_conf)
homeassistant  |   File "/usr/src/homeassistant/homeassistant/runner.py", line 190, in run
homeassistant  |     return loop.run_until_complete(setup_and_run_hass(runtime_config))
homeassistant  |   File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete
homeassistant  |     self.run_forever()
homeassistant  |   File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever
homeassistant  |     self._run_once()
homeassistant  |   File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once
homeassistant  |     handle._run()
homeassistant  |   File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
homeassistant  |     self._context.run(self._callback, *self._args)
homeassistant  |   File "/usr/src/homeassistant/homeassistant/config_entries.py", line 734, in async_setup_locked
homeassistant  |     await self.async_setup(hass, integration=integration)
homeassistant  |   File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
homeassistant  |     result = await component.async_setup_entry(hass, self)
homeassistant  |   File "/config/custom_components/energidataservice/__init__.py", line 54, in async_setup_entry
homeassistant  |     result = await _setup(hass, entry)
homeassistant  |   File "/config/custom_components/energidataservice/__init__.py", line 90, in _setup
homeassistant  |     await api.initialize()
homeassistant  |   File "/config/custom_components/energidataservice/api.py", line 106, in initialize
homeassistant  |     await self.tariffs.load_modules()
homeassistant  |   File "/config/custom_components/energidataservice/tariffs/__init__.py", line 27, in load_modules
homeassistant  |     for module in sorted(listdir(f"{dirname(__file__)}")):
MTrab commented 5 months ago

Nope, not even remotely the same errors shown

stensberg commented 4 months ago

I experienced the same today but now it seems to be working. I got this from logs:

2024-08-02 07:08:11.895 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: {('energidataservice', 'a777e883510f6496e63283338591e648'): 1518245.755121577}
2024-08-02 07:09:08.646 ERROR (MainThread) [custom_components.energidataservice.connectors.energidataservice] API returned error 500
2024-08-02 07:09:11.957 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: {('energidataservice', 'a777e883510f6496e63283338591e648'): 1518245.755121577}
2024-08-02 07:09:50.735 ERROR (MainThread) [custom_components.energidataservice.connectors.energidataservice] API returned error 500
2024-08-02 07:10:12.020 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: {('energidataservice', 'a777e883510f6496e63283338591e648'): 1518245.755121577}
2024-08-02 07:11:12.071 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: {('energidataservice', 'a777e883510f6496e63283338591e648'): 1518245.755121577}
2024-08-02 07:12:12.043 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Energi Data Service for energidataservice
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/energidataservice/__init__.py", line 54, in async_setup_entry
    result = await _setup(hass, entry)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/energidataservice/__init__.py", line 187, in _setup
    await api.async_get_tariffs()
  File "/config/custom_components/energidataservice/api.py", line 298, in async_get_tariffs
    self.tariff_data = await tariff.async_get_tariffs()
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/energidataservice/tariffs/energidataservice/__init__.py", line 59, in async_get_tariffs
    await self.async_get_system_tariffs()
  File "/config/custom_components/energidataservice/tariffs/energidataservice/__init__.py", line 165, in async_get_system_tariffs
    dataset = await self.async_call_api(query)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/async_retrying_ng/__init__.py", line 124, in wrapped
    ret = await ret
          ^^^^^^^^^
  File "/config/custom_components/energidataservice/tariffs/energidataservice/__init__.py", line 193, in async_call_api
    resp = await self.client.get(f"{BASE_URL}?{query}", headers=headers)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 608, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 976, in start
    message, payload = await protocol.read()  # type: ignore[union-attr]
                       ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/streams.py", line 640, in read
    await self._waiter
asyncio.exceptions.CancelledError: Global task timeout
2024-08-02 07:12:12.045 WARNING (MainThread) [homeassistant.bootstrap] Setup timed out for stage 2 waiting on set() - moving forward
2024-08-02 07:12:12.070 WARNING (MainThread) [homeassistant.helpers.frame] Detected that custom integration 'hacs' accesses hass.helpers.event. This is deprecated and will stop working in Home Assistant 2024.11, it should be updated to import functions used from event directly at custom_components/hacs/base.py, line 630: self.hass.helpers.event.async_track_time_interval(, please create a bug report at https://github.com/hacs/integration/issues
2024-08-02 07:12:50.345 WARNING (MainThread) [homeassistant.components.automation.sync_thermostats_first_floor] Sync thermostats first floor: Already running
2024-08-02 07:12:50.350 WARNING (MainThread) [homeassistant.components.automation.sync_thermostats_first_floor] Sync thermostats first floor: Already running
2024-08-02 07:54:53.373 WARNING (Thread-4) [pychromecast.socket_client] [65PUS8204/12(192.168.1.40):8009] Heartbeat timeout, resetting connection
2024-08-02 07:55:23.406 ERROR (Thread-4) [pychromecast.socket_client] [65PUS8204/12(192.168.1.40):8009] Failed to connect to service MDNSServiceInfo(name='TPM191E-4bcb5f92edfec9ebf34c9c679983388e._googlecast._tcp.local.'), retrying in 5.0s
2024-08-02 08:02:03.282 WARNING (Thread-4) [pychromecast.socket_client] [65PUS8204/12(192.168.1.40):8009] Heartbeat timeout, resetting connection
2024-08-02 08:02:33.311 ERROR (Thread-4) [pychromecast.socket_client] [65PUS8204/12(192.168.1.40):8009] Failed to connect to service MDNSServiceInfo(name='TPM191E-4bcb5f92edfec9ebf34c9c679983388e._googlecast._tcp.local.'), retrying in 5.0s
2024-08-02 08:04:59.295 ERROR (MainThread) [custom_components.energidataservice.tariffs.energidataservice] Error during API request: 500, message='Internal Server Error', url=URL('https://api.energidataservice.dk/dataset/DatahubPricelist?filter=%7B%22Note%22:%5B%22Elafgift%22,%22Systemtarif%22,%22Transmissions+nettarif%22%5D%7D&limit=500')
2024-08-02 08:07:46.612 ERROR (MainThread) [custom_components.energidataservice.tariffs.energidataservice] Error during API request: 500, message='Internal Server Error', url=URL('https://api.energidataservice.dk/dataset/DatahubPricelist?filter=%7B%22Note%22:%5B%22Elafgift%22,%22Systemtarif%22,%22Transmissions+nettarif%22%5D%7D&limit=500')
2024-08-02 08:08:58.778 ERROR (MainThread) [custom_components.energidataservice.tariffs.energidataservice] Error during API request: 500, message='Internal Server Error', url=URL('https://api.energidataservice.dk/dataset/DatahubPricelist?filter=%7B%22Note%22:%5B%22Elafgift%22,%22Systemtarif%22,%22Transmissions+nettarif%22%5D%7D&limit=500')
2024-08-02 08:10:37.729 ERROR (MainThread) [custom_components.energidataservice.connectors.energidataservice] API returned error 500
2024-08-02 08:11:00.725 ERROR (MainThread) [custom_components.energidataservice.tariffs.energidataservice] Error during API request: 500, message='Internal Server Error', url=URL('https://api.energidataservice.dk/dataset/DatahubPricelist?filter=%7B%22Note%22:%5B%22Elafgift%22,%22Systemtarif%22,%22Transmissions+nettarif%22%5D%7D&limit=500')
MTrab commented 4 months ago

Error 500 from the API indicates an API outage - nothing I can do about that, other than perhaps see if I somehow can make a better handling of such errors