Created At

Apr 23, 2020

Last Update

May 04, 2020

Platforms

HC 3

Views

2716

Download

406

Type Quick App

It is a Quick App to track presence based on the status of the device's MAC address in the UniFi controller. The app emulates a binary sensor. "Unknown" and "Home" correspond to the sensor's status "true", "Away" corresponds to the sensor's status "false".

The following variables are mandatory:

  1. controller - address of controller including protocol and port (e.g., https://192.168.1.10:8443/)
  2. site - name of the site defined in controller and where MAC address will be searched (e.g., default)
  3. login - username to log into the controller. I recommend creating a dedicated user with read-only access to the controller (e.g., fibaro)
  4. password - self-explanatory
  5. frequency - how often to poll controller (in seconds, e.g., 120)
  6. mac - MAC address of the device that will be tracked (e.g., d4:a3:3d:c2:b9:e4) 

The following variables are optional:

  1. away delay - the app changes status for MAC address from "presence detected" to "presence not detected" if the UniFi controller "sees" the mac more than "away delay" seconds ago. If the variable is not defined, then the value of "frequency" is used as "away delay".
 

16 Comments,  Want to add comment please login
C7c862ae66fcf0e8cdf4c1157c08b49d

Hmmm... when i set frequency to 60 (instead of 3), it seems to work fine! Cheers!

C7c862ae66fcf0e8cdf4c1157c08b49d

Thx - i found out that although my site is called Site - unifi ip address points out it is called something like "g4szhqw4". When I use that as a variable - i can connect! BUT - I only get a "Home" once. After that, I receive "Away". So the first time it sees my iphone - it works. But the next poll leads to Away - althoug nothing has changed and my Iphone is still attached to the wifi network. Any suggestions?

602d0c581d41f736142387ba05c5263f

I recommend sending a request manually to validate the app's configuration. To do that: 1) Open in web browser URL specified in the "controller" variable. 2) Login with the login/password from "login" and "password" variables. 3) In the same browser tab where you logged into UniFi, open the page <controller>api/s/<site>/stat/sta. In my configuration the "controller" variable is "https://192.168.1.10/", the "site" variable is "defaul", so the whole request looks like "https://192.168.1.10/api/s/default/stat/sta". 4) The UniFi controller responds with the list of devices, including their MACs, which the controller "sees". 5) Search the response for the MAC address specified in the "mac" variable.

C7c862ae66fcf0e8cdf4c1157c08b49d

Nope - didn't find it. Error stays: [ERROR] [QUICKAPP390]: checkMacUnifi() failed: "{\"meta\":{\"rc\":\"error\",\"msg\":\"api.err.NoSiteContext\"},\"data\":[]}" Any Sugeestions?

C7c862ae66fcf0e8cdf4c1157c08b49d

Found it! It seems an iphone has a private MAC address config for each new Wi-Fi-network it connects to.