windkh / node-red-contrib-shelly

Shelly control nodes for node red.
MIT License
33 stars 21 forks source link

FIX #132 : GEN 2 | Callback Mode | If Shelly is password protected install script fails #133

Closed teixemf closed 10 months ago

teixemf commented 11 months ago

Fixes the issue with activating Callback Mode on GEN2 Shellys that are password protected.

On the install and uninstall skript functions, all the calls to shellyRequestAsync() using GET and passing the params different than null were replaced with calls to shellyRequestAsync() using the POST method.

windkh commented 11 months ago

2 Questions:

teixemf commented 11 months ago

Tested with v1.0.7 on "Shelly Plus 2PM" and "Shelly Plus I4"

Tested successfully with Authentication Enabled and Authentication DIisabled.

windkh commented 11 months ago

The weird thing is that Delete and Get behave differently. I have a bad feeling about that: maybe the shelly developers will change/fix that again in future... let's hope not

teixemf commented 11 months ago

Sorry but I don't understand you mean by something needing to be changed or fixed by the shelly developers. Using Postman I tested the API functions Script.List, Script.GetStatus and Script.Delete on all the four scenarios and on all the Shelly API returned properly. Could you explain better?

Bellow are the URLs, params and body I used to test the API using Postman.

HTTP GET + Shelly Auth Disabled http://{{shelly-ip}}/rpc/Script.List http://{{shelly-ip}}/rpc/Script.GetStatus?id=1 http://{{shelly-ip}}/rpc/Script.Delete?id=1

HTTP POST + Shelly Auth Disabled http://{{shelly-ip}}/rpc with the body: {"id":1,"method":"Script.List"} http://{{shelly-ip}}/rpc with the body: {"id":1,"method":"Script.GetStatus", "params":{"id":1}} http://{{shelly-ip}}/rpc with the body: {"id":1,"method":"Script.Delete","params":{"id":1}}

HTTP GET + Shelly Auth Enabled (all calls made with Digest Auth with Algorithm SHA-256 and username: admin and password: mypass ) http://{{shelly-ip}}/rpc/Script.List http://{{shelly-ip}}/rpc/Script.GetStatus?id=1 http://{{shelly-ip}}/rpc/Script.Delete?id=1

HTTP POST + Shelly Auth Enabled (all calls made with Digest Auth with Algorithm SHA-256 and username: admin and password: mypass ) http://{{shelly-ip}}/rpc with the body: {"id":1,"method":"Script.List"} http://{{shelly-ip}}/rpc with the body: {"id":1,"method":"Script.GetStatus", "params":{"id":1}} http://{{shelly-ip}}/rpc with the body: {"id":1,"method":"Script.Delete","params":{"id":1}}

windkh commented 10 months ago

@teixemf ah ok understood. So every call works either with GET + params or POST + method and data in body. I will merge your changes, but in the end I guess I need to rework the request method after you merge to get rid of the confusion between GET and POST. Thanks a lot for testing and providing your help: I will mention you in the readme