Device_Tracker with Fritz!Box

Hi there,

since a few day I’ve set up a hassio-Server and now I’m getting into the system and the wide functionalities. My Fritz!Box should be used as a device_tracker to recognize our mobiles, so I’m able to switch the lights or alarm on/off based on the logged in mobiles.

my configuration.yaml looks like

device_tracker:
-platform: fritz
host: 192.168.178.1
track_new_devices: yes
user: “Username”
password: !secret fritz_password
interval_seconds: 10
consider_home: 180

I’ve tried different settings with/without username/password and other options.

Do you know where’s my problem? May you give me a hint?

Thank you guys.

What does the log file say about your config?
Maybe a stupid question, but did you think of the correct YAML formatting?

device_tracker:
  - platform: fritz
    host: 192.168.178.1
    track_new_devices: yes
    user: "Username"
    password: !secret fritz_password
    interval_seconds: 10
    consider_home: 180

instead of

device_tracker:
-platform: fritz
host: 192.168.178.1
track_new_devices: yes
user: "Username"
password: !secret fritz_password
interval_seconds: 10
consider_home: 180

Sorry, I don’t understand the editor of this forum, so wasn’t able to format it :smiley:

Is there a possibility to switch to html input?

Yes, I considered the correct YAML formatting. Which log do you mean - home-assistant.log or the log of hassbian?

You can use the buttons on the top of the reply window. Paste the YAML code, select it and press the “Preformatted text” button.
Check the home-assistant.log for errors on the device tracker. You read the warning on the Fritz device tracker page? Depending on which installation you have, you have to add some extra components. If you are on the Virtual Environment, switch to the right user and activate the virtual environment so the python component is installed at the right place.

Thank you!

There are no errors. Yeah I’ve read the warning, but I’m running it on a RPi, so shouldn’t be a problem, should it?

I am running it on a Rpi too, but in a virtual environment. All changes to Python have to be made within the venv.

Did HA create a file named known_devices.yaml? If so, what’s in there?

No, it is the provided hassio image, so I think it isn’t the venv.

There is a file named known_devices.yaml, but I think it was generated by nmap, because without nmap it is not possible to recognize device states!

Maybe you should try to remove the know_devices file so HA will create a new one, based on the Fritz Device Tracker. You don’t need both NMAP and the Fritz component unless you have a specific reason for using two device trackers.

I did delete it, but the device tracker with platfrom fritz does not generate a new one?!

With nmap it works like a charm, with fritz it doesn’t!

I don’t know anything about Fritz… Did you try a completely stripped config like:

device_tracker:
  - platform: fritz

According to the docs about the Fritz device tracker all variables are optional.

Doesn’t work either!

I’m working with Fritz!Box 7490 and FW 6.83, if it matters.

On the standalone RPi-Image I’m not able to get anything from apt or pip.

Hi,
I have the same box and I’m using the following config:

device_tracker:
  - platform: fritz
    host: 192.168.178.1
    track_new_devices: False
    consider_home: 300

track new devices is currently set to false because I’ve already set up the devices I want to track in the known_devices.yaml.
This works for me in a dockerized Home assistant (not hass.io).

Note: if you have several fritz boxes, you have to add a device tracker config for each box. Since they share the known_devices file it does not generate duplicates.

Jochen

Seems working, but I’m getting an error.

2017-12-29 16:47:33 INFO (Thread-6) [homeassistant.components.device_tracker.fritz] Successfully connected to FRITZ!Box 749                                        0 (UI)
2017-12-29 16:47:33 INFO (Thread-6) [homeassistant.components.device_tracker.fritz] Scanning
2017-12-29 16:47:33 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform fritz
  File "/srv/homeassistant/lib/python3.5/site-packages/fritzconnection/fritzconnection.py", line 376, in _get_action
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/fritz.py", line 31, in get_s                                        canner
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/fritz.py", line 64, in __ini                                        t__
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/fritz.py", line 93, in _upda                                        te_info
    self.last_results = self.fritz_box.get_hosts_info()
  File "/srv/homeassistant/lib/python3.5/site-packages/fritzconnection/fritzhosts.py", line 77, in get_hosts_info
  File "/srv/homeassistant/lib/python3.5/site-packages/fritzconnection/fritzhosts.py", line 59, in host_numbers
  File "/srv/homeassistant/lib/python3.5/site-packages/fritzconnection/fritzhosts.py", line 51, in action
  File "/srv/homeassistant/lib/python3.5/site-packages/fritzconnection/fritzconnection.py", line 405, in call_action
  File "/srv/homeassistant/lib/python3.5/site-packages/fritzconnection/fritzconnection.py", line 378, in _get_action
fritzconnection.fritzconnection.ServiceError: Unknown Service: Hosts:1

Hi,
I have a Fritz!Box 7490 and FW 6.83.
I don’t understand what I musto to configure to use fritzbox in Home Assistant.
I added this in configuration.yaml:

