Isaksson / node-red-contrib-unifi

MIT License
52 stars 20 forks source link

Implement better error handling #46

Closed gahujipo closed 2 years ago

gahujipo commented 4 years ago

I am not able to get this node running. I run my unifi controller under a URL and an invalid SSL certificate (comes by default). But no matter which command I choose I get this error:

"TypeError: Cannot read property 'command' of undefined"

This is my node-red: image

These are the versions in my controller: image

What could I check next?

Isaksson commented 4 years ago

What do you inject from the inject node?

gahujipo commented 4 years ago

Nothing. Inject is empty. Do I have to inject the command? Shouldn't that be selected in the drop-down of the node?

gahujipo commented 4 years ago

I just upgraded to the latest v5 controller version. Didn't change anything. Is this node already compatible with controllers with version 6?

gahujipo commented 4 years ago

Is there a log I could check for errors to get this node running?

Isaksson commented 4 years ago

Does it work if you actually injects a command?

gahujipo commented 4 years ago

No. I changed the inject node to this: grafik

Which leads to this with no debug output: grafik

Isaksson commented 4 years ago

I need to add some better error handling but one of the issues could be wrong IP or Port number, then it will give you that object Object error.

gahujipo commented 4 years ago

Yes, I think it would be the best solution to add some better error handling.

Like I said, I am running the controller under a URL (controller.domain.tld, not an IP) with the default self signed ceritificate. Could that be the problem which prevents the node to connect to the controller?

gahujipo commented 4 years ago

I found in the source code, that the error, gets written to the console, which I was able to get from the container console. There I found

ERROR: Error: getaddrinfo ENOTFOUND https https:443

I changed the server property to a value without a leading "https://", which made the node green, but got again the error

"TypeError: Cannot read property 'command' of undefined"

grafik

Then I injected the command, as suggested:

{
    "command": "ClientDevices"
}

And now it works as expected. Therefore I will change the title of this issue.

hannah98 commented 4 years ago

I don't know if it is appropriate to latch on to this issue but I discovered a similar issue that seems to fit under the "better error handling" message.

I tried using this node for the first time today. I set it up and whenever I would run it the only indication I would get that it was doing something was this message in the system console:

ERROR: undefined

I tried injecting the command as shown above and that didn't work. Finally through trial and error I discovered what the problem was.

The name of my Unifi site is "Home", so I changed the Site in this node configuration from "default" to "Home". That was producing the ERROR: undefined.

As soon as I changed the site back to "default" it started working. It would have been helpful to know that the problem had to do with the value I entered into the site field.

RicharddeCrep commented 2 years ago

I cannot get any info out of the Node.

I have the same "undefined" response regardless of the many changes I make as a result of the other comments here.

I share others' requests for better documentation and error messaages.