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

AVM FRITZ!SmartHome must reconfigured every day #94768

Closed
lgusewski opened this issue Jun 17, 2023 · 11 comments · Fixed by #97985
Closed

AVM FRITZ!SmartHome must reconfigured every day #94768

lgusewski opened this issue Jun 17, 2023 · 11 comments · Fixed by #97985
Assignees
Labels
integration: fritzbox problem in device Issue lies within the device, such firmware, software, or user customization/config

Comments

@lgusewski
Copy link

The problem

I use Home Asssistant 2023.6.2 with FRITZ!SmartHome. Every day I got the message, that the integration must be reconfigured. I had two options. Reconfiguring with the password for the Home Assistant-User or simply restarting Home Assistant. Both methods help to get the integration working agin.

What version of Home Assistant Core has the issue?

core-2023.6.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

AVM FRITZ!SmartHome

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2023-06-17 05:52:03.469 ERROR (SyncWorker_7) [pyfritzhome.fritzhome] 404 Client Error: Not Found for url: http://fritz.box/login_sid.lua
2023-06-17 05:52:03.482 ERROR (MainThread) [homeassistant.components.fritzbox] Authentication failed while fetching a40d8c135e98c2bcfbab1bd3039e308b data: login for user="home-assistant" failed

Additional information

No response

@home-assistant
Copy link

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

Code owner commands

Code owners of fritzbox 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 fritzbox Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


fritzbox documentation
fritzbox source
(message by IssueLinks)

@mib1185
Copy link
Contributor

mib1185 commented Jun 17, 2023

Hi @lgusewski

please enable debug logging, restart HA and provide the home-assistant.log after reconfiguration is prompted again.
To do so add the following to your configuration.yaml:

logger:
  default: info
  logs:
    homeassistant.components.fritzbox: debug
    pyfritzhome: 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.

@mib1185
Copy link
Contributor

mib1185 commented Jun 17, 2023

Also please check the event logs of the FritzBox itself

@lgusewski
Copy link
Author

I activated the debug logging and wait now. The check inside the FRITZ!Box log have no info in the relevant time, the error was. As information, I have a 7590 with FRITZ!OS 7.55. Perhaps you look here also for some details about my system.

@lgusewski
Copy link
Author

So today morning I had the problem again. First I thought it has something to do with my backup strategy, because HAOS is running under proxmox and at five a.m. I stop the machine, backup and restart. Shortly after this, at 5:04 a.m. the connection was broken. But this backup was only made on Sunday morning. This explains not the problems on normal workdays and the error message, I found in the log was also not different from the initial message I posted before.

I made a little anonymization inside the files, but beside it is the original config and log from today.

config_entry-fritzbox-a40d8c135e98c2bcfbab1bd3039e308b.json.txt
home-assistant.log

@mib1185
Copy link
Contributor

mib1185 commented Jul 12, 2023

this is the corresponding error message:

2023-06-18 05:04:21.337 ERROR (SyncWorker_2) [pyfritzhome.fritzhome] 404 Client Error: Not Found for url: http://fritz.box/login_sid.lua

it means that the path /login_sid.lua could not be found at http://fritz.box - possible reasons (list may be incomplete):

  • issue in the Fritzbox itself
  • issue with DNS, so fritz.box is not resolved correctly to the IP address of the Fritzbox

@mib1185 mib1185 added the problem in device Issue lies within the device, such firmware, software, or user customization/config label Jul 12, 2023
@lgusewski
Copy link
Author

