Created At

Apr 23, 2020

Last Update

May 04, 2020

Platforms

HC 3 Lite, Yubii Home, HC 3

Views

4034

Download

555

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".
 

25 Comments,  Want to add comment please login
209bd4e8787f899634e93d300e0fc01e

Does it works well?

Aa0948cec1bc754c6fde5a1ab87ea969

Razvan Velterean - I am trying to do this same and have received the same results as you using port 443. I get connection refused when trying port 8443. Have you managed to find out what was stopping your quick app from running? we are using a Cloud Key Gen2 Thanks Owen

7605bf39af919dae14de13f0bd0a9e81

[24.03.2021] [21:38:00] [ERROR] [QUICKAPP357]: QuickApp crashed [24.03.2021] [21:38:00] [ERROR] [QUICKAPP357]: /usr/share/lua/5.3/json/decode/util.lua:35: unexpected character @ character: 2 1:2 [<] line: [24.03.2021] [21:38:52] [WARNING] [QUICKAPP357]: Variable away delay not found [24.03.2021] [21:38:52] [DEBUG] [QUICKAPP357]: onInit(): away delay equals frequency [24.03.2021] [21:38:52] [TRACE] [QUICKAPP357]: setPresenceStatus() called: Unknown [24.03.2021] [21:38:52] [DEBUG] [QUICKAPP357]: loginUnifi() succeed [24.03.2021] [21:39:52] [TRACE] [QUICKAPP357]: checkMacUnifi() succeed [24.03.2021] [21:39:52] [ERROR] [QUICKAPP357]: QuickApp crashed [24.03.2021] [21:39:52] [ERROR] [QUICKAPP357]: /usr/share/lua/5.3/json/decode/util.lua:35: unexpected character @ character: 2 1:2 [<] line: [24.03.2021] [21:40:00] [WARNING] [QUICKAPP357]: Variable away delay not found [24.03.2021] [21:40:00] [DEBUG] [QUICKAPP357]: onInit(): away delay equals frequency [24.03.2021] [21:40:00] [TRACE] [QUICKAPP357]: setPresenceStatus() called: Unknown [24.03.2021] [21:40:00] [DEBUG] [QUICKAPP357]: loginUnifi() succeed [24.03.2021] [21:41:01] [TRACE] [QUICKAPP357]: checkMacUnifi() succeed [24.03.2021] [21:41:01] [ERROR] [QUICKAPP357]: QuickApp crashed [24.03.2021] [21:41:01] [ERROR] [QUICKAPP357]: /usr/share/lua/5.3/json/decode/util.lua:35: unexpected character @ character: 2 1:2 [<] line: [24.03.2021] [21:42:00] [WARNING] [QUICKAPP357]: Variable away delay not found [24.03.2021] [21:42:00] [DEBUG] [QUICKAPP357]: onInit(): away delay equals frequency [24.03.2021] [21:42:00] [TRACE] [QUICKAPP357]: setPresenceStatus() called: Unknown [24.03.2021] [21:42:00] [DEBUG] [QUICKAPP357]: loginUnifi() succeed [24.03.2021] [21:43:00] [TRACE] [QUICKAPP357]: checkMacUnifi() succeed [24.03.2021] [21:43:00] [ERROR] [QUICKAPP357]: QuickApp crashed

7605bf39af919dae14de13f0bd0a9e81

@Oleksiy Lukyanchykov, I reinstalled your app after this long beta and still not working. I see you're using a software controller and I use a UCK-G2-Plus. There's no way I did something wrong. There's only one variable. My site is named different than default but I tried both names: default and the actual name. Other than that, there's not much I can try. Except the port. It worked to connect on port 443 and with actual site name but now I have another problem [24.03.2021] [21:23:05] [ERROR] [QUICKAPP357]: loginUnifi() failed: "Connection refused" [24.03.2021] [21:23:33] [WARNING] [QUICKAPP357]: Variable away delay not found [24.03.2021] [21:23:33] [DEBUG] [QUICKAPP357]: onInit(): away delay equals frequency [24.03.2021] [21:23:33] [TRACE] [QUICKAPP357]: setPresenceStatus() called: Unknown [24.03.2021] [21:23:33] [DEBUG] [QUICKAPP357]: loginUnifi() succeed [24.03.2021] [21:24:33] [TRACE] [QUICKAPP357]: checkMacUnifi() succeed [24.03.2021] [21:24:33] [ERROR] [QUICKAPP357]: QuickApp crashed [24.03.2021] [21:24:33] [ERROR] [QUICKAPP357]: /usr/share/lua/5.3/json/decode/util.lua:35: unexpected character @ character: 2 1:2 [<] line:

602d0c581d41f736142387ba05c5263f

@Razvan Velterean: the app works fine for me with UniFi 6.1.x. I run UniFi on a NAS in a Docker container. ''Connection refused" means that the app can't establish a TCP connection with UnFi, so it can't be related to API changes. Most likely, it is the result of the wrong app configuration.