Forgive me if this is posted in the wrong place … but I just realized all my Webcore stopped working … I have a few devices that rely on my SmartThings Hub and I had a REST API set up to talk to it from my system (OpenHab) … well now I am trying to get the new REST API working and having some trouble … not too much out there on the community I could find and the ST documentation is so thoroughly complete it would take days to absorb.
Basically I can now do the following:
curl -X GET -H "Authorization: Bearer a0b4d89c-d7fa-48f3-xxxxx" -H "Content-Type: application/json" -d '{"command":"on"}' "https://api.smartthings.com/v1/devices/91cc9707-7ab3-4328-a664-218210e71bc5/"
This returns the device status which is:
{"deviceId":"91cc9707-7ab3-4328-a664-218210e71bc5","name":"eWeLink Outlet","label":"FrontRoom_Light","manufacturerName":"SmartThingsCommunity","presentationId":"dc51981a-71db-3f67-a30b-150d778cd741","deviceManufacturerCode":"eWeLink","locationId":"7dc0f22b-0a5c-4520-9ffb-7db6178887d8","roomId":"e78546b5-ba90-4514-ac03-61df7cb18634","components":[{"id":"main","label":"FrontRoom_Light","capabilities":[{"id":"switch","version":1},{"id":"firmwareUpdate","version":1},{"id":"refresh","version":1}],"categories":[{"name":"Switch","categoryType":"manufacturer"}]}],"createTime":"2021-10-17T15:09:54.085Z","parentDeviceId":"483b14be-ef93-4877-82b9-37b227fcce60","profile":{"id":"db6161b1-d26d-3a78-acea-c09dec91c31c"},"zigbee":{"eui":"00124B00226A6311","networkId":"7E53","driverId":"f2e891c6-00cc-446c-9192-8ebda63d9898","executingLocally":true,"hubId":"483b14be-ef93-4877-82b9-37b227fcce60","provisioningState":"PROVISIONED"},"type":"ZIGBEE","restrictionTier":0,"allowed":null}
Now, I would like to send it a command and learned (probably incorrectly) from ChatGPT that I should use:
curl -X PUT -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"command":"on"}' "https://api.smartthings.com/v1/devices/{deviceId}/commands"
Well this doesn’t work, and various attempts have failed as well. I get back a:
{"requestId":"1D44CAC2-5BAC-4E18-BAAB-5D89E1A32EC2","error":{"code":"ConstraintViolationError","message":"The request is malformed.","details":[{"code":"SizeError","target":"commands","message":"commands must have a size between 1 and 20.","details":[]}]}}
The “commands must have a size between 1 and 20.” doesn’t make a a lot of sense to me.
Can anyone direct me to a simple example of turning ON and OFF a switch through a cURL?
Thanks!