New Plugin - miniUniFi (minimal UniFi access)

Posted on
Fri Oct 23, 2020 1:16 pm
FlyingDiver offline
User avatar
Posts: 4843
Joined: Jun 07, 2014
Location: Southwest Florida, USA

New Plugin - miniUniFi (minimal UniFi access)

I was looking for a simple way to use my UniFi controller for mobile device presence detection. I tried using Karl's plugin, but it was just more than I wanted. So I wrote my own.

https://github.com/FlyingDiver/Indigo-m ... /tag/0.0.3

This is still early testing days, but it does what I wanted it to do. Install the plugin, create a UniFi Controller device with connection and login information for your controller, then create UniFI client devices. There are both Wifi and Ethernet connected device types, but I'm not sure what you'd want to use the Ethernet client devices for. ;)

The client devices are on/off sensors, they're ON when the device is connected to your Wifi network. They're OFF when not on the network.

The default is to poll the controller every 60 seconds. This is configurable in the Plugin configuration, with (currently) a minimum interval of 30 seconds.

There are no plans to add controlling the UniFI system to this plugin. I am open to adding more status type reporting, including status of the UniFi devices themselves.

Usage questions in this thread. But reports and enhancement requests in GitHub, please: https://github.com/FlyingDiver/Indigo-miniUniFi/issues

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Fri Oct 23, 2020 2:55 pm
jalves offline
Posts: 620
Joined: Jun 16, 2013

Re: New Plugin - miniUniFi (minimal UniFi access)

Thanks for creating this plug-in. I've installed Karl's plugin for my Dream Machine but haven't yet sorted out how I'm going to use it. Basically I want pretty much what you're after - presence sensing.

It might also be useful to have a report of the Dream Machine or the internet goes down.

I'm on the road right now so I won't get a chance to try it out until late next week.

Running Indigo 7.4.1 on a 27" iMac (mid-2017), 40G memory, 1T Fusion Drive, OS X 10.15.7
Jeff

Posted on
Fri Oct 23, 2020 2:58 pm
FlyingDiver offline
User avatar
Posts: 4843
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: New Plugin - miniUniFi (minimal UniFi access)

It'll be good to get some testing on an UDM controller. I use the app running in a Docker container on my Synology NAS.

I hope we have someone with an UDM Pro to test as the query URLs are different.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sat Oct 24, 2020 8:07 am
autolog offline
Posts: 3403
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: New Plugin - miniUniFi (minimal UniFi access)

Thanks Joe :D

I am running / testing it linked to my Cloud Key G2. :)

Posted on
Sat Oct 24, 2020 8:22 am
Busta999 offline
User avatar
Posts: 701
Joined: Mar 30, 2016
Location: Wales UK

Re: New Plugin - miniUniFi (minimal UniFi access)

Thanks Joe

Setting up on my UDM now !!

Mike

Posted on
Sat Oct 24, 2020 10:55 am
autolog offline
Posts: 3403
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: New Plugin - miniUniFi (minimal UniFi access)

Sharing this in case it helps other users of this plugin. :)

I have two separate networks defined - one for 5GHz and one for 2.4GHz.

I was getting two separate entries set-up when I flipped my iPhone between the two. I noticed that it had two different MAC addresses (one for each network). In iOS14 there is a Wi-Fi setting that is "automagically" turned on to use Private Addressing which means the iPhone generates a different MAC for each network.

In the iPhone Settings > Wi-Fi You can disable this for a specific network or networks which means you will only get one entry in the list which is the original Wi-Fi Address (MAC) shown in Settings > General > about.

I now just have one UniFii entry for my iPhone regardless off which of the two networks it is on. :)

Posted on
Sat Oct 24, 2020 11:13 am
Korey offline
User avatar
Posts: 655
Joined: Jun 04, 2008
Location: Henderson, NV

Re: New Plugin - miniUniFi (minimal UniFi access)

Testing on UDMP running 1.8.1-rc3

Failing at authentication it seems:

Code: Select all
Started plugin "miniUniFi 0.0.3"
   miniUniFi Error                 Error in plugin execution runConcurrentThread:

Traceback (most recent call last):
  File "plugin.py", line 85, in runConcurrentThread
  File "plugin.py", line 186, in updateUniFiController
  File "/Library/Application Support/Perceptive Automation/Indigo 7.4/IndigoPluginHost.app/Contents/Resources/PlugIns/requests/sessions.py", line 520, in post
  File "/Library/Application Support/Perceptive Automation/Indigo 7.4/IndigoPluginHost.app/Contents/Resources/PlugIns/requests/sessions.py", line 477, in request
  File "/Library/Application Support/Perceptive Automation/Indigo 7.4/IndigoPluginHost.app/Contents/Resources/PlugIns/requests/sessions.py", line 587, in send
  File "/Library/Application Support/Perceptive Automation/Indigo 7.4/IndigoPluginHost.app/Contents/Resources/PlugIns/requests/adapters.py", line 481, in send