What it means is clear, but not the reason. I could not find I time, to reproduce the problem. The minimum ist once a day. Today around 1 am. Mostly in the time from 5 am to 6 am. My network based on Unifi and network segmentation. The Router and Home Assistant are in the network segment 192.168.1.0/24 and the FRITZ!Box in the segment 192.168.3.0/24. I also run since years a Synology DiskStation with their DNS-Server. The domain fritz.box is configured on the Synology. Home Assistant is configured to use this DNS-Server. Additional my main system is openHAB and it uses the same network structure. Today I found around 1 am the same login error messages from openHAB. But openHAB had no problems to reconnect. The whole issue was less than 20 seconds.
So it seems you are right, that this has something to do with the device. But the question is, why stops the Add-On (or Home Assistant) to reconnect? And is there a hidden way I did not found to change the configuration from a domain to IP without deleting the Add-On the reconfigure it?

@mib1185
Copy link
Contributor

mib1185 commented Jul 15, 2023

The fritzbox (AVM Fritz!Smarthome) integration polls every 30s the Fritz!Box. If there are any connection issues during this poll, HA will just retry later. But if there are any http errors, HA assumes that the box was restarted so we need to re-login. If this re-login fails, it is assumed that the credentials has changed and needs to be re-configured.

First of all, create a backup before proceed with the following!

from my point of view, you have 3 options

  1. fix the DNS issue in your environment
    this needs to be resolved by your own

  2. re-install the "AVM Fritz!Smarthome" integration
    as long as you did not have changed the entity ids, you should be able to just delete and add the integration again, which preserves the historical data and the entity ids, those they are the same afterwards

  3. (most advanced method) replace the hostname with the ip in the hidden HA core config
    this is absolutely not recommended, therefore you are on your own when doing this!
    you will find the configuration of all integrations in config/.storage/core.config_entries
    to be on the safe side, editing this file should be done, when HA is not running

@lgusewski
Copy link
Author

lgusewski commented Aug 6, 2023

Answer to:

  1. I had and have no DNS problems. I checked this. An additional test was to use the dnsmasq Add-On from Home Assistant to have a local cache. The result was, your integration goes every restart in reconfiguration mode. I think, dnsmasq could be started to late and the first connection have no target. So the effect was again a necessary reconfiguration.
  2. I had reinstalled the integration before. I did not help.
  3. I am confused that a change from a configuration is not recommended under Home Assistant. I had a similar feedback for editing passwords (in this case for the adguard home integration).

So there is once a day a problem with my FRITZ!Box. The problem time was round about 10 to 20 seconds, time is different. The difference between the Home Assistant integration and openHAB is, openHAB reconnect, Home Assistant give up.

So this is, what I had also done. I give up and shutdown the VM with my Home Assistant.

@Elarion245
Copy link

Elarion245 commented Aug 8, 2023

I am suffering from the same issue since about a month or so. Since then I have upgraded HA from 2023.6.X to 2023.8.X and also my Fritzbox 7490 has received an update to the final 7.56 firmware (used to be on the beta channel before).

I am using HA through LAN, but I also have WLAN connected. Could it be that this is causing an issue?

Among many entries, I find in my log file:
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.178.54', port=49000): Max retries exceeded with url: /upnp/control/wlanconfig3 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff83acf450>: Failed to establish a new connection: [Errno 113] Host is unreachable'))
The LAN is using the 52 IP, whereas the WIFI was so far not assigned to a static IP.

Apart from that, I also have timeouts on the router at the time around which the connection was apparently lost:
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='192.168.178.1', port=49000): Read timed out. (read timeout=60.0)

I wonder if there is any possibility of a workaround. Even if the box is restarted, is it possible to avoid the manual reconfiguration, e.g. by defining the credentials in the configuration.yaml?

Below an output of the Fritzbox logs. The HA integration failed some time around 18:35. I am surprised that there is nothing in the Fritzbox logs around this time:
grafik

For yesterday and many days before I find this interesting message, which indicates that the session ID has expired:
grafik

@Elarion245
Copy link

I hope this PR will be integrated soon.
It seems to be better here when only using Lan...

@github-actions github-actions bot locked and limited conversation to collaborators Sep 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
integration: fritzbox problem in device Issue lies within the device, such firmware, software, or user customization/config
Projects
None yet
3 participants