mjwwit / node-red-contrib-ikea-tradfri

Node-RED nodes to get updates from and control devices connected to an IKEA TRADFRI gateway
3 stars 3 forks source link

Can't connect on my gateway #2

Closed Benoulimou closed 3 years ago

Benoulimou commented 3 years ago

Hi,

When I want to connect my gatway, I enter the ip and the security code but nothing happens. I have no way of knowing why.

mjwwit commented 3 years ago

Thanks for reporting this! Did you check the debug logs in the Node-RED interface?

Benoulimou commented 3 years ago

yes it say only :

An error occurred while connecting with the TRADFRI gateway: ConnectionFailed

i'm sur of my ip an security code

mjwwit commented 3 years ago

Can you ping the gateway IP from the device you're running Node-RED on? And if you're running Node-RED in a Docker container, can you ping the gateway from inside the container?

Benoulimou commented 3 years ago

I'm use node red in home assistant. Under my vm i can ping my gateway tradfri.

mjwwit commented 3 years ago

Alright, I'll see if I can add more information to the connection error messages. Maybe that will clarify what the problem is.

Benoulimou commented 3 years ago

thx al lot

mjwwit commented 3 years ago

I've just released version 0.4.2 which includes several error reporting improvements. Hopefully this clarifies why you are unable to connect to the gateway.

Benoulimou commented 3 years ago

Thank you very much but I can't get the update. Neither on Nod Red nor through npm

mjwwit commented 3 years ago

Node-RED always needs a bit of time before it shows the update, but it should be available through npm: https://www.npmjs.com/package/node-red-contrib-ikea-tradfri/v/0.4.2

h4rdw0rk1ngdud3 commented 3 years ago

Maybe i have a related problem. I'm running redmatic on a HomematicIP CCU3. I didn't installed the new version with the improved debugging yet. But i checked the url which is requested by the config node when "authenticate" was clicked. It did not POST to "[gateway-ip]/authenticate" but it appends this path to the url where Node Red is available on my CCU3, like "ccu/addons/red/[gateway-ip]/authenticate". Maybe the way the request url is build is the problem. But i will check this with the new version too and report my logs.

matteos1 commented 3 years ago

node red in home assistant not autenticate the gateway

Benoulimou commented 3 years ago

hi , error :

An error occurred while connecting with the TRADFRI gateway: ConnectionFailedCould not connect to the gateway after 3 tries:An unexpected error occured while connecting to the gateway: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined

mjwwit commented 3 years ago

Ah! After entering the gateway IP-address and the security code, have you clicked the "Authenticate" button? The bottom two disabled input fields should get populated after that. Also, don't forget to save the node configuration after doing so.

mjwwit commented 3 years ago

node red in home assistant not autenticate the gateway

Are you sure your issue is directly related to this one? If not please open another issue and provide whatever information (setup, logs, errors) you can.

mjwwit commented 3 years ago

It did not POST to "[gateway-ip]/authenticate" but it appends this path to the url where Node Red is available on my CCU3, like "ccu/addons/red/[gateway-ip]/authenticate". Maybe the way the request url is build is the problem.

I've had no problems placing an IP address or hostname into the path of a URL like this.

Benoulimou commented 3 years ago

Ah! After entering the gateway IP-address and the security code, have you clicked the "Authenticate" button? The bottom two disabled input fields should get populated after that. Also, don't forget to save the node configuration after doing so.

Of course, but the fields remain empty and nothing happens when I click on authenticate. The ip format is 192.168.0.0 or http:// or something else?

mjwwit commented 3 years ago

It should just be the IP-address, no protocol prefix.

Can you open your browser devtools (F12) and watch for a request to /tradfri/gateway/[ip-address]/authenticate? It will probably not be successful, and the reponse to this request may possibly show us what's going on.

h4rdw0rk1ngdud3 commented 3 years ago

i also tried to check whats going on with the request, because even on version 0.4.2 is no further logging.

Request:

POST /tradfri/gateway/192.168.188.200/authenticate HTTP/1.1 Host: ccu3-webui Connection: keep-alive Content-Length: 29 Accept: / X-Requested-With: XMLHttpRequest User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36 Content-Type: application/x-www-form-urlencoded; charset=UTF-8 Origin: http://ccu3-webui Accept-Encoding: gzip, deflate Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7 Cookie: io=DSEkSC-H6o1E4MmAAAAF

Request-Body:

securityCode=[MYSECURITYCODE]

Response

HTTP/1.1 404 Not Found Accept-Ranges: bytes Cache-Control: private, no-cache, must-revalidate, no-transform, max-age=0 Content-Type: text/html; charset=iso-8859-1 Content-Length: 9 X-Frame-Options: SAMEORIGIN X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block X-Robots-Tag: none X-Download-Options: noopen X-Permitted-Cross-Domain-Policies: none Referrer-Policy: no-referrer Date: Fri, 19 Mar 2021 10:37:31 GMT

mjwwit commented 3 years ago

Interesting... Are you by any chance running Node-RED on a custom path? I now realize that Node-RED has this option, but I don't think I've accounted for it in this plugin.

h4rdw0rk1ngdud3 commented 3 years ago

Yes i think in this setup node red is configured with a custom path. It's reachable under "/addons/red" and port 80.

Benoulimou commented 3 years ago

It should just be the IP-address, no protocol prefix.

Can you open your browser devtools (F12) and watch for a request to /tradfri/gateway/[ip-address]/authenticate? It will probably not be successful, and the reponse to this request may possibly show us what's going on.

image

mjwwit commented 3 years ago

Alright, then I think you both have the same problem. Node-RED is running on a custom path, and this plugin does not account for that possibility. The other obvious issue is that these errors happen without proper feedback. I will resolve both issues in the next version.

mjwwit commented 3 years ago

Release version 0.4.3 includes both improvements and has just been published to npm.