Isaksson / node-red-contrib-unifi

MIT License
52 stars 20 forks source link

Error Bad Request Unifi Node #80

Closed MarkRoks closed 2 years ago

MarkRoks commented 2 years ago

Hello,

The Unifi node has always worked for me within Node-Red, until the last update.

I mainly used it to turn on/off the blue LED in the AP, with the required commands.

I'm using the same settings/login in the Node, using Node-Red v3.0.2, Nodejs v16.13.0 and running Unifi controller v7.2.93.

When I try to switch the led on, the Unifi node receives an "Error Bad Request" message.

Do more people have the above experience?

Regards,

Isaksson commented 2 years ago

Hello. This last updater is a huge update, deprecated modules have been removed and changed to new modules, I have tried to verify the functions but I guess you have found a bug. Does other commands work for you?

MarkRoks commented 2 years ago

Hello,

The other things, as far as I can see, work correctly. It is only the control of the led in the APs that I normally use. But now it doesn't work (anymore) through the Node.

It seems to me to be a bug in the firmware.

Could this be revised?

If it is possible, (temporarily) to restore the Node to the previous firmware (and how to), that would suffice for me for the time being.....

Regards,

Isaksson commented 2 years ago

Is this the command that you use? { command: "setapled", device_id: "24 char device id", mode: "off/on/default" }

I recommend you to wait until I have checked this but, It is possible to download and install older versions of Nodes in Node-RED, i think the version that you used before was 0.1.18 https://nodered.org/docs/user-guide/runtime/adding-nodes#installing-with-npm

MarkRoks commented 2 years ago

Hello,

It is correct that I am using the named rules for turning the LED on/off in the AP.

At first I was under the impression that there was something wrong with this, so I tried it both through a payload, and through the script I normally use. Same error in both cases.

I will try to install the previous version. Otherwise, I'll wait for a possible solution to the problem mentioned.

Regards,

MarkRoks commented 2 years ago

Hello,

I tried to install v0.1.18, but I can't do it with: "npm i node-red-contrib-unifi@0.1.18".

It does execute the line in putty (logged in as root), but it doesn't put the Node/file in the right place (I think).

After restarting Node-Red, the Unifi Node is therefore not present.....

Am I doing something wrong or something?

Regards,

Isaksson commented 2 years ago

Did you execute the command within the Node-RED directory? To install a node module from the command-line, you can use the following command from within your user data directory (by default, $HOME/.node-red):

MarkRoks commented 2 years ago

Hello,

It took me some time but managed to install firmware 0.1.18 (back). I was indeed in the wrong directory, in terms of installing the Node. This is because I never install the Nodes this way, but directly from Node-Red itself. Thanks a lot (so far) for the support on this.

Now it works again, as it was before.

If there is anything that needs to be tested with the latest firmware, I would of course like to hear about it.

Regards,

Isaksson commented 2 years ago

Sounds good, I will update this case when I have some news about this issue.

Isaksson commented 2 years ago

I have verified this command against a Unifi Controller (not Unifi OS) and on that controller the command works without any issues. I need to verify this command against a controller that runs Unifi OS.

MarkRoks commented 2 years ago

Hello,

It's true that the controller I'm using uses Unifi OS.

That's why I'm using port 443, instead of 8443.

Regards,

hjhasler commented 2 years ago

Hi

I just installed "node-red-contrib-unifi" the first time today. I was trying to us all the get-functions. On most I got the error "ERR_BAD_REQUEST". This function works: getSiteStates -> adequate output This function works: getAlarm -> Output: undefined

I'm using the unifi contoller version 7.2.92. Node red version 3.0.2. node-red-contrib-unifi version 0.2.4.

Maybe my infos can help you.

Kind regards Hans-Jörg

Isaksson commented 2 years ago

I have managed to replicate the issue against Unifi OS, now I will try to find a solution. Thanks for the input.

Isaksson commented 2 years ago

I have found and fixed the issue, I am now just verifying some more commands. I will push a new version tonight.

Isaksson commented 2 years ago

I have now pushed version 0.2.5 to NPM and also updated the version on Node-RED Flow

This patch will solve the issue mentioned in this post, please verify if you have the time.

hjhasler commented 2 years ago

I have updated to version 0.2.5 but I have almost the same issues. Now only the function "getSiteStates" works.

Additional comment: I'm running node red in a docker container.

Isaksson commented 2 years ago

And you receive ERR_BAD_REQUEST as error message?

Isaksson commented 2 years ago

@hjhasler could it be that you are using the wrong site name in the configuration of the node? You find your name when using the command SiteStats

hjhasler commented 2 years ago

Yes, I still get ERR_BAD_REQUEST. grafik

As fare as I know, the site name is not used for "getAccessDevices". Or is it?

hjhasler commented 2 years ago

I double checked now of the site names. I used the site name from the GUI of the unifi controller. They are different. Sorry for my wrong understanding...

I use the name "default" and it seems to work now. I'll do some further testing and will respons later on...

Isaksson commented 2 years ago

Thanks for testing, you are not the first one who makes this "mistake" they have not made the site name part that clear.

MarkRoks commented 2 years ago

Hello,

For me everything works (again) perfectly, as before, after the update of the Node to v0.2.5.

Thanks a lot for the support!

Regards,

Isaksson commented 2 years ago

Sounds good.

hjhasler commented 2 years ago

Hi @Isaksson

I still have some problems. If it works fine by MarkRoks, my problem is probably of some other source… Can you give me a hint or two?

-getSiteStates: works fine -> adequate output -getAccessDevice: works fine -> adequate output (I see all devices at the selected site.) -RestartAP: msg.payload = { command: "restartAP", mac: "xx:xx:xx:xx:xx:xx" }; return msg; Same objects appears at the debug node. Message "ERR_BAD_GATEWAY" appears at the bottom of the Unifi node. I use the MAC address, which appears from the report of "getAccessDevice". (mac: "xx:xx:xx:xx:xx:xx") Result->AP does not restart. -disablePoePort: msg.payload = { command: "disablePoePort", device_id: "123456789012345678901234", port: "Port 1" }; return msg; No objects appears after the unifi node. No status change at the unifi node. I use the 24 character ID, which appears form the report of "getAccessDevice". (_id: "123456789012345678901234") Result->Nothing happens, the power at port 1 remains on.

My primary goal is to enable/disable the power on a port. That is the reason I use your library.

Thank you very much for you help in advance.

Kind regards Hans-Jörg

Isaksson commented 2 years ago

I will run some tests with those commands, I will let you know my results.

Isaksson commented 2 years ago

Please verify the RestartAP command now, I have made some changes in version 0.2.6 that should fix this command.

hjhasler commented 2 years ago

RestartAP works now with 0.2.6.

disablePoePort still no reaction.

Isaksson commented 2 years ago

Thanks for that. Yeah, disablePoePort is another story :) I dont think that actually worked with older version of this node, I have located the issue but to fix I need to rewrite/and rethink that function.

But, there is one "hack" that you could try.

On the switch that you want to disable the PoE port: Login to the controller and click the switch and then Ports, select the port that you want this node to have the possibility to disable PoE on and click port profile override and enable storm control (do not modify the 0 values) click on Apply Changes.

Now, lets try to disable that PoE port from this Node, let me know the result.