Fritz! Presence Detection fails after Fritzbox reboot

Hi,

When my AVM Fritzbox reboots the Presence Detection Module in HA is no longer working. All devices are marked as “not_home” and I get a recurring error message in the Log:

Updating device list from fritz took longer than the scheduled scan interval 0:00:12
10:08 PM components/device_tracker/__init__.py (WARNING)

So it seems like the component lost the connection to the Box and is not able (or is not even trying?) to reconnect. When I restart HA it works again.

This is especially annoying when my provider decides to update my box at night and my Wakeup trigger is not running in the morning because HA thinks nobody is home.

Has anyone experienced this problem and has maybe an idea how to fix this?

2 Likes

I’m observing the same problem.
Restarting the Fritzbox cures it for a little while, but eventually it comes back.
I have a huge number of devices connected, and I suspect that the time to collect the status (even if it only detects the first 15) is too long.
I tried - from a virtualenv where I used to run HA (now moved to hassio) to query the FB the same way the component does

(homeassistant) homeassistant@jarvis:~ $ fritzhosts -p XXXpasswordYYY

and it does not take 12 seconds. But still, it takes a while.
I’ll be looking at the code now to see if this is configurable or changeable and then potentially raise an issue on github (or piggy back on similar ones)

I tried to set

interval_seconds: 25

to the fritzbox config, and for now there are no error messages (but I have not rebooted the FB, but in my experience, restarting HA was not enough)

But while I was there, I noticed that my config still does not contain the password, which seems to have been mandatory since a few updates (and running fritzhosts from command line does not work without password).
It’s curious, because it works without it, in HA.

I am only changing the timeout now, to see if it helps, and eventually I’ll add the password as well.

I didn’t know about the interval_second option. I set it to 20 and the message is not showing up in the logs anymore. I got > 20 devices in my network so maybe that was the issue.

I still have to test again what happens on a Reboot of the Fritzbox.

For username/pw I also don’t have anything set, maybe that’s related to the Fritz OS Version? I have a 6490 on Version 06.65 (it’s provider bound, so no chance to update manually). (It would be reasonable to require credentials for such information)

It has not failed for me either. And I did not add the password (you are correct, it’s a future version - not available for me either - that requires it)
Case closed it seems.

I just found out why HA works without username/pw and fritzhost standalone crashes.

Actually there is a pw defined in HA in the component

So this works:

time fritzhosts -p admin
FritzHosts:
version:            0.6.2
model:              FRITZ!Box 6490 Cable (kdg)
ip:                 169.254.1.1

List of registered hosts:

  n: ip              name                       mac                 status

  0: <redacted>
...
 58: <redacted>

fritzhosts -p admin  4.21s user 0.12s system 18% cpu 23.298 total

So 23.3 seconds for 58 hosts.

I’ll keep an eye on that, maybe that would make sense to put into the documentation.

There is button to remove all devices from the Fritzbox with no specific settings. So this cleans out all the old devices which where last in the network months ago.

I removed all those historical devices from my box. There are now 18 devices on the net and the update time is down to about 8 seconds. So each entry costs about 0.4 seconds update time.

Coming back to my initial problem: When I reboot my box my iPhone is recognized pretty fast again. But of course it’s currently more or less active. I am suspecting this issue might be related to the phone saving power at night and not trying to reconnect to the wifi once it was disconnected due to the reboot.

The same is (still) happening on 0.80.0 when the FritzBox is rebooted. Restarting home assistant service usually fixes it.

WARNING (MainThread) [homeassistant.components.device_tracker] Updating device list from fritz took longer than the scheduled scan interval 0:02:00

platform fritz is using “interval_seconds: 120” and scanning takes less than 10s (fritzhosts -p admin).

1 Like

I’m also having similar issues with 0.86.2 (docker) I’m not sure if it is related to a fritzbox reboot. Sometimes when the error occurs and I reboot Home assistant I get this message during boot:

home-assistant   | 2019-01-27 11:11:29 ERROR (SyncWorker_1) [homeassistant.components.device_tracker.fritz] Failed to establish connection to FRITZ!Box with IP: 169.254.1.1
home-assistant   | 2019-01-27 11:11:29 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform fritz

which is kind of weird because pinging the ip will work just fine and the same is true for opening the fritzbox web interface with said IP. Can it be related to a (new) fritzbox firmware? I’m using FRITZ!OS:07.01 with model 7581

Also, for completeness. The config on home assistant is:

platform: fritz
new_device_defaults:
  track_new_devices: false

It seems the default IP address for the fritz box (169.254.1.1) doesn’t work inside the docker container (anymore) When I assign a specific host in my config (i.e. host: 192.168.1.1) it seems to work for me

I haven’t tested this with a non-docker hass instance

Note: I’m using network: host in my docker-compose file