home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.57k stars 29.91k forks source link

No way to ignore specific clients in new UniFi device tracker integration #25764

Closed joshtbernstein closed 5 years ago

joshtbernstein commented 5 years ago

Home Assistant release with the issue: 0.97

Last working Home Assistant release (if known): 0.96b5

Operating environment (Hass.io/Docker/Windows/etc.): Hass.io

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

Description of problem: Before the UniFi device tracker was merged into the integration, devices would be added to known_devices.yml which would allow them to be ignored per device. There was also the option to set "track_new_devices" to "false" to ignore all new devices. There doesn't seem to be a way to do this now.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

device_tracker:
  - platform: unifi
    host: unificontroller.mynetwork.local
    username: !secret unifi_username
    password: !secret unifi_password
    verify_ssl: false
    ssid_filter:
      - 'MyCoolSSID'
    track_new_devices: false

Traceback (if applicable):

Additional information:

rkreterfield commented 5 years ago

Having the same problem after upgrading today.

probot-home-assistant[bot] commented 5 years ago

Hey there @kane610, mind taking a look at this issue as its been labeled with a integration (unifi) you are listed as a codeowner for? Thanks!

glassbase commented 5 years ago

Same here... Super annoying to have like 40-50 entities I don't care to see in HA now.

joshtbernstein commented 5 years ago

So I found a PR for this in one of the betas for 0.97, but it looks like something is wrong with the documentation as that change isn't showing up.

Adding dont_track_wired_clients: true kind of works, but I still have a few devices showing up.

glassbase commented 5 years ago

@dummptyhummpty Did you add it to your config and it worked? Does not appear to work for me unless I need to manually delete the "wired" entities

joshtbernstein commented 5 years ago

@glassbase I added it, deleted all of the wired entities from the entity registry and rebooted. Some of them still came back, but less than before. So yeah, seems like it's not working 100% correctly.

Kane610 commented 5 years ago

If you get wired entities then maybe your configuration isn't mapped to your config entry. A common mistake seems to be not using the site name rather than the site is previously supported by the device tracker

joshtbernstein commented 5 years ago

@Kane610 I'm using the same site name in the integration configuration and in my configuaration.yml

P11x3l commented 5 years ago

This isn't just wired devices, it tracks all new wifi devices and adds cards for them in the UI and entities in Entity Registry. Now I have 20 wifi devices all showing up in the UI.

Previously we could set "track_new_devices: false" and then on specific devices we could use "track: true".

This way I could track only mobile phones on wifi and wouldn't get the clutter of the other 20 devices.

fillwe commented 5 years ago

Yeah I have 60 wifi devices on my network. Just want to track 2 of them, rest is just cluttering up the UI 😕

joshtbernstein commented 5 years ago

@nicr4wks That’s a good point. I got confused and forgot about that.

ChadMoran commented 5 years ago

The reason this is happening is that each device is now an entity. So far the only way I've found to remove them is to use the customize functionality to hide them from the UI but this is quite cumbersome if you have a lot of clients on your network.

lmamakos commented 5 years ago

I think the primary purpose of the UniFi integration is presence detection with device_trackers. Not as some sort of discovery and network management tool. I just don't see how, for most people, spontaneously generating new entities for each random WiFi device is expected or desired behavior.

Please restore the old behavior as a default.

steve28 commented 5 years ago

Yes, please make default to track NOTHING unless i tell it to! I don't need a device tracker for every. single. person. that's ever connected to my wifi.... Also, pretty sure no one needs a device_tracker for their thermostat (or light switches, or refrigerator, or bathroom scale, or...)

ranunculales commented 5 years ago

I second the default to NOT track devices (@steve28); I'd rather tell it which ones I want tracked since those are fewer (just 2) than the 60 devices on my network.

CoarsePiglet commented 5 years ago

Since I am a heavy user of this integration, I would also like to voice my concern with known_devices.yaml being removed from the Presence Detection via UniFi. I currently have 45 devices tracked by Home Assistant with the UniFi integration, 2 of which I actually need tracked. Please do integrate known_devices.yaml again, or allow us to set a default to not track the entities it creates and to disable tracking for the entities it has already created. I really hope this gets fixed someday, UniFi tracking was the best alternative for Owntracks in my scenario, and it has worked flawlessly ever since.

