Trouble setting up unifi integration / component - Cloud Key Gen 2

I feel like this should be straight forward, but its not working.

Im trying to set up the unifi integration.

I have a Cloud Key Gen 2 set up as the controller.

I enter the IP address of the controller in the host line.
Then for the username/password, Im copy pasting the credentials that sucessfuly log me in to the controller at the above IP.

Yet when I do this, I get “bad user credentials”

Any ideas?

It shouldnt be anything special. Admin account? Latest and greatest sw version?

Sorry for the delayed reply.

Using a CK2+ with up to date software.

My config is:

device_tracker:
  - platform: bluetooth_tracker
    track_new_devices: no
  - platform: unifi
    host: 192.168.1.7
    username: admin
    password: *****

The IP and username/pw work fine to log in on my computer.

Yet I get the error cannot connect.

Does it matter that I have cloud access enabled on Unifi, as well as Im using home assistant cloud?

No cloud access shouldn’t affect this. Can you try upgrading to the 0.97 beta? There are tons of changes to UniFi component.

Sure. Updating now. Does it matter how I install it (add on, integration, or config)?

Updated to beta. Installed via integrations. Still getting bad user credentials.

Connected to UniFi at 192.168.1.7 but not registered.

6:57 PM components/unifi/controller.py (WARNING) - message first occured at 6:56 PM and shows up 2 times

Error connecting to the UniFi controller at 192.168.1.7

6:57 PM components/unifi/controller.py (ERROR)

So I tried it via configuration.yaml. In the previous hass.io version, it would just give me an error upon restart and not work.

This time, I got a “new devices found” message so I was thinking it worked. But then it just took me to the integration page, where it showed up under unconfigured. And then Im back to the same issue, where it gives me “bad user credentials”

And I cant install it via add-ons because the webui wont show up, since Im using hass.io cloud. So yeah.

I think you may need to add the port number to your config. When you log in from your computer you’re probably reaching a page similar to this…


…where you choose whether to Configure the Cloud Key (hardware) or Manage the Controller (software). The Controller is what HA needs access to so look at the port number in the URL after you select ‘Manage’ (it’s probably 8443).

…or just try:

device_tracker:
  - platform: bluetooth_tracker
    track_new_devices: no
  - platform: unifi
    host: 192.168.1.7
    port: 8443
    username: admin
    password: *****

Have port numbers (they are there by default) for both setups. Still get the same issue with our without. How do I verify Im using the correct port? (although it should be 8443…)

Oh yeah, you’re right.

I’m not familiar with the gen. 2 CK, maybe they changed the default port number?

You need to look at the port number in the URL after you select ‘Manage’. It should be something like;
https://192.168.1.7:8443/manage/site/default/dashboard, where 8443 is the port number.

If you have more than one Site configured in Unifi you might also need to add the site_id, which is default in the example URL given above.

So I only have one site. But the url for my CK goes to https://192.168.1.7/manage/overview

No port numbers in the url.

I think the default is 8443 but I cant figure out where to actually verify that…

Hmm, that’s different from the 1st gen. :thinking:

If no port # is showing then the default for SSL connections (https://) is being used, which is 443.
It seems unlikely, but 443 might be forwarded to another port in the CK by default. You’d need to check your port-forwarding settings in the Controller to confirm. <-- Scratch that, it wouldn’t matter anyway. HA should still be able to connect.

Since the default in HA is 8443, you need to manually configure it to 443:

device_tracker:
  - platform: bluetooth_tracker
    track_new_devices: no
  - platform: unifi
    host: 192.168.1.7
    port: 443
    username: admin
    password: *****

Aaaaa. I just figured out what the issue is.

I have a completely seperate login for unifi local access (which is my ubiquity login) then I do for cloud access (admin/password). It makes no sense. But finally got it to work

1 Like

Ok so I spoke to soon apparently. I got the integration to work. But when I add the device tracker (with the now working login), I get the following error:

Failed to connect to Unifi. Error:
You will need to restart hass after fixing.

device_tracker:
  - platform: bluetooth_tracker
    track_new_devices: no
  - platform: unifi
    host: 192.168.1.7
    port: 8443
    username: xxx
    password: xxx

Did you try port: 443?

Just did. Same error.

Weird. Ubiquity may have changed methods used to remotely access the Controller with Gen 2. Maybe someone who has experience integrating that specific model will chime in.

You might want to update the post title to include Cloud Key Gen. 2…?

Looks like everything is workign now in .97. I have one other question about configuration for it, probably misreading something in the docs.

Im trying to drop the detection time down, as it takes 5 minutes before Im marked as away.

Does this look correct? It doesnt seem to have affected the detection time.

unifi:
  controllers:
    - host: unifi
      site: default
      detection_time: 120