That’s a very interesting question. Normally, you would either enter them through Habmin or PaperUI. Or you could enter them into the device’s XML file. When setting a code through Habmin, you can see something like this being sent…
usercode_code_5: 123456
Sending the following through the REST API seems to work, and the response has the numbers sent, but when checking the config and in Habmin, the code is always displayed as 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A.
{ “usercode_code_5”: “123456” }
To do this through the REST API, you’d need your device’s ThingUID (i.e., zwave:device:55555:node100). Then you’d do something like this…
val String updateResponse = executeCommandLine("/bin/sh@@-c@@/usr/bin/curl -o /dev/null -s -w \"%{http_code}\" --connect-timeout 10 --max-time 10 -X PUT --header \"Content-Type: application/json\" --header \"Accept: application/json\" -d \"{ \\\"usercode_code_5\\\": \\\"123456\\\" }\" \"http://localhost:8080/rest/things/zwave:device:55555:node100/config\"",10000)
logDebug("Rules","Test: updateResponse=[{}]",updateResponse)
I’m pretty sure there can’t be gaps in the codes, so if you have codes 1-3, don’t try a code 5 or it won’t work. Do code 4 instead. To clear them, send…
{ “usercode_code_5”: “” }
You can verify there is a code in that slot by checking…
http://<your OH server>:8080/rest/things/<the Thing UID>
Thank you for asking for this. I very rarely need a guest code, but now I can just ask Alexa to enable/disable it, instead of punching a code into the locks!