Author Topic: PLUGIN: Unifi Sensor - Presence detection using a Unifi Wi-Fi controller  (Read 2836 times)

Offline s83569

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
Re: PLUGIN: Unifi Sensor - Presence detection using a Unifi Wi-Fi controller
« Reply #15 on: October 06, 2017, 09:06:35 am »
Sorry but I can't understand what I should configure for attribute - Unifi URL - is it some external device, which should be present in the system - or is it a Vera's IP address should be used, If we are talking about external UNIFI controller has be present in the network - why on the page there is no notice about UNIFI controller configuration....
I am confused about how it should work, - I have uploaded files to Vera, gave permission to script and create a UNIFI device, so - what else should be present / configured to get MAС tracking workable?

Offline Don Phillips

  • Hero Member
  • *****
  • Posts: 1290
  • Karma: +33/-32
Re: PLUGIN: Unifi Sensor - Presence detection using a Unifi Wi-Fi controller
« Reply #16 on: October 06, 2017, 08:37:12 pm »
Sure, you just set the SetHMode variable to the value you want. I use it to set night mode. 
Vera 3, 1.7.1030, CT101 t-stat, Everspring motion detector, GE/Jasco switch, Leviton outlet, AeonLabs sensor, NuTone garage door, Blue Iris, Sricam SP011, iPhone locator, APCUPSD, VeraMate, VeraAlerts, PLEG, House Modes, Countdown Timer, DVR, Virtual/Multi Switch, Weatherunderground, LB60Z-1 bulb

Offline Spanners

  • Sr. Member
  • ****
  • Posts: 252
  • Karma: +15/-5
Re: PLUGIN: Unifi Sensor - Presence detection using a Unifi Wi-Fi controller
« Reply #17 on: October 06, 2017, 11:57:49 pm »
I clearly need to add site ID to the UI. :)

I have 4 instances of the plugin, each watching a different mobile phone.

I use a PLEG condition to monitor the status, and if all are offline it changes to away mode. Another condition changes it back to home if any one of the devices becomes active.

cHouseMode_Away      (!tiPhone1Present AND !tiPhone2Present AND !tiPhone3Present AND !tiPhone4Present) AND (tHouseMode_Home OR tHouseMode_Night) AND (tHouseMode_Home; NOW > 00:10:00)

cHouseMode_Home      (tiPhone1Present OR tiPhone2Present OR tiPhone3Present OR tiPhone4Present) AND tHouseMode_Away


Until they add AND logic to the Vera Scene editor you'll need to use PLEG or Lua code in a scene to achieve it.



Exactly the way I would do it except I would make a virtual switch on or off, although the houseaway mode also seems tempting although there seems to be no way to put Vera in away modes using Pleg, or is there?

Device 19 is a PLEG instance.


Action: cHouseMode_Away

Device Actions:Immediate

Device   Action   Arguments
Logic - Geo Security[19]   SetHouseMode   Mode=2

Action: cHouseMode_Home

Device Actions:Immediate

Device   Action   Arguments
Logic - Geo Security[19]   SetHouseMode   Mode=1


Offline svjakobs

  • Newbie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: PLUGIN: Unifi Sensor - Presence detection using a Unifi Wi-Fi controller
« Reply #18 on: October 09, 2017, 03:18:29 am »
I'm in too deep water here. Any chance anyone would take the time to give step-by-step direction,or example on how I can use this to trigger housemode=away when my 3 Unify er gone, and set homemode if one or more is present?

Thanks

Offline Spanners

  • Sr. Member
  • ****
  • Posts: 252
  • Karma: +15/-5
Re: PLUGIN: Unifi Sensor - Presence detection using a Unifi Wi-Fi controller
« Reply #19 on: October 09, 2017, 03:47:14 am »
Sorry but I can't understand what I should configure for attribute - Unifi URL - is it some external device, which should be present in the system - or is it a Vera's IP address should be used, If we are talking about external UNIFI controller has be present in the network - why on the page there is no notice about UNIFI controller configuration....
I am confused about how it should work, - I have uploaded files to Vera, gave permission to script and create a UNIFI device, so - what else should be present / configured to get MAС tracking workable?

Hi - here are my settings for a Unifi Sensor device:

Address   d4:f4:6f:12:80:c7
Poll Period   90 seconds
Device Retries   0
Unifi URL   192.168.0.20:8443
Unifi Username   vera
Unifi Password   obscuredbyclouds


Address - is an IP or MAC of the device you want to check on the Unifi controller.
Poll Period -how often you want to hit the Unifi conroller for info
Device Retries - how many negative responses you want before you change the state of the sensor
Unifi URL (probably a poor choice of name) - the IP address and Port number of your Unifi Controller.
Unifi Username - a user ID you've created on the Unifi Controller for Vera to use. DO NOT use your default admin account.
Unifi Password - password for user ID above.

The only thing you need to configure on your Unifi Controller, assuming you're running 5.5 or thereabouts is a username and password. You may need to get the site ID and edit the shell script if you're not accessing the default Unifi site.

You can test by logging into your Unifi controller and then changing the URL to: https://xxx.xxx.xxx.xxx:xxxx/api/s/default/stat/sta  where the x's are your IP/port details. You should get a browser full of JSON text in response.



Offline Spanners

  • Sr. Member
  • ****
  • Posts: 252
  • Karma: +15/-5
Re: PLUGIN: Unifi Sensor - Presence detection using a Unifi Wi-Fi controller
« Reply #20 on: October 09, 2017, 03:53:41 am »
I'm in too deep water here. Any chance anyone would take the time to give step-by-step direction,or example on how I can use this to trigger housemode=away when my 3 Unify er gone, and set homemode if one or more is present?

