New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request: Ability to enable/disable a wlan through the rest interface #4
Comments
The node-unifi library this node-red library utilizes already uses such a function:**
*/
}The portion in above request I do not get, should be "default" or something parameterized. Hope this is easy.. |
Hello. I have also added a new command to get the wlan_id. Run command WLanSettings and use the _id from the result. This is now pushed to Git will update on NPM |
The new version is also pushed to NPM, please let me know how it goes when you have tried the new feature. |
Hi Kristoffer, This is excellent. I am in the process of setting up a new vm for my node-red stuff, so I will be able to test this within the next couple of days after I migrated everything. Thanks for the quick reaction and implementation. This will help turning my guest wlan on and off based on a dashboard button or some other logic. I will let know know as soon as possible. Tran. |
That sounds good. I do not have any timeline or so when I will add more functionality, do you have anything that you need just open a new issue and explain the command that you need, as long it is in the backend module then I could add it to this module. |
Hi, Migration kind of successful, just the normal problems associated with that. I tested the WLanSettings command, and that works perfectly. However, I have some trouble DISabling a wlan, when I construct a payload like:
the node (which is set as WLanSettings) always goes in error like, the log shows following:
The reason for this is that the parent node-unifi library uses following to call the api:
it seems clear that my site id is not <SITE>, but it is also not parameterized through the disableWlan function. I replaced the <SITE> with the disable function with my site id, but still get the same error in the log. Any ideas? |
Let just make some things clear, the module is working when you use the GUI command WLanSettings? I just made the exact same thing and it disable/enable my ssid Do you use default site name? |
And you still need to have the correct site name in the configuration for the unifi node, I get the same error if I change the site name in the configuration to a site name that I do not have. |
Correct
Correct. Oddly enough, also WLanSettings now stopped working with "ERROR: api.err.Invalid". Hmm, did I break it somehow ? |
odd indeed. |
Yes, it works in the default wlan group. Do you have the GUI commands up and running now? |
It works again.. The flow I am using is following to test: [{"id":"d752285e.27aaa8","type":"inject","z":"d1a7fc8a.5906d","name":"Info","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"x":430,"y":600,"wires":[["a0b5749f.5414b8"]]},{"id":"50c1b6f.1843a48","type":"debug","z":"d1a7fc8a.5906d","name":"","active":true,"console":"false","complete":"false","x":890,"y":600,"wires":[]},{"id":"34e31163.f71cce","type":"inject","z":"d1a7fc8a.5906d","name":"test wlan in default group : DISABLE","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":200,"y":660,"wires":[["95fc3b18.077ba8"]]},{"id":"95fc3b18.077ba8","type":"function","z":"d1a7fc8a.5906d","name":"DISABLE","func":"msg.payload = {command:"disableWLan",wlan_id:"5a5a6860e4b073cbb84a0a45",disable:true};\nreturn msg;","outputs":1,"noerr":0,"x":440,"y":660,"wires":[["a0b5749f.5414b8"]]},{"id":"a0b5749f.5414b8","type":"Unifi","z":"d1a7fc8a.5906d","name":"Access devices","ip":"10.50.1.32","port":8443,"site":"default","command":"110","x":660,"y":600,"wires":[["50c1b6f.1843a48"]]}] |
If I change the site from default to my real site name in the config node, also the WLanSettings collecting goes on error. If I go back and forth between my real site ID and the default one... the result is as follows: default: wlansettings is OK, disableWlan errors perhaps I should revert to default site ? but that could crap up my whole installation potentially... family would not thank me that. |
If you change the Site to a name that is not your site then the module will produce an error, and that is correct. |
see above (edited the previous post, and we crossed post) |
I cant Import that flow so I cant test exact the same thing. |
True, I mixed up site name with wlan group name..
No, in the configuration I entered my custom site name. |
That great, so now we know that you have the correct site name and that the module is working with GUI commands, but I still do not know if you still have problem with the custom command "disableWLan" and if you do, do you still get the same error as before |
I created a new Wlan group and also a new Wireless Network in the new group, and I had no problems to enable/disable that network so there is no problem with not uring the default Wlan group. |
The situation is odd and it has to do with the way the node treats the site name. I have one working flow consisting of a timestamp injector into a unifi node with default site and wlansettings and a debug node. When starting this flow all goes well. However, when I copy the above flow, the copied flow stops working with error: ERROR: api.err.Invalid No matter what I do, I am unable to create a second flow with a unifi node which does not give me an error.. Also, the moment, I enter my site name in the unifi node, run it (and it error), the sitename in the unifi node is changed automatically back to default on edit. After that it stops working at all. |
Okey, but if you reuse the first node and just add a function node in between and send |
nope, that does not work then. For now even working unifi nodes stopped working and result in the same error. |
I think you maybe should restart the node-red, I have never seen any issues to the controller that needed a reboot. |
one mystery solved. lastpass was messing with my password in the credentials every time I edited the unifi node. That at least explains the problems with the node stopping working in between site name edits. Too silly... I will recheck my original flow |
Ahh, yes the browser and plugins could sometimes make the most strange things :) Run some more tests and let me know how it goes, Its late here now and I will check in here again tomorrow. |
sure, I might just try moving my wlan config to the default site. Unifi controller runs on proxmox so that should not be an issue. It is late here also (europe). Good night and thanks for your help. |
I must shamefully admit that the problems most likely are all related to my very bad javascript voodo. The node has default as side name, and the command is set to "WLanSettings".
As I understand things, both methods should have equal result. If I try to get the same info using the function node, with above payload setting, I always get an error. My mistake must therefor in providing some bad json from the javascript node. Can you look at my function code and provide me with a correct payload ? |
One minor addition, once the unifi node has errored, any next run (even the correct invocation using the INFO trigger) will error. This error stays until the whole flow is redeployed... (While this behavior might be more related to the underlying node-unifi or deeper, it still makes test problematic) |
You are doing everything correct, for some reason i called it WlanConf in the code, thats why you get error with that code. I will change it in the code so that it match the information :) I just verified with two different payload commands, one that is working and one that gives error, no problem to send the correct one after the one that produces error, so in my tests it works as it should. |
So now I use the correct name :) Here is a simple flow that i used to verify that the nodes goes OK after Error. Just connect this to your Unifi module. 1 will get ok and 0 will produce Error and then click 1 again and if it works as it should then the Unifi module should go into Ok again.
|
Ok, with WLanConf my function node works. Using your above flow, the state of the unifi node indeed toggles between ok and error... |
However, the unifi node which has a command set within as WLanSettings will not go back to OK after an error. |
I added some logging in the node js, and the error now actually is: ERROR: api.err.NoPermission And indeed, I am using a read-only user in unifi. |
And indeed.... a read-only user has not privilege to disable a wlan... duh |
let me test this with my real wlans, and I will let you know. |
Ahh, then it works as it should, good that a read only cant change the configuration :) |
Hi Kristoffer, It works now as expected, thanks for providing this. A couple of observations which might be added to the documentation as some point: *) Unifi controller user must have at least 'administrator' rights (not read-only) A suggestion if possible. Rather then setting a node just to 'Error' in case of error, perhaps show the error message coming from the unifi-node as node status or in the debug window. This will give a clearer indication why the error occurred and fixing will be easier. With this I thing this issue can be closed. |
Thanks for the feedback. |
The ubiquiti allows a wlan to be disabled/enabled using something like:
This functionality would be very beneficial to include in the package.
Thanks
The text was updated successfully, but these errors were encountered: