erikwihlborg76 / unofficial-danalock-web-api

9 stars 2 forks source link

lock operation fails #6

Open roccolord opened 3 months ago

roccolord commented 3 months ago

Getting information about one/all locks are fine. I get name and serial and so on for my lock, but running any command on the lock (state,battery,lock,unlock) fails with:

6 Mar 14:06:46 - [warn] [function:prepare "action" req] The action ful_entre is not recognized
6 Mar 14:06:46 - [info] [function:prepare "action" req] Preparing for action "ful_entre"
6 Mar 14:06:46 - [warn] [http request:bridge API] JSON parse error
6 Mar 14:06:46 - [error] [function:otherwise throw error] Unhandled outcome

Where "ful_entre" is the lock name and the url for running the command is: http://192.168.68.4:1880/endpoint/danalock/ful_entre/battery

I'm running this on a HA Green.

Any ideas?

roccolord commented 3 months ago

Ahh the prepare "action" rew splits on /

// Resolve "action" from URL
const parts = msg.req.originalUrl.split('/');
const action = parts.at(3);
msg.action = action;

And since I have endpoint in the url also the 3 should be 4.

erikwihlborg76 commented 3 months ago

I changed so the action was identified using const action = parts.at(-1); instead. Hope it works for your type of installation, else let me know.

So just grab the latest Nodered code in danalock.json.