node-unifiapi
node-unifiapi copied to clipboard
UbiOS not supported / Incorrect device count
Hello,
Unfortunately, I have not been able to get this working yet. Here is what I have:
let CloudAPI = require('node-unifiapi/cloudapi');
let cloud = CloudAPI({
//deviceId: '', // The cloud id of the device
username: 'unifi',
password: 'unifi',
debug: true, // More debug of the API (uses the debug module)
debugNet: true // Debug of the network requests
});
cloud.self()
.then(() => cloud.devices())
**username and password excluded for obvious reasons
I receive:
{ response:
{ debugId: 3,
headers:
{ date: 'Sat, 18 Apr 2020 10:04:08 GMT',
'content-type': 'application/json; charset=utf-8',
'content-length': '24',
connection: 'close',
'access-control-allow-origin': 'https://account.ubnt.com',
vary: 'Origin',
'access-control-allow-credentials': 'true' },
statusCode: 200,
body: '{"count":0,"devices":[]}' } }
CloudAPI Received response: string +372ms
CloudAPI now we have object +1ms
Which I know isn't correct. I looked on unifi.ui.com (The new UbiOS page) and this is in the requests:
https://cloudaccess.svc.ui.com/devices?withUserData=true https://ubic-stabilizer.svc.ui.com/api/airos/v1/unifi/devices?page=0&page_size=1000
So the second one (which I think your API is calling) is showing 0, whereas the first one is accurate.
It also looks like there is a 'list' which is at: https://cloudaccess.svc.ui.com/list, which also returns correct info.
Also: URL for getting the new UbiOS devices (UDMs) https://cloudaccess.svc.ui.com/devices?type=ucore,ulp&withUserData=true
Any help is much appreciated :)
@lifewcody Same here. Apparently with the addition of UDM PROs the routes for the software-based controllers have changed. Have you been able to make any progress?
FYI: I maintain the PHP API client for UniFi but have a specific use-case where we may need to leverage CloudAccess and it would be really cool if we can achieve that with this package.
Sorry, I haven't yet look at this deeply. Let me see if I can simulate the issue and I will fix it
Delian
On Mon, Jun 8, 2020 at 5:28 PM malle-pietje [email protected] wrote:
@lifewcody https://github.com/lifewcody Same here. Apparently with the addition of UDM PROs the routes for the software-based controllers have changed. Have you been able to make any progress?
FYI: I maintain the PHP API client for UniFi but have a specific use-case where we may need to leverage CloudAccess and it would be really cool if can achieve that with this package.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/delian/node-unifiapi/issues/26#issuecomment-640701813, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA3WZUK736QPGXSU7IBI43RVT7SZANCNFSM4MLJLGUA .
This is one of the two big issues slowing my adoption of the UDM pro. The other is that /etc/hosts isn't getting populated but, with an API, I can think about programming a work-around.
@BobFrankston If you have PHP skills you can always start off with the PHP API client which I maintain and already supports UDM PROs.
Thanks -- I'll see if I can figure out the fix to apply it to the node version but I'm hesitant to try to update the shared version.
The PHP version seems short enough to rewrite if need be. I also found https://ubntwiki.com/products/software/unifi-controller/api. My goal is still to have a TypeScript (OK, JavaScript) library that I can use. My bias shows in https://rmf.vc/IEEEJSEco.
@malle-pietje - Since I'm not up to speed on the PHP ecosystem, do you have a simpler example I can use to invoke the PHP library? I'm getting authorization issues on the UDM Pro. There seems to be a myriad of credentials) and I don't know if I have the bug in my JS code or not.
@BobFrankston the issue with UDM PROs is that the login route and base path have changed. Also the authentication uses a JWT token instead of cookies. Just search through the code for the is_unifi_os property to see where we change behavior of the client: https://github.com/Art-of-WiFi/UniFi-API-client/blob/master/src/Client.php
Thanks. I did find /api/auth/login. The challenge now is to figure out which credentials for what since that too has changed. There are local credentials, UDM credentials, cloud credentials ... but I did get to authorization failure which is progress.
@BobFrankston When accessing the (non-Cloud) API you need to use a set of credentials for the UniFi controller application with local access permissions.
I added local credentials and tried both that and the cloud credentials which the UDM pro seems to want. Do you have a command line I can use with your PHP version so I can test the credentials? I do appreciate your help and the work you've done.
@BobFrankston You can use this example which can easily be executed from the command line after setting up the config file: https://github.com/Art-of-WiFi/UniFi-API-client/blob/master/examples/list_user_stats.php
Execute like so:
# php list_user_stats.php
I've made lots of progress and added:
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYPEER => false,
but now need to get past
PHP Notice: cURL error: SSL: no alternative certificate subject name matches target host name
OK, got past that with
CURLOPT_SSL_VERIFYHOST => FALSE,
CURLOPT_SSL_VERIFYPEER => FALSE,
On to the next challenge ...