core: AVM FRITZ!Box Tools UnboundLocalError: local variable 'topology' referenced before assignment

The problem

Unexpected error fetching fritz-192.168.x.x-coordinator data: local variable ‘topology’ referenced before assignment

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/components/fritz/common.py", line 231, in _async_update_data
    await self.async_scan_devices()
  File "/usr/src/homeassistant/homeassistant/components/fritz/common.py", line 322, in async_scan_devices
    await self.hass.async_add_executor_job(self.scan_devices, now)
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/fritz/common.py", line 371, in scan_devices
    for node in topology["nodes"]:
UnboundLocalError: local variable 'topology' referenced before assignment

What version of Home Assistant Core has the issue?

2022.2.7

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

AVM FRITZ!Box Tools

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

check your code line

has topology attr nodes?

https://github.com/home-assistant/core/blob/b42676370c38740d9f865892bf4f6f07a7ad9ba8/homeassistant/components/fritz/common.py#L375

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 16 (5 by maintainers)

Most upvoted comments

After @felix63 tested the code, I created a PR to fix the error and make the integration again usable.

NOTE: Device trackers are completely missing; we will add logic for non mesh Fritzbox in the next days.

Simone