There is always a reason. Some newbies complained and this happened
Baash,
I created a virtual TV device and was able to created this json command based on a routine that turns on the tv and mutes the tv in one command.
{“commands”:[{“component”:“main”,“capability”:“switch”,“command”:“on”},{“component”:“main”,“capability”:“audioMute”,“command”:“mute”}]}
And here is the json command to turn the tv on and set the volume, in this case to 5
{“commands”:[{“component”:“main”,“capability”:“switch”,“command”:“on”},{“component”:“main”,“capability”:“audioVolume”,“command”:“setVolume”,“arguments”:[5]}]}
Change the 5 to whatever level you want when the tv turns on. And zero should work
Btw just playing around with those three options I detailed above will help you get a better understanding of how ST works behind the scene
Kurt,
I pasted this command {"commands”:[{"component”:"main”,"capability”:"switch”,"command”:"on”},{"component”:"main”,"capability”:"audioMute”,"command”:"mute”}]}
And I’ve got this error message !
{“error”:{“message”:“The request is malformed.”,“details”:[{“code”:“BodyMalformedError”,“message”:“The request body is malformed and cannot be processed by server.”,“details”:,“target”:“httpRequestBody”}],“code”:“ConstraintViolationError”},“requestId”:“3427767690862164364”}
Baash,
It looks like when I pasted the json, the quotes were changed to curly quotes instead of straight quotes.
{"commands":[{"component":"main","capability":"switch","command":"on"},{"component":"main","capability":"audioMute","command":"mute"}]}
I re-pasted it as preformatted text this time (I didn’t know you could do that). This should work better.
Sorry about that
It works perfectly !!
Big, big thanks to you.
However, I stil didn’t understand how and where to create a virtual device !
Thanks
If you haven’t seen the FAQ on Creating Virtual Devices, perhaps it will shed some light on the subject for you.
Baash,
I’m glad it worked well for you.
Definitely take a look at the link John provided above. Virtual devices can be useful in so many situations especially when working with routines
Hi. I’m trying to run a shortcut to turn my TV off. However I keep getting error messages. Apologies but I’m new to this, so would welcome any suggestions and help please.
Dan,
Did you change the pat (personal authorization token) to your pat in the ST_Device_CMD_API shortcut?
If your pat is correct, could you please post the entire cmdJSON from the shortcut above
I haven’t seen this error before
this is crazy thank u so much ive never even done anything like this before and i was able to figure it out. ur the goat fr
I’m glad it worked out well for you Rayyan
hey, is it possible to control brightness with st_device_cmd_api , ? or is using st_scene_api and just making certain scene shortcuts with different brightnesses better? thanks.
I’m thinking you are asking for a shortcut that will ask for what dim level to set a light to.
Below is something similar that I did to set a thermostat. You will need change the Text to the correct command to set the dim level.
The short cut just asks for a number like 50 to set the dim level to 50%
Let me know if this works for you
I´m missing something as I always get a “401 Authorization Required” error.
Any help would be appreciated
Sorry for the delay, I’ve been busy and haven’t been on here in a little while
Based on the response from ST it looks like you haven’t entered your PAT in the ‘ST_Device_CMD_API’ shortcut. See post from Feb 11 for further info related to adding your PAT
This is perfect. Very smart way to manage the common variables in the four API files. Thanks for posting this.
FYI…
I really hope that they will eventually support iOS Shortcuts natively, now that they have restricted PATs and essentially broken this workaround for new users. After all, they also added native support for live activities and widgets on iOS.
In fact, few versions ago, there was a bug in the SmartThings iOS app where the functions of the buttons shown in the Quick Remote live activity notification (such as turning on and off a Samsung TV) accidentally showed up in Shortcuts. So it seems like proper Shortcuts support could be implemented reasonably easily, if Samsung chooses to do so.
rambo350z This works for about two days and then the token no longer works. I get the 401 error. I verify the token is still there. I have the right key.
The only way to fix it is to create a new token.
Anyone know why the token only works for a couple of days?
Because of the „Changes To Personal Access Tokens (PAT)“ described in the thread that @jkp linked to in response to your previous post: