I’ve been able to hack status out of my environment with pysmarthings pretty easy, but using lockCodes:setCode is proving problematic. I can get it to work with CLI so I expect it’s just syntax for pysmartthings. Working CLI example:
Are you getting a “body malformed error”?
Sometimes you have to escape the symbol ", it would be useful if you checked how that function is sending the request, especially in the function post_device_command because it is called from device.command
Do you know which controller is the device using? You can verify this by listing the devices using the ST CLI or a direct query to the SmartThings API
You can identify each type by these properties:
DTH: deviceTypeName, DTH (which has other details), type: "DTH"
Edge Driver: driverId (inside a property called “zigbee”, “zwave” or “lan”, depending on the protocol used by the device), type: "lan/zigbee/zwave"
ST Schema: "viper", type: "VIPER"
If it’s a stock DTH, you can check its config in the official repo below and confirm there’s a handler for the command setCode.
This is because, despite the capability has the command on its properties, there needs to be a handler for this event to perform the required actions.
aah, sorry, I forgot you mentioned it worked on the CLI.
Well, then, there must be something else. The success message generated by pysmartthings is due to the “accepted” response from the API, right?
Have you verified the value sent in the command is correct? I mean the generated command before sending it to the ST API (I think it is in post_device_command).
We get the response from the API saying “accepted” and a 200 code when there were no obvious issues (syntax, capability’s name, etc.) but it doesn’t mean the execution inside the device handler was correct.
In your code, I only noticed some " symbols were missing in “slot”, have you corrected that?