ConnectionError: HTTPSConnectionPool(host='192.168.0.254', port=8443): Max retries exceeded with url: /proxy/network/api/auth/login (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x10ac92fd0>: Failed to establish a new connection: [Errno 61] Connection refused',))

   miniUniFi Error                 plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)

--
Korey

Posted on
Sat Oct 24, 2020 11:40 am
FlyingDiver offline
User avatar
Posts: 4843
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: New Plugin - miniUniFi (minimal UniFi access)

Korey wrote:
Testing on UDMP running 1.8.1-rc3

Failing at authentication it seems:


https://github.com/FlyingDiver/Indigo-m ... i/issues/9

Please subscribe to notifications for that issue and follow up there. I don't want to fill up this thread with debug back and forth.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Oct 25, 2020 8:47 am
FlyingDiver offline
User avatar
Posts: 4843
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: New Plugin - miniUniFi (minimal UniFi access)

autolog wrote:
Sharing this in case it helps other users of this plugin. :)

I have two separate networks defined - one for 5GHz and one for 2.4GHz.

I was getting two separate entries set-up when I flipped my iPhone between the two. I noticed that it had two different MAC addresses (one for each network). In iOS14 there is a Wi-Fi setting that is "automagically" turned on to use Private Addressing which means the iPhone generates a different MAC for each network.

In the iPhone Settings > Wi-Fi You can disable this for a specific network or networks which means you will only get one entry in the list which is the original Wi-Fi Address (MAC) shown in Settings > General > about.

I now just have one UniFii entry for my iPhone regardless off which of the two networks it is on. :)


Note that the multiple MAC entries for different networks also applies to Apple Watches, and I cannot find a setting to disable it. I get different MAC addresses for my normal and guest networks.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Oct 25, 2020 9:07 am
FlyingDiver offline
User avatar
Posts: 4843
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: New Plugin - miniUniFi (minimal UniFi access)

Pre-release 0.0.4 now available: https://github.com/FlyingDiver/Indigo-m ... /tag/0.0.4

Save session data so the plugin doesn’t have to log into the controller every poll
Added SSL certificate verification option
Also added test code for UDMP detection
Fixed name caching issue
Time offline added to UI Status
Added “offline_seconds” state
Misc fixes

Added UniFi devices, no detection logic yet

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Oct 25, 2020 3:19 pm
Doctor Q offline
Posts: 26
Joined: Feb 18, 2020

Re: New Plugin - miniUniFi (minimal UniFi access)

Watching this with interest on GitHub. Like C-Span for code heads.


Sent from my iPad using Tapatalk

Posted on
Sun Oct 25, 2020 3:59 pm
autolog offline
Posts: 3403
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: New Plugin - miniUniFi (minimal UniFi access)

FlyingDiver wrote:
[... Note that the multiple MAC entries for different networks also applies to Apple Watches, and I cannot find a setting to disable it. I get different MAC addresses for my normal and guest networks.

You can disable from your Apple Watch. Go to Settings (on your Apple Watch ) > Wi-Fi > Select normal network > Uncheck Private Address.
Repeat for your Guest network.

Hopefully that will work for you. :)

Apple Support document is here: https://support.apple.com/en-gb/HT211227

Posted on
Mon Oct 26, 2020 8:52 am
FlyingDiver offline
User avatar
Posts: 4843
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: New Plugin - miniUniFi (minimal UniFi access)

New test release: https://github.com/FlyingDiver/Indigo-m ... tag/0.0.10

Now working for UDM Pro controllers
Controller type auto-detect. Menu removed from device configuration.
Added status for UniFi devices.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Oct 26, 2020 9:26 am
FlyingDiver offline
User avatar
Posts: 4843
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: New Plugin - miniUniFi (minimal UniFi access)

Question - should I automatically set the name of newly created devices to the name the UniFi controller knows that device by? It would be a little confusing because the field in the device creation dialog box would not reflect the given name.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Oct 26, 2020 9:46 am
autolog offline
Posts: 3403
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: New Plugin - miniUniFi (minimal UniFi access)

FlyingDiver wrote:
Question - should I automatically set the name of newly created devices to the name the UniFi controller knows that device by? It would be a little confusing because the field in the device creation dialog box would not reflect the given name.


You could add an option in the Edit device settings to do that if checked.

Alternatively only change it if the current name starts with "new device", so you don't overwrite it if someone has already changed it. :)

Who is online

Users browsing this forum: No registered users and 1 guest