Kane610 commented 5 years ago

To handle ignoring of entities of UniFi which you don't want visible in hass Paulus shared this on the 0.97 release blog post.

Disabling entities is no longer going to be the responsibility of integrations but of Home Assistant core via the entity registry. Disabled entities will no longer be added to the state machine.

As a user you should not aim to manage what is in the state machine. With Lovelace you pick and choose the entities that you want to see.

https://community.home-assistant.io/t/0-97-apache-kafka-fortigate-twente-milieu/130480/90?u=robban

I will talk to him during the upcoming week about me implementing this in the core.

steve28 commented 5 years ago

The issue here is that even transient entities on your network get created as device_trackers. I understand the philosophy of not trying to manage what goes into the state machine... I just think that in this case - that can lead to lots of garbage in the state machine.

For example, I don't save every phone number I have ever called or that calls me in my phone book.

Kane610 commented 5 years ago

Ok, so how do you suggest we solve this going forward?

rkreterfield commented 5 years ago

The main reason I have an issue with this breaking change, is the fact it makes all of my POE enabled devices act as a switch. I have an automation setup for all switches, lights, etc to turn off at 2:00 a.m. every night, which in turn makes my VoIP phone and all my security cameras turn off. I ended up removing the integration completely until there is an option to exclude devices on your network. Probably going to just revert to my last snapshot on v0.96.5.

joshtbernstein commented 5 years ago

@kane610 To answer your question, we need a way to not add all devices as default and only include the ones we want. I can honestly deal with them showing in the integration as inactive, but I wouldn’t want them anywhere else in HA.

There would also need to then be some kind of cleanup for devices that haven’t been seen in X amount of days.

I really appreciate the work you’ve done, but it seems as if this change shouldn’t have been made until these questions had answers.

P11x3l commented 5 years ago

Perhaps a sort of white-list on the device tracker or part of the entity core if that's where hass is headed? If it's on the core then I think there should be an option to apply per tracker type (one white-list for unifi-tracker, separate white-list for nmap, etc).

We can approve devices via MAC, entity.id, etc that hass will pay attention to and everything else can automatically be disabled or not even entered in the first place.

Computers I'm repairing, devices I'm testing, devices i'll never see again, devices belonging to friends. Things constantly moving on and off wifi have no purpose whatsoever being added in to hass so it can track them forever and a day.

sreknob commented 5 years ago

I'm all for a whitelist as well. When it comes to network devices we all have a lot of transient ones so using an all-in network tracker just doesn't make sense.... The only problem is how to make this fit into the future of HASS as @Kane610 mentioned.

mattatcha commented 5 years ago

How do other integrations handle this problem? Unifi can’t be the only integration that needs the ability to whitelist devices.

lmamakos commented 5 years ago

There's two things that contribute to this problem that are related

Personally, I think that either that architectural principal is too broad or wrong; that probably what was intended was something like not forcing the integration to choose which of the myriad set of data should be available from some, e.g., weather API -- leave that to the user.

As I've tried to argue in another forum, I think this architectural principle is a fine thing to apply when the set of data that's exposed is relatively static and bounded. And that at the time the integration is installed/configured, all the information needed is available for the user to then decide what to expose or not.

The problem here is that it's not the types of information that needs to be selected by the user for use, but which of the unbounded number of instances are useful. And this is why this generalized mechanism needs some generalized whitelisting capability. Consider how much worse this all falls down if you had a bluetooth-based tracker that generates all these entities. And you're operating Home Assistant in a high population density environment with a lot of people walking by with their phones. And in that case, it's not authentication is a barrier to a bluetooth device being visible while scanning..

In the mean time, I'm moving to yet another docker container running a python script that polls the UniFI API and selectively publishes data to MQTT; and I'll just configure MQTT device_trackers. Until that breaks.

Also see https://github.com/home-assistant/architecture/issues/100 for discussion of the issue where similar concerns were raised previously.

Kane610 commented 5 years ago

@rkreterfield do you use anything but device tracker? Setting the user to a viewer account would disable the POE control. Or create a group to filter what you want to control.

