Core: No way to set custom device tracking options for mikrotik hub

Created on 8 Sep 2019  路  15Comments  路  Source: home-assistant/core

Home Assistant release with the issue:
0.98.4

Last working Home Assistant release (if known):
0.97.2

Component/platform:
https://www.home-assistant.io/components/mikrotik/

Description of problem:
Before 0.98.0 it was possible to set consider_home, interval_seconds and other options from https://www.home-assistant.io/components/device_tracker/ page. After PR #25664 it's now impossible. Even if it's possible, I don't see any documentation. device_tracker docs say nothing about config for separate components. mikrotik docs say nothing about these options too. Even more, they don't describe track_devices option, but use it in the example below 馃槕.

@slackr31337 can you reply?

This issue was already mentioned in https://github.com/home-assistant/home-assistant/issues/25772#issuecomment-526764264.

What I tried:

    1.
mikrotik:
  - host: 192.168.0.1
    username: root
    password: !secret router
    consider_home: 8
    interval_seconds: 3
    track_devices: True

Got:

home_assistant    | 2019-09-08 13:40:43 ERROR (MainThread) [homeassistant.config] Invalid config for [mikrotik]: [consider_home] is an invalid option for [mikrotik]. Check: mikrotik->mikrotik->0->consider_home. (See /config/configuration.yaml, line 237). Please check the docs at https://home-assistant.io/components/mikrotik/
home_assistant    | 2019-09-08 13:40:43 ERROR (MainThread) [homeassistant.setup] Setup failed for mikrotik: Invalid config.
    2.
device_tracker:
  - platform: mikrotik
    consider_home: 8
    interval_seconds: 3
    track_new_devices: False

mikrotik:
  - host: 192.168.0.1
    username: root
    password: !secret router
    track_devices: True

Got:

home_assistant    | 2019-09-08 13:44:14 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform legacy
home_assistant    | Traceback (most recent call last):
home_assistant    |   File "/usr/src/homeassistant/homeassistant/components/device_tracker/setup.py", line 65, in async_setup_legacy
home_assistant    |     self.platform.get_scanner, hass, {DOMAIN: self.config}
home_assistant    |   File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
home_assistant    |     result = self.fn(*self.args, **self.kwargs)
home_assistant    |   File "/usr/src/homeassistant/homeassistant/components/mikrotik/device_tracker.py", line 35, in get_scanner
home_assistant    |     return scanner if scanner.success_init else None
home_assistant    | UnboundLocalError: local variable 'scanner' referenced before assignment

mikrotik

Most helpful comment

Any news?

All 15 comments

I will start writing a PR to add these missing options into the Mikrotik Hub and update the documentation.
Missing options:
consider_home
interval_seconds
track_new_devices
Thank you for the details PaulAnnekov

@slackr31337 any news?

@slackr31337 any news?

Hi @PaulAnnekov,

I am currently testing code changes before submitting a PR. The option to disable tracking new devices requires the device tracker to load the known_devices.yaml and compare mac addresses.

I should have a working PR soon.

We should not extend the legacy behavior but instead implement config entries and use the new device tracker class available:
https://github.com/home-assistant/home-assistant/blob/f3d408aca4e707f62ccd4902001b550cbe1a8148/homeassistant/components/device_tracker/config_entry.py#L120-L133

See the unifi device tracker for an example.

Looks like UniFi also having trouble #26921.

I have submitted a PR #27093 to update the Mikrotik Integration following the Unfi implementation. In this PR you will have the option to set the consider home interval. And you can also control adding new devices using the system option Enable newly added entities. As for the interval_seconds I left it to the device_tracker entity update default interval.

Any news?

I think it's a good example of how to not make a code review :disappointed: . You approve something which totally breaks backward compatibility and everybody is waiting 4+ months for a fix.

I think this issue can be closed now with the new integration added.

Which integration?

@engrbm87 I see you fixed one part of the problem, consider_home is now detection_time. Thanks :confetti_ball: . But what about interval_seconds? Is there any way to set it, e.g. to 3 seconds. Currently, it looks like it's 15 seconds.

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 馃憤
This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Still relevant.

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 馃憤
This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Still relevant.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

coolriku picture coolriku  路  3Comments

Elmardus picture Elmardus  路  3Comments

flsabourin picture flsabourin  路  3Comments

sh0rez picture sh0rez  路  3Comments

kirichkov picture kirichkov  路  3Comments