Isaksson / node-red-contrib-unifi

MIT License
52 stars 20 forks source link

Error on 1st attempt at using it #33

Closed cymplecy closed 4 years ago

cymplecy commented 4 years ago

Using this image

getiing this

image

https://discourse.nodered.org/t/node-red-contrib-unifi/27653

Isaksson commented 4 years ago

Are you sure that you get that error message when ju inject a timestamp? or could that error message be from a test you did with injecting commands (JSON)?

cymplecy commented 4 years ago

Pure timestamp as per image 1st attempt at using node ever -just installed it a few minutes beforehand - Windows10 if that makes any diff Tried it twice - same error both times

Isaksson commented 4 years ago

Ok, then we will make a test like this. 1: inject node (timestamp is ok to use) 2: function node, add this code: msg.payload = { command: "events"}; return msg; 3: your Unifi node 4: debug node

Please try this example.

cymplecy commented 4 years ago

That works fine

image

Isaksson commented 4 years ago

Perfect. I have made a change in the code and will publish that soon, I think that will solve your first Issue. Do you need any more help about your first issue that you post on the forum, how to disable a AP?

you could to the same thing but replace the command and also add the MAC. Change the code in the function node to this

msg.payload = { command: "disableAP", mac: "device MAC address"}; return msg;

cymplecy commented 4 years ago

"I have made a change in the code and will publish that soon, I think that will solve your first Issue" Ta :)

cymplecy commented 4 years ago

"Do you need any more help about your first issue"

I've tried out your function code command and I get this error message

image

JFI I'm not the OP on that thread

Isaksson commented 4 years ago

Ahh I see, there is a change in the API. I will correct this, the MAC is not the correct value to identify the AP, you need to use the 24 char device ID. I will make the change to the code and update the Readme.

But the new function will be like this msg.payload = { command: "disableAP", device_id: "24 char device id"}; return msg;

But that will be implemented in next version

Isaksson commented 4 years ago

JFI I'm not the OP on that thread Ahh I see, your just testing this out to help the OP.

I have now pushed the new version to NPM

cymplecy commented 4 years ago

I've upgraded to 0.1.11

image

image

Node shows red indicator and I get this in my console log

image

Isaksson commented 4 years ago

I will run some tests and see what is causing this error, the code was untested from my side.

Isaksson commented 4 years ago

Version 0.1.12 includes this fix

cymplecy commented 4 years ago

Sorry for delay - I (stupidly) decided to upgrade my controller from 4.x to 5.x and it was VERY wrong so I've had to re-setup my network!

Disable now works :)

image

And enable works as well :)

image

Thanks for your efforts :) - I'll report back to the forum :)

cymplecy commented 4 years ago

Just got another error when trying to inject timestamp into node to read accessdevices

image

image

I'd sucessfully done it once before so may just be a one-off glitch!

Isaksson commented 4 years ago

About your last error message. From the error message I could read out that you are injecting the command disableap and it failes because its missing the parameter device_id

so maybe you inject a timestamp but it passes a function node that injects the command or something like that.

cymplecy commented 4 years ago

I "think" that the node seems to not handle direct timestamp injects consistently (based on other experiences I've had) but I'll wait till I can repeat the error before posting again

Isaksson commented 4 years ago

I "think" that the node seems to not handle direct timestamp injects consistently (based on other experiences I've had) but I'll wait till I can repeat the error before posting again

There should no be any issues with injecting timestamp, you could inject anything, but if you inject a command then the payload must match that command. So as long as you do not provide the command then it should be fine, and if you inject command then you need to make sure that you follow the information about the command from the Readme file.

cymplecy commented 4 years ago

OK -I've been thru all the options in the node just using timestamp as an injector and they all worked fine and without error :)

image

cymplecy commented 4 years ago

No error - but when I tried 1 (which sends msg.payload.command= "events" - I got events in debug

But then when I press plain timestamp into the node - it did events again even though node was set to AccessPoints

image

Isaksson commented 4 years ago

No error - but when I tried 1 (which sends msg.payload.command= "events" - I got events in debug

But then when I press plain timestamp into the node - it did events again even though node was set to AccessPoints

image

Ahh ok, but if you "deploy" between the tests then it works I guess. In this case the Node remembers the last command and because of that it ignores the one from the drop down. I will make a fix for this that will be included in next release (no need to push just the fix for this bug)

cymplecy commented 4 years ago

Manged to repeat the last error - I pressed 1 to disable the AP (which worked) and then press plain timestamp 2 which should have listed AccessDevices but instead gave the same error as last time

image

Isaksson commented 4 years ago

Yes, same thing. It "remembers" the last command.

cymplecy commented 4 years ago

Could you publish the fix to NPM please?

Isaksson commented 4 years ago

Could you publish the fix to NPM please?

Done.

cymplecy commented 4 years ago

The node is working fine for me on Version 0.1.13 - thanks for all your efforts :)