I am trying to write a Tasker task to control a virtual lock I created with vEdge. A while back, one of the users here posted a lot of Tasker tasks that work using the ST Api to get Device IDs and to issue commands to the Api. There is a task to turn a switch on and off. There isn’t one to lock or unlock a lock.
I find the best way to figure out API syntax is to use debug mode of the ST CLI or developer tools in a web browser.
Using the ST CLI, you can add an environment variable that gives you debug information that includes API calls being made. So using the CLI, I can issue the unlock command for a lock and see the specific API being called and the format of the request body for the command:
bep@debian12:~$ SMARTTHINGS_DEBUG=true smartthings devices:commands eb0d3bf1-db9e-442d-9f8f-bf8ba318443b
[2025-06-30T10:14:02.404] [DEBUG] login-authenticator - authentication - enter
[2025-06-30T10:14:02.405] [DEBUG] rest-client - making axios request: {"url":"https://api.smartthings.com/devices/eb0d3bf1-db9e-442d-9f8f-bf8ba318443b","method":"get","headers":{"Content-Type":"application/json;charset=utf-8","Accept":"application/vnd.smartthings+json;v=20170916","User-Agent":"@smartthings/cli/1.10.2 linux-x64 node-v18.5.0","Accept-Language":"en-US","Authorization":"Bearer dae0584e-xxxx-xxxx-xxxx-xxxxxxxxxxxx"},"params":{}}
Test Lock
Components:
─────────────
1 main
2 settings
─────────────
? Enter component index or id 1
Capabilities:
────────────────────────────────────────
1 lock
2 platinummassive43262.unlockCodeName
3 heartsample19211.lockedCodeName
4 lockCodes
5 tamperAlert
6 battery
7 refresh
────────────────────────────────────────
? Enter capability index or id 1
[2025-06-30T10:14:05.567] [DEBUG] login-authenticator - authentication - enter
[2025-06-30T10:14:05.568] [DEBUG] rest-client - making axios request: {"url":"https://api.smartthings.com/capabilities/lock/1","method":"get","headers":{"Content-Type":"application/json;charset=utf-8","Accept":"application/json","User-Agent":"@smartthings/cli/1.10.2 linux-x64 node-v18.5.0","Accept-Language":"en-US","Authorization":"Bearer dae0584e-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}}
Commands:
──────────────
1 unlock()
2 unlatch()
3 lock()
──────────────
? Enter command 1
[2025-06-30T10:14:06.978] [DEBUG] login-authenticator - authentication - enter
[2025-06-30T10:14:06.979] [DEBUG] rest-client - making axios request: {"url":"https://api.smartthings.com/devices/eb0d3bf1-db9e-442d-9f8f-bf8ba318443b/commands","method":"post","headers":{"Content-Type":"application/json;charset=utf-8","Accept":"application/json","User-Agent":"@smartthings/cli/1.10.2 linux-x64 node-v18.5.0","Accept-Language":"en-US","Authorization":"Bearer dae0584e-xxxx-xxxx-xxxx-xxxxxxxxxxxx"},"data":{"commands":[{"component":"main","capability":"lock","command":"unlock"}]}}
Command executed successfully
For an unlock command, we see the request body is "“data”:{“commands”:[{“component”:“main”,“capability”:“lock”,“command”:“unlock”}]}}.
Using the developer tools in the web browser, I can also issue an unlock command from the Advanced Web App and see the request body for that command to get the proper syntax.
And you also helped solve another error: I didn’t quite have the correct Device ID. Sheesh. Duh. Fixed that and now it works the way it’s supposed to. Thanks again!
Hey, gang. I’m back. I now have the Aeotec Hub installed. I can see it in the Android SmartThings app. I’m looking for some guidance, though. Should I make a group hub with my v2 hub? Or is that not really necessary? If I want to add a matter lock, how do I do that? Do I just hit + on the main app screen and select matter device? Will it know to use the thread network on the Aeotec Hub? I’m usually a little more tech savvy than this, but I don’t want to screw it up now that I have the new hub going. I hate to just try it and not have it work (although TBH I’m not entirely hopeful since my experiment with the Echo failed). Thanks!
OMG! It worked! Considering how much time I’ve wasted with the lock, ordering an Echo, setting that up, and when that didn’t work, trying to keep track of lock/unlock using Kwikset app notifications on my phone, Tasker, and some virtual devices. It was actually a breeze with the Aeotec Hub. And I have it all set up SharpTools as well (where I have a Rule to load all the codes so I don’t have use the lock app on SmartThings (whatever it’s called). Thanks!
P.S. Nuts. I just realized that this isn’t in the thread that I intended. I think I meant for it to go in the Integrating Halo Lock thread. Oh well. It’s all’s well that ends well.
I was using the virtual lock to track the status of the lock using Alexa per the suggestion in this thread, but it wasn’t foolproof. Integrate Kwikset Halo?.