Thanks

I presume you don't already use PLEG?

The conditions and actions I posted earlier will work, but yes you'll need to install and learn to use the PLEG plugin. Recommend starting with RexBecketts documentation here:

http://forum.micasaverde.com/index.php/topic,21603.0.html

You can install the PLEG plugin from the Vera app store.

It's not as daunting as it first seems, and almost every "how do I?" question involves PLEG in the answer. It'll be the best plugin you ever put on your Vera.

Offline riochicken

  • Sr. Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
Re: PLUGIN: Unifi Sensor - Presence detection using a Unifi Wi-Fi controller
« Reply #21 on: October 20, 2017, 12:51:42 pm »
Hi,

Any chance on a rebuild? I think the new UI7 Firmware screwed the plugin up...

Thanks!

Offline Spanners

  • Sr. Member
  • ****
  • Posts: 252
  • Karma: +15/-5
Re: PLUGIN: Unifi Sensor - Presence detection using a Unifi Wi-Fi controller
« Reply #22 on: October 21, 2017, 03:57:12 am »
Hi,

Any chance on a rebuild? I think the new UI7 Firmware screwed the plugin up...

Thanks!

What sort of issues are you having? I've put the new firmware on my Vera and the plugin is still working ok.

Offline riochicken

  • Sr. Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
Re: PLUGIN: Unifi Sensor - Presence detection using a Unifi Wi-Fi controller
« Reply #23 on: October 22, 2017, 12:39:01 pm »
Hi,

Any chance on a rebuild? I think the new UI7 Firmware screwed the plugin up...

Thanks!

What sort of issues are you having? I've put the new firmware on my Vera and the plugin is still working ok.

Weird... Since the last update my devices don't seem to read the information out of the system anymore.. The just keep on reporting device found while it's offline...

Offline Spanners

  • Sr. Member
  • ****
  • Posts: 252
  • Karma: +15/-5
Re: PLUGIN: Unifi Sensor - Presence detection using a Unifi Wi-Fi controller
« Reply #24 on: October 23, 2017, 01:43:17 am »
That is odd, because any error, timeout etc should result in an offline status.

Everything must execute perfectly and a result returned to get an online detection.

You can test by logging into your Unifi controller and then changing the URL to: https://xxx.xxx.xxx.xxx:xxxx/api/s/default/stat/sta  where the x's are your IP/port details. You should get a browser full of JSON text in response. Hit CTRL-F and see if you can find the IP/MAC of the device you're looking for.

Offline riochicken

  • Sr. Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
Re: PLUGIN: Unifi Sensor - Presence detection using a Unifi Wi-Fi controller
« Reply #25 on: October 23, 2017, 02:16:47 am »
That is odd, because any error, timeout etc should result in an offline status.

Everything must execute perfectly and a result returned to get an online detection.

You can test by logging into your Unifi controller and then changing the URL to: https://xxx.xxx.xxx.xxx:xxxx/api/s/default/stat/sta  where the x's are your IP/port details. You should get a browser full of JSON text in response. Hit CTRL-F and see if you can find the IP/MAC of the device you're looking for.

Yeah well, no error whatsoever, even when I change the hardware address it still says, address found....?!?! I will re-upload the files and start over again, see if that helps... Thanks!


I Think I know what went wrong.... when using a complex user password for the Vera user ID, the plugin apparently doesn't understand and says it found the address, I now used a slightly easier password and it works... duh... I think the check for checking the userid and password is not working correctly...
« Last Edit: October 23, 2017, 01:11:28 pm by riochicken »

Offline Spanners

  • Sr. Member
  • ****
  • Posts: 252
  • Karma: +15/-5
Re: PLUGIN: Unifi Sensor - Presence detection using a Unifi Wi-Fi controller
« Reply #26 on: October 24, 2017, 03:46:29 am »
Ah yes, that rings a bell - can't use special characters in the password or username. Causes an issue when passing it as a parameter to the script from the plugin.


Offline riochicken

  • Sr. Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
Re: PLUGIN: Unifi Sensor - Presence detection using a Unifi Wi-Fi controller
« Reply #27 on: October 24, 2017, 04:08:25 am »
Ah yes, that rings a bell - can't use special characters in the password or username. Causes an issue when passing it as a parameter to the script from the plugin.

Ah, that explains... Even two capitals in the username went wrong apparently, now it's functioning again like it should.. :)

Offline jugernaat

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
Re: PLUGIN: Unifi Sensor - Presence detection using a Unifi Wi-Fi controller
« Reply #28 on: December 16, 2017, 09:29:50 am »
Never Mind it is working. I had a capital leter in my username and had not set that on the controler. it is always somthing easy!
this looks like an awsome app and will be great for presence sensing my car and truck. thanks for the great work!




So I have been playing with this for a few days but no matter what I do I can not get this to see the device I have on the network. it comes back with address not found: query time 1s.
I am using the default site and have no special characters in the password.

unifi controler is ver 5.4.9
Vera Firmware: UI7 1.7.3231

I am using the ping plugin as well which works fine I am just not sure what I am doing wrong.
any help would be apriciated.
« Last Edit: December 16, 2017, 09:37:58 am by jugernaat »

Offline Spanners

  • Sr. Member
  • ****
  • Posts: 252
  • Karma: +15/-5
Re: PLUGIN: Unifi Sensor - Presence detection using a Unifi Wi-Fi controller
« Reply #29 on: December 17, 2017, 06:46:38 pm »
Awesome - hope it works well for you.