Monitoring your Unifi AP

Theres a single change that might be required.
On line 34, change ‘v6’ to ‘UDMP-unifiOS’

I might need to make that an additional configuration option.

Assuming that works (which it should) I just commited a change that should handle that automatically.

Connecting with the python library is a bit different using a UDMP vs a CloudKey

Using the AppDaemon setup I’m getting 500 errors in the logs. I’m at a loss as to what I need to do to resolve this. No entities in HA are being created, I had assumed this was automatic but if not, how do I manually create them?

Both HA and Appdaemn are running in docker containers if that of any use, both however are using the host network

Server got itself in trouble
2023-05-20 15:57:28.861294 INFO unifi_monitor: Leeloo-Switch Port 13 Port 13 is off
2023-05-20 15:57:28.863124 WARNING unifi_monitor: unifi_monitor: Entity binary_sensor.unifi_Leeloo-Switch_port13_link not found in namespace default
2023-05-20 15:57:28.865267 INFO AppDaemon: unifi_monitor: Entity binary_sensor.unifi_Leeloo-Switch_port13_link created in namespace: default
2023-05-20 15:57:28.877273 WARNING HASS: Error setting Home Assistant state default.binary_sensor.unifi_Leeloo-Switch_port13_link, {'state': 'off', 'attributes': {'friendly_name': 'Port 13', 'device_class': 'connectivity', 'model': 'US24PRO'}}
2023-05-20 15:57:28.878309 WARNING HASS: Code: 500, error: 500 Internal Server Error

I’m trying to get this working, but I’m stuck on the login it seems, and I don’t have a clue how to solve it.

My Home Assistant (2023.5.3) is running in a Docker image on my NAS (Synology DS418 play with DSM7), which has IP address 192.168.0.2. The Unifi Controller (7.3.83) is running in another Docker image on the same NAS. Both are running fine.

I’ve followed the instructions here (GitHub - w1tw0lf/Unifi-Device-info: Unifi AP Device info via API for home assistant) to get the integration going for 2 AP’s, but when I look at the sensors in Home Assistant they are all in status “Unknown”. So I’ve tried to run the script for one of the AP’s from a terminal window using the command:
‘python3 /config/scripts/unifi_ap_liv.py’
and the result is this:

/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1045: Insecure
RequestWarning: Unverified HTTPS request is being made to host '192.168.0.2'. Ad
ding certificate verification is strongly advised. See: https://urllib3.readthed
ocs.io/en/1.26.x/advanced-usage.html#ssl-warnings                               
  warnings.warn(                                                                
Traceback (most recent call last):                                              
  File "/config/scripts/unifi_ap_liv.py", line 21, in <module>                  
    client = Controller(host, username, password, port, version,                
  File "/usr/local/lib/python3.10/site-packages/pyunifi/controller.py", line 113
, in __init__                                                                   
    self._login()                                                               
  File "/usr/local/lib/python3.10/site-packages/pyunifi/controller.py", line 195
, in _login                                                                     
    raise APIError(                                                             
pyunifi.controller.APIError: Login failed - status code: 405  

So first I get a warning about SSL, which I don’t mind. But it seems I get an HTTP error 405, and I have no idea why.

Here is my config:

host = '192.168.0.2'
username = 'davyvr'
password = 'XXXXXXXXX'
version = 'UDMP-unifiOS'
#### version ####
## the base version of the controller API [v4|v5|unifiOS|UDMP-unifiOS] ##
## this would be for the version of the controller you are running ##
#################
site_id = 'default'
port = '8443'
verify_ssl = False
target_mac = 'fc:ec:da:16:c8:8f'

Any suggestions as to what I could try? How to get this solved?

Thanks in advance,
Davy

As per github issue, only thing I can think of that you need to change the version as docker isn’t UDMP-unifiOS.

To everyone interested: v5 did the trick! Thanks :slight_smile:

Looks like the release Home Assistant Core 2023.5.4 does not (fully) work with Unify. At least I lose the stream of the video.
Any suggestions on how to solve?

still not working with the latest HA… anyone any updates?

As I can see the script searches for Activity…while all before controller 7 used the Activity in the gui

After controller 7 release it changed to Air Stats… anyone know how to change ?

Likewise, thanks for the info!

is this still working? long inactivity

It still works, I just haven’t had the time to work on it or improve it.

Your help and work is appreciated! Since the last hass update it looks like the unifigateway integration has died :cry:

I want to implement your solution, but is there a step by step documentation available to implement your python script?

And is it possible to monitor my UDM or only switches / APs?

Thnx in advance and much appreciated!!

Most of the guide is on the github page, GitHub - w1tw0lf/Unifi-Device-info: Unifi AP Device info via API for home assistant

It should work with a UDM, it mainly just pulls switches/APs info.

i tried it but the format of the yaml files are not correct anymore. Also only input thats working is the upgrade available one :frowning:

Please share the error you getting ?

Still work fine this side.

Not sure how to check if the python part is correctly, but the configuration.yaml part (command line and template part) is giving me errors. When importing your config the formatting is not correct so could also be formatting issues. I even downloaded your config file and uploaded into mine (and ofcourse changed login etc)…

Error code:

Logger: homeassistant.components.command_line.utils
Source: components/command_line/utils.py:54
Integration: Command Line (documentation, issues)
First occurred: 22:03:40 (5 occurrences)
Last logged: 22:08:41

Command failed (with return code 1): /config/scripts/unifi_combined.py
Command failed (with return code 1): python3 /config/scripts/unifi_ap.py

python

To test the python script outside Home assistant, you will need GitHub - finish06/pyunifi

Nevermind I already found another community post with a working script… Thnx anyway

Maybe you’d like to share that post to help others :slight_smile:

Can you provide a link to the other post?