Presence detection with unifi

Hey guys so for the last few hours i have been trying to set up presence detecion with my unifi gear… everything goes smooth with the configuration but then nothing happens. nothing appears,

Here is my config:

device_tracker:
   - platform: unifi
     host: 10.0.0.20
     port: 8443
     username: myussr
     password: mypasswd
     detection_time: 300 
     verify_ssl: False
     ssid_filter:
      - 'Shrem'
     interval_seconds: 60
     new_device_defaults:     
       track_new_devices: True
       hide_if_away: False

Does anyone know what i am doing wrong ?

1 Like

Hard to say because you have not formatted your configuration correctly.

1 Like

You need to specify site_id unless your site is the default site.
Your unifi site id is in the URL for the dashboard of your site.
From the Unifi component page . . .

“For example, this is what would be seen in the URL bar when inside the dashboard page of a site:
https://127.0.0.1:8443/manage/s/ceb1m27d/dashboard
And your site_id value would be ceb1m27d .”

1 Like

I am on mobile but here it is I don’t see any errors.
device_tracker:

  • platform: unifi
    host: 10.0.0.20
    port: 8443
    username: myusr
    password: mypass
    detection_time: 300
    verify_ssl: False
    ssid_filter:
    • ‘myssid’
      interval_seconds: 60
      new_device_defaults:
      track_new_devices: True
      hide_if_away: False

I am using the default site… Really don’t know what’s happening.

Logs. Where are they?

One obvious syntax problem is that you need one more space before “- ‘Shrem’” under ssid_filter.

I tried to enable the debug … nothing comes up in the logs.

logger:
  default: info
  logs:
    aiounifi: debug
    homeassistant.components.unifi: debug
    homeassistant.components.switch.unifi: debug

I also have managed to add the component via integrations and it is successfully added . Maybe its my unifi controller version ??? im on 5.10.23

Edit: Managed to get some logs but nothing seems out of the ordinary… the probolem is that the known_devices.yaml never populates.

1 Like

Sorry for the mess that was yesterday with the syntax errors i was using mobile …

So i have this in my configuration.yaml

device_tracker: !include device_tracker.yaml

I have also made a device_tracker.yaml that goes like this.

####################################################
#                                                  #
#              DEVICE TRACKER - UBIQUITI           #
#                                                  #
####################################################

#https://www.home-assistant.io/components/device_tracker.unifi/

- platform: unifi
  host: 10.0.0.20
  port: 8443
  username: myusr
  password: mypass
  verify_ssl: false
  detection_time: 60
  ssid_filter:
    - 'mySSID'

I have also added the component successfully via integrations … no error logs i am starting to think that my unifi version is not supported.

I’m on 5.10.23 and it is working fine.

All that happens when this works is it adds devices from your network to your known_devices.yaml file and creates device_tracker entities with “scanner: UnifiScanner” in the attribute.

I was able to check the full logs … On the logs it connects and all of the devices show up perfectly… But it doesn’t add anything to the known_devices.yaml and it also it doesn’t create any entities… Is there something I’m missing ???

Not a full answer, but a potential workaround… how many access points do you have? There is another UniFi component that allows you to check the devices on the access point instead of the controller.
I had a similar problem as you and couldn’t get it to work. As I only have one AP in my house, the AP version works just as well for me, and I got that working without any issues.

Well we have 4 APs and a couple of switches and some cameras … i wanted to do this so i can also get stats for the switches and power consumption and display them on custom graphs… now that you mentioned it worked yesterday when i tried that approach but it just brought my network to a crawl lol so i deleted that immediately.

I have added a github issue since the component loads fine its just the tracking that is kinda not working … i hope i we can get somewhere over there.

I have also made a device_tracker.yaml that goes like this

Forgive what may be an obvious question, but have you set appropriate permissions for the manually created file?

I really don’t know how to check the permissions on the file… But when i use the unifi-direct component the file gets populated…

here are the last things i have tried .
Made a new fresh install no other component or entity added and the result is the same …
Added a lot of different configs here is the latest:

####################################################
#                                                  #
#              DEVICE TRACKER - UBIQUITI           #
#                                                  #
####################################################

#https://www.home-assistant.io/components/device_tracker.unifi/

- platform: unifi
  host: !secret unifi host
  port: !secret unifi port
  username: !secret unifi username
  password: !secret unifi password
  verify_ssl: False
  detection_time: 60
  interval_seconds: 60
  consider_home: 180
  ssid_filter:
      - 'Shrem'
  new_device_defaults:
    track_new_devices: true
    hide_if_away: false
  monitored_conditions: 
    - rx_bytes
    - rx_bytes-r
    - rx_packets
    - rx_rate
    - signal
    - site_id
    - tx_bytes
    - tx_bytes-r
    - tx_packets
    - tx_power
    - tx_rate

Added the issue on github but it seems not to get any attention it must be something wrong with my specific setup because i don’t see anyone else having the same issues as me.

1 Like

But when i use the unifi-direct component the file gets populated

I would assume then that file permissions are correct.

Is the unifi user account being used an admin on the controller (read-only is sufficient)?
Does the password contain any special characters (there are old posts reporting this as an issue).

Well ill be damned … I changed the account permissions to read only from administrator and then it worked immediately… its not specified what type of account you should use for the component to work strange thing is that in the logs it connected and displayed the information when logger was enabled for debugging purposes it just didn’t populate the known_devices.yaml and entities where not created.

Thanks for pointing me on another direction issue is solved finally

1 Like

maybe dumb question :see_no_evil: but what stands those both lines for:

  interval_seconds: 60
  consider_home: 180

just got the detection_time: 10 in mine
I recognized that it took some time appr. 5-10 min. if the device is marked as away?!

any thoughts?

1 Like

interval seconds is how often HA contacts unifi to get list of devices that are connected
Consider home is how long someone should be a way to be marked away.

I have problem setting up unifi, would you mind sharing your config?

1 Like

There you go:

device_tracker:
  - platform: unifi
    host: !secret unifi_ip
    username: !secret unifi_user
    password: !secret unifi_pw
    verify_ssl: false
    detection_time: 10
    new_device_defaults:
      track_new_devices: false
1 Like