Art-of-WiFi / UniFi-API-client

A PHP API client class to interact with Ubiquiti's UniFi Controller API
MIT License
1.09k stars 217 forks source link

list_devices($mac) on a UBB wireless radio does not return data #167

Closed prairieit closed 1 year ago

prairieit commented 1 year ago

Response from Unifi is empty if you do a list_devices($mac) with a mac address from the wireless side of a UBB pairing. Using mac e0:54 as example, this is the wireless side of a UBB pairing. Doing the same thing but with the wired side mac returns data without any issues.

Debug output

---------cURL INFO-----------
Array
(
    [url] => https://unifi.<server>.com:8443/api/s/<siteid>/stat/device/e0:63:da:e4:e0:54
    [content_type] => application/json;charset=UTF-8
    [http_code] => 200
    [header_size] => 290
    [request_size] => 198
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 0.017259
    [namelookup_time] => 0.000108
    [connect_time] => 0.000666
    [pretransfer_time] => 0.01112
    [size_upload] => 0
    [size_download] => 30
    [speed_download] => 1738
    [speed_upload] => 0
    [download_content_length] => 30
    [upload_content_length] => 0
    [starttransfer_time] => 0.017206
    [redirect_time] => 0
    [redirect_url] => 
    [primary_ip] => x.x.60.102
    [certinfo] => Array
        (
        )

    [primary_port] => 8443
    [local_ip] => x.x.150.59
    [local_port] => 43976
    [http_version] => 2
    [protocol] => 2
    [ssl_verifyresult] => 0
    [scheme] => HTTPS
    [appconnect_time_us] => 11088
    [connect_time_us] => 666
    [namelookup_time_us] => 108
    [pretransfer_time_us] => 11120
    [redirect_time_us] => 0
    [starttransfer_time_us] => 17206
    [total_time_us] => 17259
)

-------URL & PAYLOAD---------
https://unifi.<server>.com:8443/api/s/<siteid>/stat/device/e0:63:da:e4:e0:54
empty payload
----------RESPONSE-----------
{"meta":{"rc":"ok"},"data":[]}
-----------------------------
malle-pietje commented 1 year ago

I’m afraid we don’t have any UBB devices we can use to replicate this. Can you share the results for the wired member?

malle-pietje commented 1 year ago

The only reason I can think of is that the UBB pair is managed within the controller as a single device with the wired MAC address as the key.

prairieit commented 1 year ago

@malle-pietje Your thinking on this is correct! I had a chance to test further, and it is indeed managed as a pair with the wired mac as the key. I can pull the results perfectly fine with the wired units MAC. I'll have to do some digging further to get around this with my ongoing project. In my project, I'm looping through the results of the alerts to find offline devices in order to implement with our internal ticketing system. In the cases where I was seeing this, the offline device alert is connected to the wireless side MAC. So when trying to pull data from that specific device, the API does not find it. Either way, your work on this api client is much appreciated!

malle-pietje commented 1 year ago

@prairieit thanks for confirming. Let us know if any further questions come up.