Ubiquiti Unifi Binding Feature Discussion

ubiquiti
unifi
Tags: #<Tag:0x00007f51e56f80e0> #<Tag:0x00007f51f009fe68>

(Matthew) #827

So here’s the major list of features I’ve seen requested:

  • PoE Support
  • Toggling LED on/off for APs
  • Toggling SSIDs on/off for Sites (maybe could be done per AP)

The other core things that need to be implemented are:

  • Use the common HttpClient instance (implemented)
  • OH Actions for simplifying rules
  • Support UoM
  • Discovery

What am I missing here?


(Matthew) #828

I just pushed a new build that uses the common HttpClient provided by OH and some other minor updates. Can you all please update to the latest and report back. I would like to stop with this build and open a new PR before doing any further development.

Build #98: org.openhab.binding.unifi-2.5.0-SNAPSHOT.jar

Thanks!


(Kim Andersen) #829

A bit Off topic… But how is your house building coming, Matt?


(Matthew) #830

I’m actually wiring the last electrical panel right now.

We’re getting closer to being done on the inside. The crappy winter weather has held us up outside but thankfully that’s starting to change. I’m hoping we’re moved in by the end of April!


(Kim Andersen) #831

Sounds great… remember to keep us posted about the whole building when finished :slight_smile:


(Matthew) #832

I forgot to mention you need to be running a 2.5.0-SNAPSHOT version of OH as the required change to ExtensibleTrustManager isn’t in 2.4


(Anders Alfredsson) #833

Is 2.5.0-M1 enough?


(Matthew) #834

Just rolled back to M1 and yes it works.

The PR was merged into ESH on Jan 2nd…


(Max1968) #835

For me it doesnt work on 2.5.0-M1. With a previous working configuration, I uninstalled the unifi binding using Paper UI and then uploaded the Build #98 to the addons directory. Getting the error message

Status: OFFLINE - CONFIGURATION_ERROR Error establishing an SSL connection with the UniFi controller

in PaperUI and the following in logs:

2019-03-11 16:57:10.954 [hingStatusInfoChangedEvent] - 'unifi:wirelessClient:509a65e0' changed from OFFLINE (BRIDGE_OFFLINE): The UniFi Controller is currently offline. to UNINITIALIZED
2019-03-11 16:57:10.955 [hingStatusInfoChangedEvent] - 'unifi:wirelessClient:509a65e0' changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)
2019-03-11 16:57:10.955 [hingStatusInfoChangedEvent] - 'unifi:controller:55832b6c' changed from OFFLINE (CONFIGURATION_ERROR): Error establishing an SSL connection with the UniFi controller to UNINITIALIZED
2019-03-11 16:57:10.980 [hingStatusInfoChangedEvent] - 'unifi:controller:55832b6c' changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)
2019-03-11 16:58:01.180 [hingStatusInfoChangedEvent] - 'unifi:wirelessClient:509a65e0' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to UNINITIALIZED (BRIDGE_UNINITIALIZED)
2019-03-11 16:58:01.183 [hingStatusInfoChangedEvent] - 'unifi:controller:55832b6c' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING
2019-03-11 16:58:01.270 [hingStatusInfoChangedEvent] - 'unifi:controller:55832b6c' changed from INITIALIZING to OFFLINE (CONFIGURATION_ERROR): Error establishing an SSL connection with the UniFi controller
2019-03-11 16:58:01.279 [hingStatusInfoChangedEvent] - 'unifi:wirelessClient:509a65e0' changed from UNINITIALIZED (BRIDGE_UNINITIALIZED) to INITIALIZING
2019-03-11 16:58:01.281 [hingStatusInfoChangedEvent] - 'unifi:wirelessClient:509a65e0' changed from INITIALIZING to OFFLINE (BRIDGE_OFFLINE): The UniFi Controller is currently offline.

(Matthew) #836

Can you try build #100: org.openhab.binding.unifi-2.5.0-SNAPSHOT.jar

After talking with @martinvw I added a fallback default SSL trust manager.

bendie:~ mgbowman$ ssh openhab2

                          __  _____    ____
  ____  ____  ___  ____  / / / /   |  / __ )
 / __ \/ __ \/ _ \/ __ \/ /_/ / /| | / __  |
/ /_/ / /_/ /  __/ / / / __  / ___ |/ /_/ /
\____/ .___/\___/_/ /_/_/ /_/_/  |_/_____/
    /_/                        2.5.0.M1
                               Milestone Build

openhab> bundle:list | grep -i unifi
256 │ Active   │  80 │ 2.5.0.201903111759     │ UniFi Binding

You should see something like this in your logs if you enable DEBUG for the UniFi binding:

2019-03-11 20:00:57.505 [DEBUG] [org.openhab.binding.unifi           ] - BundleEvent INSTALLED - org.openhab.binding.unifi
2019-03-11 20:01:01.394 [DEBUG] [org.openhab.binding.unifi           ] - BundleEvent RESOLVED - org.openhab.binding.unifi
2019-03-11 20:01:01.395 [DEBUG] [org.openhab.binding.unifi           ] - BundleEvent STARTING - org.openhab.binding.unifi
2019-03-11 20:01:01.400 [DEBUG] [fi.internal.UniFiThingHandlerFactory] - Registering Trust Manager Provider : UniFiTrustManagerProvider{peer: 'UniFi'}
2019-03-11 20:01:01.401 [DEBUG] [org.openhab.binding.unifi           ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory}={service.id=510, service.bundleid=256, service.scope=bundle, component.name=org.openhab.binding.unifi.internal.UniFiThingHandlerFactory, component.id=334} - org.openhab.binding.unifi
2019-03-11 20:01:01.405 [DEBUG] [org.openhab.binding.unifi           ] - BundleEvent STARTED - org.openhab.binding.unifi
2019-03-11 20:01:01.426 [DEBUG] [.handler.UniFiControllerThingHandler] - Initializing the UniFi Controller Handler with config = UniFiControllerConfig{host = unifi, port = 8443, username = operator, password = *****, refresh = 10}
2019-03-11 20:01:01.426 [DEBUG] [.handler.UniFiControllerThingHandler] - Registering Trust Manager Provider : UniFiTrustManagerProvider{peer: 'unifi:8443'}
2019-03-11 20:01:01.687 [DEBUG] [.handler.UniFiControllerThingHandler] - Scheduling refresh job every 10s
2019-03-11 20:01:01.688 [DEBUG] [.handler.UniFiControllerThingHandler] - Refreshing the UniFi Controller unifi:controller:home

The two key log statements are the Registering Trust Manager Provider lines

If it doesn’t work for you, I’ll dig deeper.


(Max1968) #837

this one works like a charm, thanks a lot !


(Porthos) #838

Hi, first all thanks to Matthew for this binding and its development.
Below is my working configuration up to version OH2 2.5.0 ~ S1549-1 build # 1549.

unifi.things

 Bridge unifi:controller:home "UniFi Controller" [ host="192.168.1.148", port=8443, username="name", password="password", refresh=10 ] {
	Thing wirelessClient wojteksPhone "Wojtek's Phone" [ cid="0C:BE:3B:12:27:D1", site="default", considerHome=51 ]
	Thing wirelessClient anitkasPhone "Anitka's iPhone" [ cid="48:34:38:A0:43:23", site="default", considerHome=51 ]
}

unifi.items

Switch   WojteksPhone           "Wojtek's Phone [MAP(unifi.map):%s]"    <network> { channel="unifi:wirelessClient:home:wojteksPhone:online" }
String   WojteksPhoneSite       "Wojtek's Site [%s]"                 <pusty>     { channel="unifi:wirelessClient:home:wojteksPhone:site" }
String   WojteksPhoneMAC        "Wojtek's MAC [%s]"                  <pusty>     { channel="unifi:wirelessClient:home:wojteksPhone:macAddress" }
String   WojteksPhoneIP         "Wojtek's IP [%s]"                   <pusty>     { channel="unifi:wirelessClient:home:wojteksPhone:ipAddress" }
String   WojteksPhoneAP         "Wojtek's AP [%s]"                   <pusty>     { channel="unifi:wirelessClient:home:wojteksPhone:ap" }
String   WojteksPhoneESSID      "Wojtek's ESSID [%s]"                <pusty>    { channel="unifi:wirelessClient:home:wojteksPhone:essid" }
Number   WojteksPhoneRSSI       "Wojtek's RSSI [%d]"                 <pusty>     { channel="unifi:wirelessClient:home:wojteksPhone:rssi" }
Number   WojteksPhoneUptime     "Wojtek's Uptime [%d]"      <pusty>   (gUnifi)   { channel="unifi:wirelessClient:home:wojteksPhone:uptime" }
DateTime WojteksPhoneLastSeen   "Wojtek's Last Seen [%1$tH:%1$tM:%1$tS]"  <pusty>  { channel="unifi:wirelessClient:home:wojteksPhone:lastSeen" }

The next OH2 update to # 1552, 1553, 1554 caused that no data is downloaded from the Unifi controller. If I uninstall binding via Paper UI and put org.openhab.binding.unifi-2.4.0-SNAPSHOT.jar file to the addons directory everything works without a problem. Please help me understand where the mistake lies.


(Matthew) #839

If everything was working in S1549 but doesn’t in the latest snapshot, something had to change :thinking:

I’ll update to the latest snapshot later this evening and see if I can figure out what’s going on.


(Matthew) #840

Can you also provide the bundle version you’re using?

Build #100 is 2.5.0.201903111759


(Porthos) #841

thank you Matthew,
here is the bundle version (2.4.0 - jar file in addons folder, 2.5.0 - comes with openHAB 2.5.0~S1554-1 (Build #1554))

openhab> bundle:list | grep UniFi
256 │ Active │  80 │ 2.4.0.201812081314    │ UniFi Binding

openhab> bundle:list | grep UniFi
257 │ Active │  80 │ 2.5.0.201903112315    │ UniFi Binding

(Matthew) #842

The snapshot version of the binding is just what’s in master. My jenkins build server is building the “development” version from my repo.

Can you try installing build #100? org.openhab.binding.unifi-2.5.0-SNAPSHOT.jar


(Porthos) #843

bad news, it does not work at all. As if all things are online (bridge and phones) but no data is downloaded from the UniFi controller. When I change the file from version 2.5.0 to 2.4.0 everything reacts immediately. I do not understand it completely :confused:


(Matthew) #844

I’m sorry to hear that… I will try upgrading to the snapshot you’re running and see if I can reproduce your issue. It will be over the weekend as I’m quite busy with my house - I’m installing the last electrical panel tomorrow!


(Porthos) #845

Matthew, thank you very much for your help and sincerely appreciate.


(Matthew) #846

I’m sorry @porthos but I can’t reproduce your issue.

Here’s what I did…

systemctl stop openhab2
openhab-cli clean-cache
vi /etc/apt/sources.list.d/openhab2.list # disabled "Testing" / enabled "Snapshot"
apt-get update
apt-get install openhab2 # upgraded 2.5.0~M1-1 to 2.5.0~S1555-1
systemctl start openhab2
ssh openhab2
openhab> bundle:install https://jenkins.otr.mx/job/openhab2-unifi-binding/100/artifact/addons/binding/org.openhab.binding.unifi/target/org.openhab.binding.unifi-2.5.0-SNAPSHOT.jar
Bundle ID: 206
openhab> bundle:start 206

And here are my results…

bendie:~ mgbowman$ ssh openhab2

                          __  _____    ____
  ____  ____  ___  ____  / / / /   |  / __ )
 / __ \/ __ \/ _ \/ __ \/ /_/ / /| | / __  |
/ /_/ / /_/ /  __/ / / / __  / ___ |/ /_/ /
\____/ .___/\___/_/ /_/_/ /_/_/  |_/_____/
    /_/                        2.5.0-SNAPSHOT
                               Build #1555

openhab> bundle:list | grep -i unifi
206 │ Active │  80 │ 2.5.0.201903111759    │ UniFi Binding 

/var/log/openhab2/openhab.log

2019-03-15 17:14:35.544 [DEBUG] [org.openhab.binding.unifi           ] - BundleEvent INSTALLED - org.openhab.binding.unifi
2019-03-15 17:14:45.758 [DEBUG] [org.openhab.binding.unifi           ] - BundleEvent RESOLVED - org.openhab.binding.unifi
2019-03-15 17:14:45.760 [DEBUG] [org.openhab.binding.unifi           ] - BundleEvent STARTING - org.openhab.binding.unifi
2019-03-15 17:14:45.761 [DEBUG] [org.openhab.binding.unifi           ] - BundleEvent STARTED - org.openhab.binding.unifi
2019-03-15 17:14:45.773 [DEBUG] [fi.internal.UniFiThingHandlerFactory] - Registering Trust Manager Provider : UniFiTrustManagerProvider{peer: 'UniFi'}
2019-03-15 17:14:45.780 [DEBUG] [org.openhab.binding.unifi           ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory}={service.id=339, service.bundleid=206, service.scope=bundle, component.name=org.openhab.binding.unifi.internal.UniFiThingHandlerFactory, component.id=188} - org.openhab.binding.unifi
2019-03-15 17:14:45.897 [DEBUG] [.handler.UniFiControllerThingHandler] - Initializing the UniFi Controller Handler with config = UniFiControllerConfig{host = unifi, port = 8443, username = operator, password = *****, refresh = 10}
2019-03-15 17:14:45.897 [DEBUG] [.handler.UniFiControllerThingHandler] - Registering Trust Manager Provider : UniFiTrustManagerProvider{peer: 'unifi:8443'}
2019-03-15 17:14:46.291 [DEBUG] [.handler.UniFiControllerThingHandler] - Scheduling refresh job every 10s
2019-03-15 17:14:46.299 [DEBUG] [.handler.UniFiControllerThingHandler] - Refreshing the UniFi Controller unifi:controller:home

/var/log/openhab2/events.log

2019-03-15 17:14:45.875 [hingStatusInfoChangedEvent] - 'unifi:controller:home' changed from UNINITIALIZED to INITIALIZING
2019-03-15 17:14:46.309 [hingStatusInfoChangedEvent] - 'unifi:controller:home' changed from INITIALIZING to ONLINE
2019-03-15 17:14:46.310 [hingStatusInfoChangedEvent] - 'unifi:wirelessClient:home:matthewsPhone' changed from UNINITIALIZED to INITIALIZING
2019-03-15 17:14:46.327 [hingStatusInfoChangedEvent] - 'unifi:wirelessClient:home:matthewsPhone' changed from INITIALIZING to ONLINE
2019-03-15 17:14:46.482 [vent.ItemStateChangedEvent] - MatthewsPhone changed from NULL to ON
2019-03-15 17:14:46.488 [vent.ItemStateChangedEvent] - MatthewsPhoneSite changed from NULL to Home
2019-03-15 17:14:46.488 [vent.ItemStateChangedEvent] - MatthewsPhoneUptime changed from NULL to 3956
2019-03-15 17:14:46.502 [vent.ItemStateChangedEvent] - MatthewsPhoneAP changed from NULL to Living Room
2019-03-15 17:14:46.507 [vent.ItemStateChangedEvent] - MatthewsPhoneRSSI changed from NULL to 41
2019-03-15 17:14:46.508 [vent.ItemStateChangedEvent] - MatthewsPhoneESSID changed from NULL to Home
2019-03-15 17:14:46.508 [vent.ItemStateChangedEvent] - MatthewsPhoneLastSeen changed from NULL to 2019-03-15T17:14:42.000+0200
2019-03-15 17:14:56.539 [vent.ItemStateChangedEvent] - MatthewsPhoneUptime changed from 3956 to 3970
2019-03-15 17:14:56.539 [vent.ItemStateChangedEvent] - MatthewsPhoneLastSeen changed from 2019-03-15T17:14:42.000+0200 to 2019-03-15T17:14:56.000+0200

I would try this…

  1. Remove any UniFi binding version you manually copied to the addons folder
  2. Uninstall any UniFi binding version you installed via PaperUI
  3. Stop OH2
  4. Clear the Cache
  5. Start OH2
  6. Install & start build #100 as I did above via the OH2 console

Good luck!