UniFi Network integration - official thread

As a new user of the integration, I’d like to check something that I couldn’t find on this post, the forum or the docs.

I’ve enabled rx/tx sensors and disabled the bulk of them, because I’m just looking for overall values.

I saw the sensor.rx and sensor.tx sensors and it looks like it’s what I’m looking for (having looked at the history now for those sensors).

Are those the overall rx/tx sensors?

As a related question, I also saw sensor.none_rx and sensor.none_tx. What could that be referring to?

Note: My network is set up with a single site (“Default”), in case that matters.

There are no common reporting of rx/tx right now, its probably a client without a name.

Also probably a client with a bad name

1 Like

Thanks for the feedback.

Is this a future possibility, or something that’s fundamentally not possible for this integration?

Unfortunately, my UDR doesn’t support SNMP out of the box. I’ve considered installing it manually, since using it is my first choice.

I’ve also come across a Python script using the router’s API, but haven’t had time to test it. It will require polling though, which is also not ideal. I suppose, if implemented, the integration would do it this way too.

It depends on how it is provided from the network app

Hey all!

Another month and Home Assistant 2024.4.0 release with changes in the UniFi integration.

@xconverge identified an issue with how the integration identifies if UniFi is hosted on Unifi OS or not. Lets hope some of the reconnection issues previously reported was caused by this. Thanks!

This release brings a lot of internal improvements to support expanding the integration in the future.

Just to re-iterate that use local accounts for your Home Assistant connection as cloud accounts will get mandatory MFA and will not be supported.

Try these features out during the beta, feedback is appreciated.

Cheers!

/Robban


Home Assistant 2024.4.0

Home Assistant 2024.4.0 Beta

aiounifi library v76 change log

For feature requests of the integration post an issue at aiounifi github

If you appreciate my work I’m on Github Sponsors.

5 Likes

Hey all!

Another month and Home Assistant 2024.5.0 release with changes in the UniFi integration.

Just to iterate one final time: Cloud accounts with MFA will not be supported, please use a local account instead see this thread

This release we got a few power players providing new functionality, @brunohenrique provided a button to regenerate passwords which fit perfectly with the QR code image entities, now guests can easily get the password and you can always make sure they don’t keep the password longer than you expect. Two requested features was brought in by @kimdv sensor for CPU and Memory utilisation as well as the means to read RX/TX from UniFi device ports, this solves among other things the common request to view WAN data usage. An old issue has been remedied by @wittypluck which is that of old devices laying around not being able to clean up, but now you can.

Honorable mentioning of @mkmer doing an improvement to login hopefully fixing those restart issues where the integration would need a manual retry Handle login non JSON response by mkmer · Pull Request #640 · Kane610/aiounifi · GitHub . This was released with 2024.4.4 just before beta cut off.

Thanks guys!

Try these features out during the beta, feedback is appreciated.

Cheers!

/Robban


Home Assistant 2024.5.0

aiounifi library v76 change log

For feature requests of the integration post an issue at aiounifi github

If you appreciate my work I’m on Github Sponsors.

5 Likes

wow, especially looking forward to this.
tried to add a heart on the PR in the repo, but it cant be done because of already Merged and closed.
Showing my appreciation here :wink:

thank you very much!

1 Like

Kudos to @wittypluck

I believe I misunderstood the new option…

had hoped we would be able to delete all of these individual device_trackers that once might have existed, but are not on the Unifi machine at all:

but we can ‘only’ delete actual devices, can we?

3 Likes

even the latter seems not too straighforward, because the 1 device I would like to delete (it’s a somehow doubly listed Apple TV) wont go, and throws an error on the delete action:

Logger: homeassistant.components.websocket_api.http.connection
Bron: components/websocket_api/connection.py:307
integratie: Home Assistant WebSocket API (documentatie, problemen)
Eerst voorgekomen: 09:09:36 (2 gebeurtenissen)
Laatst gelogd: 09:09:52

