home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.14k stars 29.82k forks source link

FRITZ!Box WLAN 3370 has don't `get host info` #97543

Closed Ludy87 closed 1 year ago

Ludy87 commented 1 year ago

The problem

Logger: homeassistant.components.fritz.common
Source: components/fritz/common.py:401
Integration: AVM FRITZ!Box Tools (documentation, issues)
First occurred: 20:49:24 (1 occurrences)
Last logged: 20:49:24

Unexpected error fetching fritz-192.168.0.17-coordinator data: Error refreshing hosts info
Traceback (most recent call last):
  File "/workspaces/core/homeassistant/components/fritz/common.py", line 396, in _async_update_hosts_info
    return await self.hass.async_add_executor_job(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/core/homeassistant/components/fritz/fritzconnection/src/fritzconnection/lib/fritzhosts.py", line 204, in get_hosts_attributes
    result = self._action("X_AVM-DE_GetHostListPath")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/core/homeassistant/components/fritz/fritzconnection/src/fritzconnection/lib/fritzhosts.py", line 36, in _action
    return self.fc.call_action(SERVICE, actionname, arguments=arguments, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/core/homeassistant/components/fritz/fritzconnection/src/fritzconnection/core/fritzconnection.py", line 424, in call_action
    return self.soaper.execute(service, action_name, arguments)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/core/homeassistant/components/fritz/fritzconnection/src/fritzconnection/core/soaper.py", line 286, in execute
    return handle_response(response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/core/homeassistant/components/fritz/fritzconnection/src/fritzconnection/core/soaper.py", line 268, in handle_response
    raise_fritzconnection_error(response)
  File "/workspaces/core/homeassistant/components/fritz/fritzconnection/src/fritzconnection/core/soaper.py", line 191, in raise_fritzconnection_error
    raise exception(message)
homeassistant.components.fritz.fritzconnection.src.fritzconnection.core.exceptions.FritzActionError: UPnPError: 
errorCode: 401
errorDescription: Invalid Action

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/workspaces/core/homeassistant/helpers/update_coordinator.py", line 293, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/core/homeassistant/components/fritz/common.py", line 317, in _async_update_data
    await self.async_scan_devices()
  File "/workspaces/core/homeassistant/components/fritz/common.py", line 478, in async_scan_devices
    for host in await self._async_update_hosts_info():
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/core/homeassistant/components/fritz/common.py", line 401, in _async_update_hosts_info
    raise HomeAssistantError("Error refreshing hosts info") from ex
homeassistant.exceptions.HomeAssistantError: Error refreshing hosts info

What version of Home Assistant Core has the issue?

core-2023.9.0.dev0

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

fritz

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

https://github.com/home-assistant/core/blob/121fc7778d2573e833d36ac2a331f5f12a24223c/homeassistant/components/fritz/common.py#L390-L392

the problem is the exception that is thrown here. If I comment out this part, then the integration runs "without" errors.

I don't (yet) understand why UPnPError occurs as an error, it may be because the Fritzbox is only used as a layer 2 router?!

If further information is needed, please let me know.

image

home-assistant[bot] commented 1 year ago

Hey there @mammuth, @aarondavidschneider, @chemelli74, @mib1185, mind taking a look at this issue as it has been labeled with an integration (fritz) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `fritz` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign fritz` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


fritz documentation fritz source (message by IssueLinks)

mib1185 commented 1 year ago

Hi @Ludy87

in which circumstances does this error occur? And which FritzOS version is your box running on? Also, please enable debug logging, restart HA and provide the home-assistant.log after this error appears again. To do so add the following to your configuration.yaml:

logger:
  default: info
  logs:
    homeassistant.components.fritz: debug

Further if possible please download and provide the diagnostics data for this integration.

Note: it is better to drag the log into the comment (which will add it as an attachment) and not copy paste as it is hard to read logs in GitHub.

Ludy87 commented 1 year ago

FRITZ!OS:06.55

it already occurs when setting up, so there is no diagnostic protocol

home-assistant_2023-07-31T20-08-07.250Z.log

raise disable: config_entry-fritz-e0628612d2cb08d0ee4fb91329b5e4ae.json.txt

Ludy87 commented 1 year ago

another error occurs, which must be dealt with in the Lib. https://github.com/kbr/fritzconnection/pull/191

mib1185 commented 1 year ago

I guess FritzOS 6.55 is to old and does not support the X_AVM-DE_GetHostListPath action via tr64, but the fritz integrations has been reworked to rely on this GetHostListPath to obtain the connected client devices (will be delivered with 2023.8). This means, we need to bring back the former/old mechanic as fallback when the FritzBox does not support the X_AVM-DE_GetHostListPath action. Hopefully I'll get it managed this week to re-implement the old mechanic as fallback

Ludy87 commented 1 year ago

Is there also the possibility that not only the guest WiFi is created as a QR code, but also the "normal" WiFi?

mib1185 commented 1 year ago

Is there also the possibility that not only the guest WiFi is created as a QR code, but also the "normal" WiFi?

it is on my list, but did not find the time, yet. maybe in the next weeks/months 🤞

mib1185 commented 1 year ago

@Ludy87 just one further question - which permissions does the used user have? are the app permissions granted to this user?

Ludy87 commented 1 year ago

There is no app permission.

Screenshot_2023-08-02-09-46-48-999_com android chrome

ferdyvi commented 1 year ago

Hi, I confirm I have the same issue with FRITZ!OS 7.56. I confirm also the removing exceptions on line 390-392 solves the problem

mib1185 commented 1 year ago

Hi @ferdyvi which FritzBox/Repeater model do you use?

ferdyvi commented 1 year ago

Hi @ferdyvi which FritzBox/Repeater model do you use?

I have modem router fritz box 7590

mib1185 commented 1 year ago

@ferdyvi i think you encounter a different issue. please open an new issue report and provide as much information as possible. Also please already add debug information as described in https://github.com/home-assistant/core/issues/97543#issuecomment-1659023634

ferdyvi commented 1 year ago

Why do you think it is a different issue? I have the same error "Error refreshing hosts info", and the workaround is the same. This bug is present in 2023.8.0

mib1185 commented 1 year ago

because you have a quite new 7590 running on FRITZ!OS 7.56 ... the issue here is based on an older FritzOS version. Further the Error refreshing hosts info is the resultung error, but the causing error here is:

homeassistant.components.fritz.fritzconnection.src.fritzconnection.core.exceptions.FritzActionError: UPnPError: 
errorCode: 401
errorDescription: Invalid Action
mib1185 commented 1 year ago

Hi @Ludy87 would be great if you could test the linked PR. thx 👍

Ludy87 commented 1 year ago

Thanks for your trouble, according to my assessment and observation, the error has been fixed.

ferdyvi commented 1 year ago

Hi, I still get the error "Error refreshing hosts info" and again the solution is to delete the raise exception as indicated by the first user

mib1185 commented 1 year ago

@ferdyvi as I wrote before, please open an own issue report and provide as much information and debug logs as possible

ferdyvi commented 1 year ago

Ok I will open a separate issue, even if the solution was already present and here

chemelli74 commented 1 year ago

Ok I will open a separate issue, even if the solution was already present and here

The one provided, is not a solution but a workaround ;-)

Simone