bkorda / node-red-contrib-zway

GNU General Public License v3.0
5 stars 4 forks source link

Added support for Z-Way Authentication token. #11

Closed PoltoS closed 2 years ago

PoltoS commented 3 years ago

Starting from v3.2.0 Z-Way requires Websocket API to be authenticate like HTTP API. This changes the node-red integration module to use the Z-Way auth token instead of login/pass.

You can change back to login/pass and autodetect the token from the first discoverDevices. Up to you

NB! This was not tested - please check before merging.

Should fix: #10

bkorda commented 3 years ago

Could somebody test it? I have no hardware anymore

PoltoS commented 3 years ago

If you give me a simple instruction on how to install node-red and this module, I can. But note, that I've ZERO experience in node-red

maggiagg commented 3 years ago

I could test it. I have rpi running with nodered. But I dont have any idea on how to get the fork/pull-request from Github into nodered. If @PoltoS or @bkorda knows how to do this and give me a short instruction I can test. Otherwise there is some kind of description at https://nodered.org/docs/creating-nodes/first-node#testing-your-node-in-node-red.

bkorda commented 2 years ago

Ok guys, sorry for such a big delay. Will test it and update plugin

Vinisz commented 2 years ago

I tested this, but I need to enter token in the config-node of zway, I used a token grabbed from zway web interface, but that crashes node-red @PoltoS , seems like PMs not working on zway forum. Did I use the right token or should I do it another way ?

PoltoS commented 2 years ago

The token is the right one (from Z-Way web UI). I fear my fixes made "in blind" were not correct and that lead to the error. Maybe @bkorda can fix it. If not, we add it to our long queue of tasks.

Vinisz commented 2 years ago

@PoltoS ok thanks, well, I'm not a dev so cannot solve this... Can however test from time to time... @bkorda , are you able to make this work?

Vinisz commented 2 years ago

Tested on latest Zway release (3.2.2.) as well, still does not work and causes a crash of node-red.

image 2021-12-02T20_45_01_927Z-debug.log

@bkorda

Vinisz commented 2 years ago

@PoltoS , can you check on above please ? maybe it provides some insights.... debug log is there.

PoltoS commented 2 years ago

I can just try-and-fail if you provide me direct access via SSH and web UI.

bkorda commented 2 years ago

Can not reproduce this. I don't use docker. Looks like it is specific issue image

bkorda commented 2 years ago

Try to remove every server (configuration) node from flow, deploy changes, add a new server node.

Vinisz commented 2 years ago

Ok, I’ll try that later

From: Bohdan Korda @.> Sent: maandag 13 december 2021 12:37 To: bkorda/node-red-contrib-zway @.> Cc: Vinisz @.>; Comment @.> Subject: Re: [bkorda/node-red-contrib-zway] Added support for Z-Way Authentication token. (#11)

Try to remove every server (configuration) node from flow, deploy changes, add a new server node.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bkorda/node-red-contrib-zway/pull/11#issuecomment-992375733 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AL2YLJAAOIOHXKR7KRAD3R3UQXLFLANCNFSM5DRGYA3A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub . https://github.com/notifications/beacon/AL2YLJF7BZZNT2FMM4HUJELUQXLFLA5CNFSM5DRGYA3KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOHMTHHNI.gif

Vinisz commented 2 years ago

@bkorda , tried directly on the RPI, so node-red and Zway running on same device, same issue, here is the output from the RPI

13 Dec 16:04:01 - TypeError: Cannot read property 'devices' of null at Request._callback (/root/.node-red/node_modules/node-red-contrib-zway/nod es/server.js:75:59) at Request.self.callback (/root/.node-red/node_modules/request/request.js:18 5:22) at Request.emit (events.js:314:20) at Request. (/root/.node-red/node_modules/request/request.js:1154 :10) at Request.emit (events.js:314:20) at IncomingMessage. (/root/.node-red/node_modules/request/request .js:1076:12) at Object.onceWrapper (events.js:420:28) at IncomingMessage.emit (events.js:326:22) at endReadableNT (_stream_readable.js:1241:12) at processTicksAndRejections (internal/process/task_queues.js:84:21)

Vinisz commented 2 years ago

Ok, found it after some more testing... I forgot to include the "/" in the API key (that should still not crash node-red but ok) Now working all fine, in docker as well... @bkorda and @PoltoS , thank you for making this happen ! now I'm finally on latest Zway

PoltoS commented 2 years ago

Looks like if the token is wrong (missing / or just expired), the answer will be null (403) and as a result node_red crashes. May be it is worth to add such a check not to crash node-red.