Isaksson / node-red-contrib-unifi

MIT License
50 stars 19 forks source link

Error message "TypeError: Cannot read properties of undefined (reading 'command')" #103

Closed UnwiredWalter closed 1 year ago

UnwiredWalter commented 1 year ago

Hi,

I was using contrib-unifi befor without any problems a few weeks ago - but no matter which command I run in the unifi node, nodered returns an error occurs saying "TypeError: Cannot read properties of undefined (reading 'command')" as long as the inject-node does not contain any message.

If I inject the timestamp as msg.payload, the unifi node still says "ERR_Network" but there is no further message in the debug log.

I tried to figure out if there is an error in my config or a missmatch with a component version, but unfortunately I didnot find any hiwto / manual or other things that gave me a hint how to sort the problem...

my setup: UDM-PRO with UniFi OS UDM Pro 2.5.17 nodered V3.0.2 running on docker node-red-contrib-unifi version 0.2.14 node js V16.9.1

unifyconfig node: Server: 10.0.10.1 Port: 8443 Unify OS ticked user / pw as created in my UDM-Pro

any ideas? I´ve also tried port 443 and created another admin user for UDM-Pro - without success...

Thanks, Walter

marc-gist commented 1 year ago

same on UniFi Network Application 7.3.83

marc-gist commented 1 year ago

Note, on debug node i see

{"_msgid":"5330e33ce5e7cd3a","payload":{},"topic":"","error":"ERR_BAD_REQUEST"}
marc-gist commented 1 year ago

FIXED: We need to use the sitename from the URL: i.e. /manage/xxxxxx/settings/wifi, would be xxxxxx in the site name.

UnwiredWalter commented 1 year ago

Hi,

I´ve set the sitename in the config node - but still the unifi node shows "ERR_NETWORK" and in the debug log it says "TypeError: Cannot read properties of undefined (reading 'command')"

Also I tried to use the sitename as payload and/or topic in the inject node - without any success. Whenever I configure some message part to be injected, the debug log does not show anything at all...

no matter what options, names I configure, the unifi node doesn't provide anything but error messages :-( again I tried port 8443 / 443 as well as putting http/https in front of the ip without success

I´m out of ideas what might cause the problem - maybe it´s a layer8 problem

[ { "id": "1934c6c80f43d4ec", "type": "Unifi", "z": "e089622.6a906a", "name": "Zuhause", "server": "fa627ee029541c8e", "command": "1", "x": 340, "y": 340, "wires": [ [ "5b977a59b3611d9d" ] ] }, { "id": "fa627ee029541c8e", "type": "unificonfig", "name": "Zuhause", "ip": "10.0.10.1", "port": "443", "site": "default", "unifios": true, "ssl": false } ]

Isaksson commented 1 year ago

Hello. Lets try to figure this out. Do not use https only the ip address. UDM then you should tick the Unifi OS and port 443

I see that you use site default, that is correct in most cases, unless you have created a site manually in Unifi and not use the default one.

Did this issue just started from a day to another or is this a new installation of the node?

UnwiredWalter commented 1 year ago

Hi,

No matter if it´s the ip alone or with http - the error is the same. my sites name is default (https://10.0.10.1/network/default/dashboard) No matter waht I rie the unifi node itself shows a smal red square and the message "ERR_NETWORK"

I had it working a couple of weeks ago but deleted the package afterwards; Since then I updated the UDM to the latest version and also installed / removed / re-installed the node-red-contrib-unifi package a couple of times - so I´m afraid the problem is somehow related with Unifi OS 2.5.17 and/or Network module version 7.3.83

What I do not really understand is if I need to inject a spacific message into the unifi node in order to get the information back. When I inject an empty message, the debug log shows "TypeError: Cannot read properties of undefined (reading 'command')" When I inject a timestamp as msg.payload, the debug log shows nothing at all.

Isaksson commented 1 year ago

I verified the node against a Dream Router with OS 3.0.17 and network 7.3.83 works as it should. Are you sure that you provide a correct username and password?

UnwiredWalter commented 1 year ago

Yes, I have created a local user for nodered with admin permissions in the UDM.

I have three instances of nodered running on my raspi - Test, Staging, Productive. The last tests which caused the error were made in the Test environment - so I tried it in my PROD environment and it WORKS! I exported the working flow from Prod, deleted the config node in TEST and imported the flow in test - and in the Test environment the problem still persists. So the root cause must be related to the Test environment...

Can you think of any reason causing the Network Error in the Test environment while the same flow is working in Prod?

bobbytables2048 commented 1 year ago

Similar issue here. "ERR_BAD_REQUEST" and the debug shows "TypeError: Cannot read properties of undefined (reading 'command')".

I have two nodered instances. Both are on the same nodered version but with different version of the unifi node. One instance is using v0.1.16 of this node and works as expected. The other instance is v0.2.14 and has the error above.

Isaksson commented 1 year ago

I have tried this on many different instances of Node-RED but I have never seen this issue. I really cant think of anything that should cause this issue.

firstraysofthenewrisingsun commented 1 year ago

Does anyone have any answers for this? The owner of this project isn't very reponsive and doesn't provide any answers as to why these errors are occurring. If anyone has ANY answers I'd greatly appreciate it