Fritz detects only one device

I tried to enable the Fritz component in the latest HA version:

device_tracker:
  - platform: fritz
    track_new_devices: yes

it created the known_devices.yaml file but it contains only one device (my desktop pc!).
In my home I have several other devices connected: a couple of Android phones, and some other PC (though I’m not interested in them).

From the doc page I cannot understand how to manually “trigger” the discovery of new devices.

“track_new_devices: yes” is not a valid option for this device. The documents make no mention of this parameter. I also confirmed this by looking at the source code. Removing that line may cause it to grab the rest of the devices on startup.

Also, side question, are all your devices hardwired or connected over wifi?

mmm… because I plan to have some other device trackers I read the general doc here. I read:

The following optional parameters can be used with any platform. However device tracker will only look for global settings under the configuration of the first configured platform

I understand I have to put all optional parameters in the first device trackers, no matter if it support them or not. Anyway, I’m going to test without that line but please note I get a valid configuration.

I have some devices wired and others connected via wifi.

So, the fritz box inherits from DeviceScanner, not DeviceTracker. Device tracker appears to have that parameter but device scanner appears to not have that parameter. If you aren’t getting a config error in the log, leave it in because it’s not hurting anything.

The only reason I asked about the wired/wireless is my router only outputs wireless devices, not wired.

Anyways, the only service I see for device tracker is: device_tracker.see. I can’t find any documentation on it. Here is the documentation on general device trackers. Maybe this will help you out:

The link you posted is exactly the same I did in my previous one :slight_smile: so I read that document.
I don’t understand how you can say fritz inherits DeviceScanner instead of DeviceTracker when the documentation (and the configuration) put it into a DeviceTracker section. Please note I’m not saying you’re wrong! I’m just curious how you can infer this from the docs!

Anyway my fritz discovered only one device… a wired one by the way!

My goal is just to know whether a device is connected to my wifi to guess if (the owner) is at home.

I didn’t infer it from the doc’s, I read the source code:

class FritzBoxScanner(DeviceScanner): #<-------- DEVICE SCANNER
    """This class queries a FRITZ!Box router."""

    def __init__(self, config):
        """Initialize the scanner."""
        self.last_results = []
        self.host = config[CONF_HOST]
        self.username = config[CONF_USERNAME]
        self.password = config[CONF_PASSWORD]
        self.success_init = True
        ..... etc

I then looked up that class in the __init.py and found that it ignores the following parameter:

CONF_TRACK_NEW = 'track_new_devices'
..... etc....
NEW_DEVICE_DEFAULTS_SCHEMA = vol.Any(None, vol.Schema({
    vol.Optional(CONF_TRACK_NEW, default=DEFAULT_TRACK_NEW): cv.boolean,
    vol.Optional(CONF_AWAY_HIDE, default=DEFAULT_AWAY_HIDE): cv.boolean,
}))
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_SCAN_INTERVAL): cv.time_period,
    vol.Optional(CONF_TRACK_NEW): cv.boolean,
    vol.Optional(CONF_CONSIDER_HOME,
                 default=DEFAULT_CONSIDER_HOME): vol.All(
                     cv.time_period, cv.positive_timedelta),
    vol.Optional(CONF_NEW_DEVICE_DEFAULTS,
                 default={}): NEW_DEVICE_DEFAULTS_SCHEMA
.... etc ...

class DeviceScanner(object):
    """Device scanner object."""

    hass = None  # type: HomeAssistantType

    def scan_devices(self) -> List[str]:
        """Scan for devices."""
        raise NotImplementedError()

    def async_scan_devices(self) -> Any:
        """Scan for devices.
        This method must be run in the event loop and returns a coroutine.
        """
        return self.hass.async_add_job(self.scan_devices)

    def get_device_name(self, device: str) -> str:
        """Get the name of a device."""
        raise NotImplementedError()

    def async_get_device_name(self, device: str) -> Any:
        """Get the name of a device.
        This method must be run in the event loop and returns a coroutine.
        """
        return self.hass.async_add_job(self.get_device_name, device)

Notice how the device_scanner does not inherit from DeviceTracker.

Anyways, there are some areas of the code that are a mystery to me so I could have read it wrong. Either way, it appears as if the config accepts the parameter but the device does not use it.

Anyways back to your issue at hand, it doesn’t look like there is a way to force your router to refresh and get new known devices. the service device_tracker.see appears to only update devices that you’ve already collected.

You may want to turn on debugging for logger to see what information goes to the log during start up. With that information, we can see where the component is failing. We need to rule out 2 possibilities: failure of the component or failure of your device.