device_tracker:

  • platform: fritz
    host: 192.168.178.1
    password: **************
    consider_home: 300
    new_device_defaults:
    track_new_devices: true

The configuration control is ok.
But I don’t see nothing in home assistant home page.
Where I wrong ?
I must to configure other files ?

No, that looks okay (if you got the formatting right). For me it even works without the password even though I have user logins configured.

Here’s my config snippet:

device_tracker:
  - platform: fritz
    host: 192.168.178.1
    consider_home: 300
    new_device_defaults:
      track_new_devices: False
      hide_if_away: False

Have you checked whether you have a “known_devices.yaml” file in your config folder?
Maybe everything happened already but your default values were off.

You should see entries in there with all the active devices from the fritzbox. For the ones you want to see in the HA UI you have to set “track” to true.

Hope this helps

Hello,
I think I have the same problem has Flipper
I have used all sorts of configurations in configuration.yaml, but nothing works. I have always the same results in the logs files

2018-07-27 20:05:10 INFO (MainThread) [homeassistant.components.device_tracker] Setting up device_tracker.fritz
2018-07-27 20:05:10 INFO (Thread-13) [homeassistant.components.device_tracker.fritz] Successfully connected to FRITZ!Box Fon WLAN 7390
2018-07-27 20:05:10 INFO (Thread-13) [homeassistant.components.device_tracker.fritz] Scanning
2018-07-27 20:05:12 INFO (Thread-5) [homeassistant.components.device_tracker.fritz] Scanning
2018-07-27 20:05:24 INFO (Thread-18) [homeassistant.components.device_tracker.fritz] Scanning
2018-07-27 20:05:37 INFO (Thread-6) [homeassistant.components.device_tracker.fritz] Scanning
2018-07-27 20:05:50 INFO (Thread-19) [homeassistant.components.device_tracker.fritz] Scanning
2018-07-27 20:06:03 INFO (Thread-4) [homeassistant.components.device_tracker.fritz] Scanning
2018-07-27 20:06:16 INFO (Thread-11) [homeassistant.components.device_tracker.fritz] Scanning

absolutely nothing else happens, nothing in know_devices.yaml nothing anywhere.
Any suggestions?

Thanks,

Hi

I found this as I’m trying to set up trackers in Hassbian, basically so it knows when I’m home based on my mobile connecting to my Fritz!box 7590.

I’ve setup a user in Fritz called MadMax1412 and given it a password, although when I go to the IP address I’m only ever prompted for a password (no username visible or able to be selected) and for that I use the one that came with the box.

Anyway, my config in configuration.yaml is:

device_tracker:
  - platform: fritz
    host: 192.168.178.1
    user: MadMax1412
    password: not_telling

But on restarting, I get the following errors:

Error setting up platform fritz

Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/init.py”, line 176, in async_setup_platform
platform.get_scanner, hass, {DOMAIN: p_config})
File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
future.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/fritz.py”, line 31, in get_scanner
scanner = FritzBoxScanner(config[DOMAIN])
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/fritz.py”, line 47, in init
import fritzconnection as fc
File “/srv/homeassistant/lib/python3.5/site-packages/fritzconnection/init.py”, line 6, in
from .fritzconnection import (
File “/srv/homeassistant/lib/python3.5/site-packages/fritzconnection/fritzconnection.py”, line 39, in
from lxml import etree
ImportError: libxslt.so.1: cannot open shared object file: No such file or directory

And:

Unable to load /home/homeassistant/.homeassistant/known_devices.yaml: Config file not found: /home/homeassistant/.homeassistant/known_devices.yaml

Needless to say with the second one, there’s no known_devices.yaml file but from my research, it appears that there wouldn’t be until you set up trackers and it’s successfully scanned your router (which the first error message implies it can’t).

So, if when I go to 192.168.178.1 I’m only prompted for the password, what would that username be?

EDIT: Based on this page should I install the python 3 package? I’m running Hassbian on a Raspberry Pi 3+

Thanks in advance.

Well, it appears that it crashes directly when importing the first library (last line of first log).
It mentions “libxslt”, “lxml” and so on which are the packages mentioned in the docs. So, yes, install those.
You can only omit installing them if you’re running HA on docker or hass.io as it seems.

Secondly, you do not need user/pass for device tracking. So, at least for this purpose you don’t have to give up your admin password. Otherrwise you’d probably have to switch the Fritzbox authentication mechanism to username/password instead of only having a password. That way you can also create more users that have different rights (settings, nas, …).

The known_devices file is created once HA gets the list of devices from the fritzbox so don’t worry about that one for now.

Thanks for the confirmation. I have installed it and rebooted and now my HA front end shows all the devices it knows about and the known_devices.yaml file has been created.

Now I’ve just got to learn how they can track their devices outside of their network. I was watching videos where he has his icons (indicating his presence) change from Home, Work and Away. Looks cool.

Thanks