FuzzyMistborn commented 5 years ago

I just gotta say, reading through https://github.com/home-assistant/architecture/issues/100 i'm disappointed to see that similar concerns that are being raised here were also raised there but appear to have been simply ignored without any explanation.

arsaboo commented 5 years ago

We can probably have config options to include and exclude as we do for other integrations. Users can then include the mac-address of the devices that should be included/excluded from HA.

jcollie commented 5 years ago

Except that there needs to be a way to do the inclusion/exclusion from the GUI.

crag-r commented 5 years ago

Why not have the ability to turn on or off tracking of new devices in the integration itself especially now that known_devices is now defunct? The other option I can see would be a workaround, but if you delete an entity from the integration it no longer comes back unless you remove and re-add the integration or even click a "re-scan" button or something similar?

Basically, as it is it's flawed as I do not agree you need everything from the UniFi controller in the state machine.

Like others I have many devices that come and go on my network that I really do not want to see appear in the entities list - the only reason I use the UniFi integration was device tracking - of which most if not all people will only ever want to track one or two devices anyway!

jtscott commented 5 years ago

I just want to add that this also causes unwanted functionality for other lovelace cards that have dynamic inclusions/filters of entities. e.g. fold-entity-row or monstercard

parberge commented 5 years ago

Why not have the ability to turn on or off tracking of new devices in the integration itself especially now that known_devices is now defunct?

This is what I was expecting to exist when I started using this integration. To clarify: Not only new devices, but for every device. Just a toggle that works the way track: false worked with known_devices.yaml

For me the most annoying thing is to see these event in logbook that I don't care about. I know there are ways to customize this, but it seems quite cumbersome to to exclude all device_tracker entities that I don't want to show up in logbook

Kane610 commented 5 years ago

I've been talking to balloob and will start looking at a hass generic way to config disabling new entities

habr05 commented 5 years ago

@Kane610 Here is what would make sense to me:

  1. Keep discovered devices for x number of days after "last seen" -> purge after x.
  2. Do not track by default; do not add bubble to UI.
  3. If device is added to a Person - start tracking but do not add bubble to UI -> Person has a bubble.
  4. If device is added to a Person - pause "x days purge".
Kane610 commented 5 years ago

Our first step is to utilise the disable functionality of entity registry; We will introduce an option to config entries that will allow the user to disable creation of new entities. They will only pop up in the entity registry as disabled entities. The user can then control what entities are wanted from each config entry

joshtbernstein commented 5 years ago

@kane610 Thank you for coming up with a solution to this issue!

rwarner commented 4 years ago

I'm still experiencing issues with this in the latest homeassistant version 101.3.

Unifi Integration, despite my unchecking of the settings area as well as disabling the option for tracking new entities still continues to mark all the devices on my network as "not_home" or "home".

I cannot get it to ignore these items and only track two of our devices on the network.

Kane610 commented 4 years ago

You mean you have selected to not track any client?

rwarner commented 4 years ago

Currently I have like 20+ device_tracker entities:

Screen Shot 2019-11-16 at 10 21 52 AM

I have the setting to "track network clients" on currently

Screen Shot 2019-11-16 at 10 22 06 AM

and the other "enable newly added entities" is disabled

Screen Shot 2019-11-16 at 10 22 12 AM

Prior to upgrading I had all of these entities disabled and turn ALL of these options off, only to enable two specific phones manually to track. However after upgrading and seemingly despite turning this options off and/or on, it continues to track a multitude of devices.

What would be the proper method for only tracking two clients on the network? I don't mind doing it again, I just can't seem to reproduce the same thing I had working already.

Kane610 commented 4 years ago

Disable track clients and enable those you want

rwarner commented 4 years ago

Thanks, my apologies I thought it was strange though because I had this setup prior to upgrading home assistant and it seemed like it got re-enabled for all entities again.

I went and disabled "track network clients" then went to the entity registry and re-enabled the two phones. Waited a minute or so and those are the only ones being tracked now in the integration.

Kane610 commented 4 years ago

Great! I think there is enough information in this issue to lock it. I will improve documentation for integration.