core: Speedtest.net goes unavailable and does not recover

The problem

Sensors in the speedtest.net integration appear to go unavailable and do not recover, and get stuck. While this home assistant may see temporary network issues, it generally appears to be healthy and other integrations that rely on cloud are working OK. The issue seems to be about being unable to recover once broken.

I attempted to enable debug logging, and reloaded the integration, then noticed it appears that the integration may throw a CancelledError which ends up not being handled correctly by the update coordinator. It does not set “success” correctly. I think because this exception is not handled right, so it may get stuck? See details below.

This may be similar to other reports like #80290 and #85375 however those reports may be more generic about general unavailability issues. I’d like to focus this on the fact that it gets stuck since I haven’t seen others report this specific stack trace before, however, the root cause may be the same.

What version of Home Assistant Core has the issue?

Home Assistant 2023.8.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Speedtest.net

Link to integration documentation on our website

https://www.home-assistant.io/integrations/speedtestdotnet/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2023-09-09 11:31:06.617 DEBUG (SyncWorker_54) [homeassistant.components.speedtestdotnet.coordinator] Executing speedtest.net speed test with server_id: 33893
2023-09-09 11:31:17.369 DEBUG (MainThread) [homeassistant.components.speedtestdotnet.coordinator] Finished fetching speedtestdotnet data in 11.332 seconds (success: True)
2023-09-09 11:31:17.369 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry SpeedTest for speedtestdotnet
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 388, in async_setup
result = await component.async_setup_entry(hass, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/speedtestdotnet/__init__.py", line 35, in async_setup_entry
await coordinator.async_config_entry_first_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 251, in async_config_entry_first_refresh
await self._async_refresh(
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/speedtestdotnet/coordinator.py", line 77, in _async_update_data
return await self.hass.async_add_executor_job(self.update_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
asyncio.exceptions.CancelledError: aiohttp connection lost

Additional information

The sensors become unavailable and do not recover:

Screenshot 2023-09-09 at 11 43 42 AM

About this issue

  • Original URL
  • State: open
  • Created 10 months ago
  • Reactions: 8
  • Comments: 16 (1 by maintainers)

Most upvoted comments

@cinghialino The automation which works for me is:

alias: Speedtest integration reload when unavailable
description: >-
  Force speedtest when download unavailable for several minutes. Fix for
  accidental failure of the integration.
trigger:
  - platform: state
    entity_id:
      - sensor.speedtest_download
    to: unavailable
    for:
      hours: 0
      minutes: 5
      seconds: 0
condition: []
action:
  - service: homeassistant.update_entity
    data: {}
    target:
      entity_id: sensor.speedtest_download
mode: single

I’d suggest taking the workaround discussion to the community forums, and keep this focused on resolving the root cause issue.

I have done the same, I inject a time stamp every 5 mins, if the Entity is ‘unavailable’ I reload it

image

I have had the same issue. I ended up making an automation that reloads the speed test integration when its status becomes unavailable. Been working like a charm since.