Ubiquiti Unifi Binding Feature Discussion

Happy New Year!

Hey guys, sorry for my absence. I had a super busy holiday season with my family and after surviving that, I just had to take a ski vacation :slight_smile: I’m finally back home! I have to put some effort into setting up my dev environment as I got a new laptop for Christmas - yay!

With all the recent changes to the tree, I have some work todo to get everything up to date with the current status of master. Once everything’s all sync’d up, I will begin working on new features that have been requested (and fixing any bugs you guys have uncovered).

I will report back in the coming days!

Matthew

4 Likes

Welcome back Matt. I guess the ski vacation didn´t result in any broken bones then, (or at least arm and hands) :smiley:

Since today I am able to switch on and off POE ports using the “EXEC” binding. Allthough I now am happy with the fact I can switch off stuff when leaving home or switch on stuff when I arrive home, I am not very fond of the steps I had to take. So dear @mgbowman, if it is possible to integrate POE in the binding I would be the first one to test :joy:

Hey Han!

I just took the time last night to get my local OH server updated to 2.5.1-2 (testing/main) and next is to get my dev environment up and running (going to start fresh here considering the repo / namespace changes).

I took this opportunity of starting with a fresh OS to sort / organise my data (something I’ve been needing to do) and I’m almost done. Unfortunately my free time is rather limited as I’ve got some major IRL work projects because it’s the beginning of the year :frowning:

Things will settle down over the next week or so and I’ll have more time to hack away at home!

I promise promise promise I will start development again very very very soon!

Matthew

1 Like

For everybody who wants to have some detail:

things file:

// "%2$s" will be replace by the input channel command, this makes it possible to use one command line with different arguments.
// e.g: "ls" as <YOUR COMMAND> and "-a" or "-l" as additional argument set to the input channel in the rule.
Thing exec:command:poe_actions [ command="/openhab/conf/scripts/poe.sh %2$s", interval=0, autorun=false ]

item file:

//POE Stuff
// state of the execution, is running or finished
Switch poe_actions_Run {channel="exec:command:poe_actions:run", autoupdate="false"}
// Arguments to be placed for '%2$s' in command line
String poe_actions_Args {channel="exec:command:poe_actions:input"}
// Output of command line execution 
String poe_actions_Out {channel="exec:command:poe_actions:output"}	

rule file (presence is arranged through the Unifi binding):

rule "Presence changing"
when 
    Item Presence changed
then { 
    logInfo("Rule presence 03", "Presence just changed!")   
    switch (Presence.state) {
		case ON : { 
			logInfo("Rule presence 03", "Presence just became ON!")
    		poe_actions_Args.sendCommand("192.168.1.15 5 auto")                     // Switch ON telephone 
            poe_actions_Run.sendCommand(ON)
                 }
		case OFF : { 
			logInfo("Rule presence 03", "Presence just became OFF!")
    		poe_actions_Args.sendCommand("192.168.1.15 5 shutdown")                 // Switch OFF telephone
            poe_actions_Run.sendCommand(ON)
           
	    }   
    }  
}     
end             

script file:

#!/bin/bash

NODE=$1                         # IP address
INTERFACE=$2                    # Port number
MODE=$3                         # auto / shutdown

sshpass -p PASSWORD ssh -oStrictHostKeyChecking=no USER@$NODE '(echo "enable" ; echo "configure" ; echo "interface 0/'$INTERFACE'" ; echo "poe opmode '$MODE'" ; echo "exit" ; echo "exit" ; echo "exit") | telnet localhost 23 ; exit;'

quit a bit of hacking :slightly_smiling_face:, make sure the script file is executable, SSHPAS is installed, the EXEC binding is installed and that the openhab user is allowed to run the file. I btw use a Docker OH2.5 image

Back with an update,

My dev env has been restored and I have merged all my local work and sorted my github config considering the changes in “master”. I’m finally back in business :slight_smile:

The latest build includes all my local (unpublished) improvements / features that had been (partially?) implemented and still in need of testing :see_no_evil:

Please see the latest README for more

Currently I’m using this with 2.5.1 and the latest UniFi Controller on a CKG2+

Please update to the latest build and report back if you have any issues.

Cheers,
Matthew


Build #111: org.openhab.binding.unifi-2.5.2-SNAPSHOT.jar - 2.5.2.202001271706


How I update using the cli

