freahs / node-red-contrib-node-tradfri

Node-RED node to utilize IKEA Trådfri devices. Fully implemented in Node.js.
GNU General Public License v3.0
7 stars 13 forks source link

Can't connect to Tradfri Gateway #5

Open pedesen opened 6 years ago

pedesen commented 6 years ago

Hey, thanks for the great library, looks very promising, especially the observer part. But I cannot get it to work. What I tried:

  1. Added the tradfri node to the flow, clicked on it
  2. Clicked "Add new tradfri-connection"
  3. Entered IP-Address and Security Code (nothing else)
  4. Clicked Update

Then I see an error in the console:

TypeError: Cannot read property 'getLights' of null
    at /home/pi/.node-red/node_modules/node-red-contrib-node-tradfri/dist/node-tradfri.js:50:30
    at Layer.handle [as handle_request] (/usr/lib/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)
    at next (/usr/lib/node_modules/node-red/node_modules/express/lib/router/route.js:131:13)
    at /usr/lib/node_modules/node-red/red/api/auth/index.js:63:13
    at Layer.handle [as handle_request] (/usr/lib/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)
    at next (/usr/lib/node_modules/node-red/node_modules/express/lib/router/route.js:131:13)
    at Route.dispatch (/usr/lib/node_modules/node-red/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/usr/lib/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)
    at /usr/lib/node_modules/node-red/node_modules/express/lib/router/index.js:277:22
    at Function.process_params (/usr/lib/node_modules/node-red/node_modules/express/lib/router/index.js:330:12)
    at next (/usr/lib/node_modules/node-red/node_modules/express/lib/router/index.js:271:10)
    at urlencodedParser (/usr/lib/node_modules/node-red/node_modules/body-parser/lib/types/urlencoded.js:91:7)
    at Layer.handle [as handle_request] (/usr/lib/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/usr/lib/node_modules/node-red/node_modules/express/lib/router/index.js:312:13)
    at /usr/lib/node_modules/node-red/node_modules/express/lib/router/index.js:280:7
    at Function.process_params (/usr/lib/node_modules/node-red/node_modules/express/lib/router/index.js:330:12)
  1. Tried to refresh the device list, nothing happens. I can only select None.

I also tried to deploy the flow between the steps, but nothing works. Maybe I have some time the next days to debug a bit myself, but any help is appreciated. Thanks!

freahs commented 6 years ago

Hey and thanks!

Unfortunately I can't tell you why this is happening right now and I've got midterm exams coming up this week so can't really spare the time for private projects at the moment. Will fix it next week or the week after when I have more time.

pedesen commented 6 years ago

Don't worry, good luck with the exams!

missaak commented 6 years ago

I think I had got same problem with creating connection.. I used https://flows.nodered.org/node/node-red-contrib-tradfri to generate pair of App Identity and Preshared Key that I used for this project. It started work after that and I was able to use 'observe' feature, which project mentioned above doesn't contain. It is just workaround..

pedesen commented 6 years ago

Thanks for the hint. I managed to get a preshared key with node-red-contrib-tradfri. Then I tried entering the URL, app identity and the preshared key (nohing else), but no luck. Got the same error message.

missaak commented 6 years ago

In node-red-contrib-tradfri config you have to fill: "Hub IP address", "Security Code" and "App Identity" (it should be random string) and path to CoAP library. New "Preshared key" will be generated for App identity after saving. And all these information (IP, Security code, App identity and Preshared key) must be inserted to new configuration for this project. It had started working for me..

flavorplus commented 6 years ago

This should not be an issue. The node is trying to request the lights-list when the connection node is not created yet. Follow the following procedure to get the this working:

  1. Added the tradfri node to the flow, click on it
  2. Click "Add new tradfri-connection"
  3. Entered IP-Address and Security Code (nothing else)
  4. Click Update
  5. Click Done
  6. Click Deploy
  7. Click again on the node to open it
  8. The device list should be populated and you should be able to select a device and use it.
  9. Click Done
  10. Click Deploy again.

This is not the best behaviour and should probably be improved in the feature.

mikuslaw commented 5 years ago

Hi, thank you for the plugin. It's great to have the support for tradfi lights.

I have the same issue. I add the node with tradfri, I leave identity empty, put the security code in, and deploy. I don't get anything on my device list after that.

I will try to get the psk/identity first and see if it helps.