That’s what the st-command from the SmartThings CLI package sends as body when I ask it to switch on a light bulb, and that works:
$ /home/ok/cli/st command device --id <id-here> --component main --capability switch --command on
OK
Edited to ensure correct double quotes used in JSON blob.
If you get a 200 ok then I would look at the actual device itself. When you say “my switch isn’t turning on” do you mean a bulb? If it is actual switch, then how are you ascertaining whether the switch is turning on or not? Looking at your mobile app?
Note that you can’t cut’n’paste the JSON from my original post (fixed now), as the double quotes (") were prettified and turned into different characters. If you use the wrong quotes, you get your 422. The JSON below should be okay as I’ve added some formatting.
I have looked at the example using postman. I obtain the personal access token. When I execute the command in Postman it returns a list of about 6 devices. None of which are mine. They are all simulated devices called door1, door2, etc.
@Jwwhite I assume you got the personal access token from this page? https://account.smartthings.com/login which is correct. Device list you will get will contain devices that are associated with your Location. In turn, the Location is associated with your Samsung account. In the past, a few of us pulled our hair in confusion about which one is our Samsung account and which one is SmartThings, when we use the same email id, such as raj.karamchedu@smartthigns.com, in my case for both the accounts. Mercifully when you click on the above PAT page, it will ask you to login to the correct account, either Samsung or SmartThings. You will get the listing of the devices that are in the account you use to generate the PAT (actually, more exactly, you will get the listing of the devices that are associated with the Location in the account you use to generate the PAT). So, in a nutshell, it helps to check if you generated your PAT with the correct account, i.e., to which your Location is associated and devices are present. Sorry if my answer felt like short story long.
I figured out what is going on, just don’t know how to fix it.
I had configured a second location for testing. Don’t really use it anymore but it has the simulated devices showing up in Postman. I tried creating a new access token selecting all locations, etc. But it still only shows that test location, not my main location.
By the way, using the link you mentioned https://account.smartthings.com/login, just takes me to my main ide. Where do you go from there to get the token? I used the link in the writeup which takes me to a create token page.
I tried deleting the test location then creating a new token. With that one I get nothing in the list.
@Jwwhite If it is already taking you to your main IDE, then I suggest this: log out of the IDE. Clear out the browser cache (try an cognito window). The idea is to force it to stay clean and ask you to login. This might help.
@Jwwhite yes yes, you are on the right track. Click on that url. It will take you to the second page where you will see your devices. If you are doing this from Postman, after you click on the url, you may have to make sure that Bearer token field is selected.