// get the unifi bundle id (first column)
openhab> bundle:list | grep -i unifi
282 │ Active │  80 │ 2.5.1                   │ openHAB Add-ons :: Bundles :: UniFi Binding

// refresh (-r) bundle 282 (unifi) after updating using [url] - copy from above
openhab> bundle:update -r 282 [url]

// check the new version was installed
openhab> bundle:list | grep -i unifi
282 │ Active │  80 │ 2.5.2.202001271706      │ openHAB Add-ons :: Bundles :: UniFi Binding
3 Likes

I installed the latest build and it works well so far.
A problem I have since a while is that iPhone XS (on IOS 13.3) is disconnecting often. It seems to go into sleep mode and disconnects from wifi.
Another iPhone 8 (on IOS 13.3) is working like a charm.
Anyone with the same behavior?

1 Like

You don’t by chance have “Low Power Mode” enabled when this happens?

AFAIK, iOS will disconnect / disassociate the wireless antenna while in LPM which will make the phone appear as offline in the UniFi controller.

Thanks for your fast response! No low power mode enabled. iPhone is loosing/disconnect from wireless multiple times per day.

Do the disconnects happen for an extended period of time?

I’m assuming you haven’t changed considerHome and it’s using the default of 180secs / 3mins.

If your phone is disconnecting for more than 3 minutes, it sounds like more of a local Wi-Fi issue and not the binding :thinking:

Matthew

@mgbowman I have a question about the initial state of the online channel. At startup, or when a thing is created, if a wireless client is connected to the network, the online channel will be set to ON. However, if the wireless client is not connected to the network, the ‘online’ channel is NULL. Was this behavior intentional?

It becomes a little more relevant in a multi-site environment, because the state of the online channel will never change from NULL until the client connects to the network in that site (which could be days or weeks).

Persistence can help, but if you’re persisting on every change (which is typical when using restoreOnStartup), restoreOnStartup will be of no use until the online channel has changed state at least once.

You can “force” openhab to update the item by saving its last state in a map.db. Its typical for openhab, the items doesnt update at start up. The binding could “ask” the device though, and then it update. But I guess it depends on several things.

I understand. But, in this scenario, there is no last state (other than NULL).

I have persistence set up to save all items’ state using the everyChange and restoreOnStartup strategy. However, if I add a wireless client thing, and the person associated with that thing is not there (and may not be there for weeks or months), the initial state of the item linked to the online channel will be NULL, and will stay NULL until the person connects to the network for the first time.

My quick workaround to the issue is to use the console to set the initial state to OFF. However, I don’t feel this should be necessary.

smarthome:send Person1Online OFF

I upgraded my UniFi equipment with the UDM-Pro. This gateway has a built in UniFi controller and the connection seems to be changed so the plugin cannot connect to it.
Are there plans to support these new controllers UDM and UDM-Pro?

2 Likes

Hi @tinomaus and welcome to the community!

Unfortunately I do not have nor do I plan to purchase a UDM or UDM Pro. If I’m being completely honest, I probably won’t buy anymore Ubiquiti gear at all because, from my point of view, the quality of the company and its products has declined and turned me off as a returning customer :frowning:

Now with that being said, I still plan to support / develop my Unifi binding, but I won’t be able to integrate / support new devices that I do not own unless you guys want to get together and start a general “hardware fund for the development of the OH UniFi binding” :slight_smile:

Lastly, I just want to let everybody know that I’m still around but just haven’t had any free time to work on the binding - the beginning of the year is always super busy in my office leaving very little “free spirit” when I get home in the evenings :frowning:

Matthew

2 Likes

not sure if anybody else tested the new binding but I still get the same issue (things are always ON). When I install the 2.4 binding it starts working back again.

Regards,

I am thinking about a “guest presence” detection in my OH setup. It would be handy if I can get the number of clients on my guest WiFi to detect if there is somebody else in my house besides family members.

Can you consider this as a feature request? :slight_smile:

Did you configure your devices in openHAB with the MAC address? This is working for me in 2.5.x.

Maybe you should use the UDM-Pro as new USG, then you can use a normal cloud-key or another Unifi Controller to work with OH plugin.

I suppose the UDM-PRO can be adopted

Does it make any sense?
Andrea

No, i used ip addresses as I did in openhab 2.4. Have you used the built #111 as instructed by Matthew ?