[140510836850112] Error handling message: Failed to remove device entry, rejected by integration (home_assistant_error) Marijn from feredacted5c (Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Safari/605.1.15)
[140511011429184] Error handling message: Failed to remove device entry, rejected by integration (home_assistant_error) Marijn from feredacted5c (Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Safari/605.1.15)

besides that, and this might be repeating from above:
I have a lot of ghost device_trackers, and many of them will never ever return to my network, so I want to delete them (not only disable them). I cant from the UI, so I tried to edit the entity_registry, but upon restart, they some how are re-created…

Meaning we can never get rid of these entities in our HA system??

And yes, I checked the Unifi network app itself, they are not listed in the Routers system at all. either on or offline a https://192.168.1.1/network/default/clients/offline

Only way I have found to remove them is to delete the integration and re-add, not ideal.

1 Like

must confess I had the section of devices set to 3 weeks in my Unifi Client devices view, and when I set it to All (meaning no time selection) a few of the returning devices were listed.

However… it made me find several others, even older, that were once registered, but now long gone, so I manually deleted them from the Unifi interface with the Remove button

Even after having done so, and restarted the HA instance (effectively also reloading the integration) they all still were there…

Next I tried to (re-)enable those devices in the HA Integration entities interface, and waited the 30 secs, hoping this would force them to be reregistered of sorts, and when not available, mark them as truly deletable… still nothing,

another HA restart now made a lot of difference, because now, those were showing the red icons

indicating we can delete them from the HA system at last.

Just updated UDMP to new EA version of UnifiOS 4.0.3 and now the integration is unable to start. (same with Unifi Protect BTW).

Only thing in the HA log is “Unable to complete setup”. It does show my local user set up for this integration last login as expected.

Have double checked the account setup and even recreated to see if that would help, but no luck.

Probably shouldn’t have jumped so quickly to the EA version, but I suppose someone has to be the guinea pig.

Anyone else?

1 Like

Are you running a local user or a cloud user?

What error message are you seeing? Enable debug logging for extra information. As I’m not running EA it’s gonna be some time before I can try it myself

Yes, it is a local user.
This is what is in the logs. I will set up debug logging and see if I can get more information.

2024-04-29 11:41:22.602 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: {('unifi', 'd22fc47f1027dda5e30b158cdc2b78ee'): 1542328.627579097}
2024-04-29 11:42:22.852 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: {('unifi', 'd22fc47f1027dda5e30b158cdc2b78ee'): 1542328.627579097}
2024-04-29 11:43:23.094 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: {('unifi', 'd22fc47f1027dda5e30b158cdc2b78ee'): 1542328.627579097}
2024-04-29 11:43:27.978 WARNING (MainThread) [homeassistant.components.unifi] Exception on update maximum recursion depth exceeded
2024-04-29 11:43:27.980 WARNING (MainThread) [homeassistant.components.unifi] Exception on update Call https://10.0.0.1:443/proxy/network/api/s/default/rest/user received 401 Unauthorized
2024-04-29 11:43:27.981 WARNING (MainThread) [homeassistant.components.unifi] Exception on update Call https://10.0.0.1:443/proxy/network/api/s/default/stat/device received 401 Unauthorized
2024-04-29 11:43:27.981 WARNING (MainThread) [homeassistant.components.unifi] Exception on update Call https://10.0.0.1:443/proxy/network/api/s/default/rest/dpiapp received 401 Unauthorized
2024-04-29 11:43:27.981 WARNING (MainThread) [homeassistant.components.unifi] Exception on update Call https://10.0.0.1:443/proxy/network/api/s/default/rest/dpigroup received 401 Unauthorized
2024-04-29 11:43:27.981 WARNING (MainThread) [homeassistant.components.unifi] Exception on update Call https://10.0.0.1:443/proxy/network/api/s/default/rest/portforward received 401 Unauthorized
2024-04-29 11:43:27.981 WARNING (MainThread) [homeassistant.components.unifi] Exception on update Call https://10.0.0.1:443/proxy/network/api/self/sites received 401 Unauthorized
2024-04-29 11:43:27.981 WARNING (MainThread) [homeassistant.components.unifi] Exception on update Call https://10.0.0.1:443/proxy/network/api/s/default/stat/sysinfo received 401 Unauthorized
2024-04-29 11:43:27.981 WARNING (MainThread) [homeassistant.components.unifi] Exception on update Call https://10.0.0.1:443/proxy/network/api/s/default/rest/wlanconf received 401 Unauthorized
2024-04-29 11:43:27.982 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Default for unifi
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 551, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/unifi/__init__.py", line 47, in async_setup_entry
    await hub.initialize()
  File "/usr/src/homeassistant/homeassistant/components/unifi/hub/hub.py", line 84, in initialize
    self.is_admin = self.api.sites[self.config.entry.unique_id].role == "admin"
                    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiounifi/interfaces/api_handlers.py", line 167, in __getitem__
    return self._items[obj_id]
           ~~~~~~~~~~~^^^^^^^^
