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

AttributeError: 'async_timeout' does not have attribute 'TimeoutError' in Cloudflare Tunnel Monitor integration #18

Open
taifunk opened this issue Nov 12, 2024 · 1 comment

Comments

@taifunk
Copy link

taifunk commented Nov 12, 2024

Problem Description:

After updating Home Assistant to version 2024.11.0, an error occurs in the Cloudflare Tunnel Monitor integration. The following error message appears in the logs.

Steps to Reproduce the Issue:

Updated Home Assistant to version 2024.11.0.
Restarted Home Assistant.
An error message appears in the logs related to the Cloudflare Tunnel Monitor integration.
Expected Result:

The integration works without errors and correctly monitors the Cloudflare tunnel.

Actual Result:

The integration does not work, and an AttributeError appears in the logs.

Logs:


Traceback (most recent call last):
  File "/config/custom_components/cloudflare_tunnel_monitor/sensor.py", line 46, in fetch_tunnels
    raise UpdateFailed(f"Error fetching Cloudflare tunnels: {response.status}, {response.reason}")
homeassistant.helpers.update_coordinator.UpdateFailed: Error fetching Cloudflare tunnels: 500, Internal Server Error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 382, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 279, in _async_update_data
    return await self.update_method()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/cloudflare_tunnel_monitor/sensor.py", line 197, in async_update_data
    new_data = await fetch_tunnels(api_key, account_id, hass, config_entry.entry_id)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/cloudflare_tunnel_monitor/sensor.py", line 50, in fetch_tunnels
    except async_timeout.TimeoutError:
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'async_timeout' has no attribute 'TimeoutError'

Environment Information:

Home Assistant version: 2024.11.0
Cloudflare Tunnel Monitor integration version: 5.2.1
Operating System: Home Assistant OS 13.2

Additional Information:

It seems that in version 4.0.0 of the async_timeout module, TimeoutError has been removed. Modifying the exception handling in the sensor.py file on line 50 as follows solves the problem in my case:

Original code:

except async_timeout.TimeoutError:

Modified code:

import asyncio

...

except asyncio.TimeoutError:

Would it be possible to include this fix in the integration?

Thank you in advance for your help!

@taifunk
Copy link
Author

taifunk commented Nov 25, 2024

#19 Pull request created

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant