Ubiquiti Unifi Binding Feature Discussion

Hi, I’m having the same issue now. Updated my Unifi Controller 2 days ago and realized today that openHAB isn’t able to communicate with it now. Is there any solution meanwhile to get that back running?

Hi,
I also have since several days after updating my Unifi controller towards software version 6.0.43; that the Unifi binding cannot communicate with the controller anymore. I get the following error with Unifi snapshot build 2.5.5:

'unifi:controller:home' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING

2021-01-10 14:46:01.356 [hingStatusInfoChangedEvent] - 'unifi:controller:home' changed from INITIALIZING to OFFLINE (CONFIGURATION_ERROR): Invalid hostname - please double-check your configuration

The hostname (IP-address) has not changed, and I can still manually login with the openhab account on my Unifi controller.

Unfortunately, they changed the way how to communicate with the Controller
The binding is also not reflecting the new two-factor authentication :frowning:

Hopefully, the author of this binding can help to get it back to work

the same does not work rasberry Pi openHAB 3.0
UniFi Cloud Key Gen2 software version 6.0.43

Unifi ctrl 6.0.43 + Openhab 2.5.x working fine for me (just upgraded to .43 though…)
2FA is not essential, just add a read-only user without 2FA.

Hi,
I did a quick change of the Unifi binding using Seaside implementation for Protect login.
Thanks Seaside for the protect implementation.

Consider it like pre-alpha, Im only using it to have presence of mobile devices, its built for openhab 3.0.

Link to the binding
Link to repo with example how I use the binding

4 Likes

Hi Patrik,

thanks for working on this binding!!
Since it is a v3.1 binding, please let me ask if it also will work with v3.0 stable or is there any trouble expected?

Regards,
Sascha

Hi,
Yes, I’m running it on my openhab 3.0 system. I can report that the presence part works which is the only part I use.
I will push the code to the repo and then maybe people can improve if it has any fundamental problems or code-breaking rules. Then we might raise a pull request and get the changes approved and included in the official repo. So this is just a POC to make it work and should be improved so the binding still supports the traditional Unifi controller as the Protect, based on config.

1 Like

Great! I will try it and give you a feedback soon. Thanks again!

1 Like

Hi @pagm,

Thank you for taking a stab at this, unfortunately it is still not working on my system…
This is my system: Raspberry Pi 4, OH3.0.1 Release, Unifi controller 6.0.43 on CKG2+.

This is the log I’m seeing:

2021-02-01 18:47:21.946 [DEBUG] [.handler.UniFiControllerThingHandler] - Initializing the UniFi Controller Handler with config = UniFiControllerConfig{host = 192.168.xxx.xxx, port = 8443, username = xxxxxx, password = *****, refresh = 10}
2021-02-01 18:47:22.059 [TRACE] [nal.api.model.UniFiControllerRequest] - >> GET https://192.168.xxx.xxx:8443/api/auth/login
2021-02-01 18:47:22.234 [DEBUG] [nal.api.model.UniFiControllerRequest] - Key: X-CSRF-Token, value:
2021-02-01 18:47:22.322 [TRACE] [nal.api.model.UniFiControllerRequest] - >> POST https://192.168.xxx.xxx:8443/api/auth/login
2021-02-01 18:47:22.355 [DEBUG] [.handler.UniFiControllerThingHandler] - Scheduling refresh job every 10s
2021-02-01 18:47:22.372 [TRACE] [.handler.UniFiControllerThingHandler] - Executing refresh job
2021-02-01 18:47:22.380 [DEBUG] [.handler.UniFiControllerThingHandler] - Refreshing the UniFi Controller unifi:controller:home
2021-02-01 18:47:22.440 [DEBUG] [nal.api.model.UniFiControllerRequest] - Key: X-CSRF-Token, value:
2021-02-01 18:47:22.450 [TRACE] [nal.api.model.UniFiControllerRequest] - >> GET https://192.168.xxx.xxx:8443/proxy/network/api/self/sites

The debug log suggests that the binding is still attempting to connect with port 8443, whereas in @Seaside’s binding the debug log simply says:

2021-02-01 18:57:20.532 [DEBUG] [al.model.request.UniFiProtectRequest] - >> GET https://192.168.xxx.xxx/api/auth/login

I tried both using the mainUI and .things file to create the controller thing but neither made any difference…

On a side note, I noticed my Raspberry Pi was running at 100% for a while after OH reboots… Not sure if it’s this binding or other things causing it but it seems better after I removed it from the addons folder.

Hi,
I saw I missed mentioning that the port needs to be configured to 443. The default value is 8443 which is the default port when running Unifi Controller standalone.
I have updated the Readme file and here is the example

Bridge unifi:controller:home "UniFi Protect Controller" [ host="...", port=443, username="...", password="...", refresh=60  ] {
  Thing wirelessClient iPhone "My iPhone" [ cid="xx:xx:xx:xx:xx:xx", site="default", considerHome=180 ]
}

Thank you! I must have overlooked the port number. Are you accessing Unifi with a different port (egress?)?
It’s working for me now, I’ll keep trying different features and let you know if I run into any issues again.

Thank you so much for making the binding work again.

Hey guys!

I’m so sorry I’ve been MIA, I had some major life changes happen over the last 6 months. I got a new job that required me to move which meant I lost access to all my UniFi equipment. Since then, I have not even had the time to get my OH back up and running :frowning:

Hopefully this weekend I’ll finally have some free time to get myself bootstraped. I feel like I’ve abandoned this project (and you guys), and I don’t like that :wink:

Be back soon!
-Matthew

8 Likes

Welcome back!

If there’s anything I can do to help debug the buffer issue I’ll gladly help.

Good to have you back @mgbowman. Hope things continue to settle down for you.

@lolodomo and I were trying to sort out this buffer capacity issue, but we were unclear about how to handle the HttpResponseException.

Thats called a life! :wink:

Nice to have you back with us again anyway. Hopefully things will start settle down for you.

@pagm It took a while to find some time for my feedback.
The setup was easy and everything works without any issue instantly.
Mainly I also use the binding for presence detection, but the other channels are working properly as well. Since you are using presence only, this might be a helpful info for you :slight_smile:

Once again, thanks for working on this binding! :+1:

I added a new config parameter called cloudkey for the Unifi controller thing. The purpose of this is to configure if the binding should be run in original mode or use the new authentication with the API paths for Cloudkey Gen 2. True means Cloudkey Gen 2 mode and false(default value) run as before.

The code is available here that can be used to improve change before we hopefully can get it in the right Openhab code repo.

I also created a new build with the new configuration parameter, the built binding works on Openhab 3 and can be downloaded here

Thanks to Mattew for the Unifi binding and Seaside for the authentication part for CK gen2

4 Likes

Unifi Binding works again on Cloudkey Gen 2. Thanks a lot

Seems like all Unifi Controllers have moved over to the new authentication and API paths, any chance that those of us still using OpenHab 2.x will get an update to this binding?

2 Likes