KeyError: '6161e05bc3ecef069349f369'

There is a lot of stuff in the logs so not sure what would be helpful. Exacerbated by having Unifi Protect integration with similar issues. Below is a snippet of logs that look relevant. This block is repeated until it reaches login attempt limit. Password was in the clear, so took that out. Several IDs and tokens I took out as well, don’t know if they are sensitive, but erring on the side of caution.

Please let me know if there is anything specific you need.

Thanks

2024-04-29 12:40:16.273 DEBUG (MainThread) [aiounifi.interfaces.connectivity] Logged in to UniFi https://10.0.0.1:443/api/auth/login
2024-04-29 12:40:16.273 DEBUG (MainThread) [aiounifi.interfaces.connectivity] sending (to https://10.0.0.1:443/proxy/network/api/s/default/stat/sta) get, None, {}
2024-04-29 12:40:16.275 DEBUG (MainThread) [aiounifi.interfaces.connectivity] received (from https://10.0.0.1:443/proxy/network/api/s/default/stat/sta) 401 application/json <ClientResponse(https://10.0.0.1:443/proxy/network/api/s/default/stat/sta) [401 Unauthorized]>
<CIMultiDictProxy('Server': 'nginx', 'Date': 'Mon, 29 Apr 2024 17:40:16 GMT', 'Content-Type': 'application/json', 'Content-Length': '47', 'Connection': 'keep-alive', 'Referrer-Policy': 'no-referrer', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'X-Content-Type-Options': 'nosniff', 'X-DNS-Prefetch-Control': 'off', 'X-Frame-Options': 'SAMEORIGIN', 'X-XSS-Protection': '1; mode=block', 'Set-Cookie': 'UOS_TOKEN=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT; samesite=none; secure; httponly; partitioned')>

2024-04-29 12:40:16.275 DEBUG (MainThread) [aiounifi.interfaces.connectivity] sending (to https://10.0.0.1:443/api/auth/login) post, {'username': 'ha_network', 'password': 'XXXXXXXXX', 'remember': True}, {}
2024-04-29 12:40:16.582 DEBUG (MainThread) [aiounifi.interfaces.connectivity] received (from https://10.0.0.1:443/api/auth/login) 200 application/json <ClientResponse(https://10.0.0.1:443/api/auth/login) [200 OK]>
<CIMultiDictProxy('Server': 'nginx', 'Date': 'Mon, 29 Apr 2024 17:40:16 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Vary': 'Accept-Encoding', 'Set-Cookie': 'UOS_TOKEN=XXXXXXXXXXX; path=/; expires=Mon, 29 Apr 2024 19:40:16 GMT; samesite=none; secure; httponly; partitioned', 'x-updated-csrf-token': 'XXXXXXXXX', 'x-token-expire-time': '1714419616468', 'X-Response-Time': '304ms', 'Access-Control-Allow-Credentials': 'false', 'Access-Control-Expose-Headers': 'Content-Disposition, Content-Range, Filename, Location, Range, Upload-Length, Upload-Offset, X-Connection-Type, X-Csrf-Token, X-File-Id, X-Token-Expire-Time, X-Updated-Csrf-Token', 'Referrer-Policy': 'no-referrer', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'X-Content-Type-Options': 'nosniff', 'X-DNS-Prefetch-Control': 'off', 'X-Frame-Options': 'SAMEORIGIN', 'X-XSS-Protection': '1; mode=block', 'X-Csrf-Token': 'XXXXXXXXXX', 'Content-Encoding': 'gzip')>

2024-04-29 12:40:16.583 DEBUG (MainThread) [aiounifi.interfaces.connectivity] data (from https://10.0.0.1:443/api/auth/login) b'{"unique_id":"XXXXXXXXX","first_name":"ha_network","last_name":" ","alias":"","full_name":"ha_network","email":"","email_status":"UNVERIFIED","email_is_null":true,"user_email":"","phone":"","avatar_relative_path":"","avatar_rpath2":"","status":"ACTIVE","employee_number":"","create_time":1683130563,"login_time":1714409006,"extras":{},"username":"ha_network","local_account_exist":true,"password_revision":1714408661,"sso_account":"","sso_uuid":"","sso_username":"","sso_picture":"","uid_sso_id":"","uid_sso_account":"","uid_account_status":"","groups":[{"unique_id":"XXXXXXXXX","name":"UDMPRO","up_id":"XXXXXXXXXX","up_ids":["XXXXXXX","XXXXXXXXX"],"system_name":"UDMPRO / Home / UDMPRO","create_time":"2023-10-23T15:31:42-05:00"}],"roles":[{"unique_id":"XXXXXXXXXXXX","name":"Super Admin","system_role":true,"system_key":"super_administrator","level":2,"create_time":"2021-10-09T13:32:14-05:00","update_time":"2021-10-09T08:32:14-05:00","is_private":false}],"permissions":{"innerspace.management":["admin"],"network.management":["admin"],"protect.management":["admin"],"system.management.location":["admin"],"system.management.user":["admin"]},"scopes":["write:protect.viewer","write:protect.user:$","write:protect.user","write:protect.sensor","write:protect.schedule","write:protect.nvr","write:protect.light","write:protect.legacyUFV","write:protect.group","write:protect.doorlock","write:protect.deviceGroup","write:protect.chime","write:protect.camera","write:protect.bridge","view:user_timezone","view:user","view:unifi-os:user","view:systemlog","view:settings","view:role","view:permission:viewer","view:permission:admin","view:permission","view:os-menu:user","view:os-menu:system-log","view:os-menu:storage","view:os-menu:settings","view:os-menu:notify-settings","view:os-menu:map","view:os-menu:devices","view:os-menu:about","view:notification","view:location_policy","view:location_device","view:location_activity","view:location","view:identity:update","view:identity:settings","view:identity:services","view:identity:organization_info","view:holiday_timezone","view:holiday","view:group","view:door_group","view:controller:uid-agent","view:controller:talk","view:controller:protect","view:controller:olympus","view:controller:network","view:controller:led","view:controller:innerspace","view:controller:drive","view:controller:connect","view:controller:calculus","view:controller:access","view:cloud_access","view:app:users","view:app:uid-agent","view:app:settings","view:app:locations","view:access:user","view:access.visitor","view:access.systemlog","view:access.settings","view:access.schedule","view:access.policy","view:access.pin_code","view:access.open_api","view:access.nfc_card","view:access.face","view:access.device","view:access.dashboard","update:access.device","systemlog:user","systemlog:system","systemlog:network","systemlog:location","systemlog:connect","systemlog:access","send:identity:email","revoke:identity:credential","readmedia:protect.camera","readlive:protect.camera","read:protect.viewer","read:protect.user:$","read:protect.user","read:protect.sensor","read:protect.schedule","read:protect.nvr","read:protect.light","read:protect.legacyUFV","read:protect.group","read:protect.doorlock","read:protect.deviceGroup","read:protect.chime","read:protect.camera","read:protect.bridge","open:door","notify:user","notify:location","notify:access","manage:controller:talk","manage:controller:protect","manage:controller:olympus","manage:controller:network","manage:controller:led","manage:controller:innerspace","manage:controller:drive","manage:controller:connect","manage:controller:calculus","manage:controller:access","edit:user_timezone","edit:user","edit:unifi-os:user_group","edit:unifi-os:user","edit:systemlog","edit:settings","edit:role","edit:preview","edit:permission:viewer","edit:permission:admin","edit:os-settings:update_install","edit:os-settings:update_channel","edit:os-settings:support_file","edit:os-settings:ssh","edit:os-settings:send_diagnostics","edit:os-settings:restart","edit:os-settings:raid","edit:os-settings:poweroff","edit:os-settings:notify","edit:os-settings:hotspare","edit:os-settings:general","edit:os-settings:client_network","edit:os-settings:auto_update","edit:notification","edit:location_policy","edit:location_device","edit:location_activity","edit:location","edit:identity:update","edit:identity:status","edit:identity:settings","edit:identity:services","edit:identity:organization_info","edit:holiday_timezone","edit:holiday","edit:group","edit:feedback","edit:export_log","edit:door_group","edit:controller:uid-agent","edit:access:user","edit:access.visitor","edit:access.settings","edit:access.schedule","edit:access.policy","edit:access.pin_code","edit:access.open_api","edit:access.nfc_card","edit:access.face","edit:access.device","deletemedia:protect.camera","delete:protect.viewer","delete:protect.user:$","delete:protect.user","delete:protect.sensor","delete:protect.schedule","delete:protect.nvr","delete:protect.light","delete:protect.legacyUFV","delete:protect.group","delete:protect.doorlock","delete:protect.deviceGroup","delete:protect.chime","delete:protect.camera","delete:protect.bridge","delete:access.device","create:protect.viewer","create:protect.user","create:protect.sensor","create:protect.schedule","create:protect.liveview","create:protect.light","create:protect.group","create:protect.doorlock","create:protect.deviceGroup","create:protect.chime","create:protect.camera","create:protect.bridge","assign:role","assign:identity:wifi","assign:identity:vpn","assign:identity:talk","assign:identity:evstation","assign:identity:camera","adopt:access.device"],"cloud_access_granted":false,"only_local_account":false,"update_time":1683130563,"avatar":null,"nfc_token":"","nfc_display_id":"","nfc_card_type":"","nfc_card_status":"","role":"admin","roleId":"XXXXXXXXXXX":"XXXXXXXXXXX","isOwner":false,"isSuperAdmin":true,"isMember":false,"maskedEmail":"","accessMask":2014,"permissionMask":8028,"deviceToken":"XXXXXXXXXXX","ssoAuth":{}}'

Got something similar shared on github. In that case websocket connection failed. Might be some changes to websocket. Someone’s gonna need to deep into webbrowser developer and try to figure out the changes

That doesn’t sound good (you lost me at websocket ;). Saw a post on the unifi EA thread as well, so it isn’t just me.
I suppose I will look into downgrading until this gets sorted. Please let me know if there is anything I can do to help. But I am afraid my skills are a bit lacking.

1 Like

Link pls :+1:t2:

Link here https://community.ui.com/releases/UniFi-OS-Dream-Machines-4-0-3/90b24b90-8be8-4987-8d47-eb408eb07e45#comment/f8fc8a2a-cc59-4af5-bb71-5aa2296d3032

A little later in the thread poster got the unifi protect integration working. I re-authed that integration several times and it came back up.

Thinking there may be something cached that might be the issue I am in the process of completely removing the network integration and adding it back. Will report back if that has any effect.