Using iOS Shortcuts and Siri to Interact with Smartthings

Sarava,

It looks like your command json is not correctly formatted. Can you post the command json you are using. Go to your device shortcut and copy the command json field and paste it into a reply

The json should look similar to the following:
{“commands”: [{“component”: “main”,“capability”: “switch”,“command”:“off”}]}

2 Likes

I am trying to turn an office light switch on, but cannot seem to make it work. Can I get a little help with the shortcut below?

Joe,

I’m not sure why you are modifying the ST_Device_CMD_API shortcut. That shortcut should remain as is

The shortcut you want to modify is the ‘test device on’ shortcut. Just change the device id in this shortcut to your device id and adjust the command json as necessary, in your case to turn on your device, no change will be needed

The reason that your modification doesn’t work is because the command json is sent in the body of the post request (File value) With your changes, I’m not sure what is being sent in the body

1 Like

Kurt,

Thank you so much for the prompt response, I am total newbie at this, so will give it a go per your directions,

Joe

Kurt,

Thanks again! Followed your instructions and works great. This is fantastic!

Joe

1 Like

Hi Joe,

I’m glad it worked out for you. Now can control any device with Siri. Just duplicate the test_device_on shortcut and change the device I’d and cmd json

2 Likes

Hello Kurt,
I’m trying to make it work but the CMD shortcut is not working while the scene are working. I want to turn on/off my TV Samsung QN95BA 75. I have used in the test shortcut the following commands: {“commands”: [{“component”: “main”,“capability”: “switch”,“command”:“off”}]} and this {
“commands”: [
{
“componentId”: “main”,
“capabilityId”: “switch”,
“command”: “on”,
“arguments”: // if the “on” command requires any arguments, include them here
}
]
}
and both are not working. the errors are the followin, in the first case (as you posted)
{“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”:“4267478330178022217”}

with the modification I made:
{“error”:{“message”:“The request is malformed.”,“details”:[{“code”:“BodyMalformedError”,“message”:“The request body is malformed and cannot be processed by server.”,“details”:,“target”:“commands”}],“code”:“ConstraintViolationError”},“requestId”:“8761868291888264572”}

Any advice on how can I solve it?

thanks

Hi Juan,

First off, the json you pasted has the wrong type of quotes. Your json has curly quotes ( “ ) and they need to be straight quotes ( " )Though the quotes may have been changed when you pasted

You can check that your json is valid by using a json format checking web site

In the second command json there are also errors. The componentId: should be just component: and the capabilityId: should just be capability:

And I’m not sure if the argument: part is needed

These command json should work or at least not give you the same error. Though I’m not sure if the TV uses switch capability to control its on/off state

{“commands”: [{“component”: “main”,“capability”: “switch”,“command”:“off”}]}

{“commands”: [{“component”: “main”,“capability”: “switch”,“command”:“on”}]}

Let me know if these work.

I just created a virtual TV and was able to control it with the ‘test device on’ and ‘test device off’. Just create a duplicate of each shortcut rename the shortcuts and update the deviceid to the id of your tv in the dictionary field. The cmdJSON field can stay as is

1 Like

Hey I am trying to use your shortcut to activate a scene but it doesnt seem to work
it says missing input dictionary
i just modified your scene shortcut all i have to change is the following?
the startreq https://api.smartthings.com/v1/scenes/mysceneidhere
pat my personal token
and I added Text sceneid with my scene id next to it
what have i done wrong?

Robert,

You don’t need to add the scene id to the ST_Scene_API shortcut. The only change needed in the ST_Scene_API shortcut is to change the pat valve in the dictionary to your pat.

To create a scene shortcut, duplicate the ‘test scene’ shortcut, rename it as necessary and change the sceneid value in the dictionary to your scene id. Your duplicated scene shortcut will call the ST_Scene_API to send the Post request to the SmartThings Scene API. To make additional scene shortcuts, do the same thing by duplicating the ‘test scene’ again

To execute your scene with Siri, just say “Hey Siri, execute yourscenename shortcut”

Let me know if this works and if you have any further questions

1 Like

Thanks a lot got it working now!

Hi Kurt
Thanks for your help creating this
I’m trying to control a Meross garage door opener, when I click on the scene and input shortcuts it says missing dictionary inputs, I’ve got a PAT in both

I’m getting this error on the test device shortcut

{“error”:{“message”:“The request is malformed.”,“details”:[{“code”:“NotValidValue”,“message”:“switch is not a valid value.”,“details”:,“target”:“commands[0].capability”}],“code”:“ConstraintViolationError”},“requestId”:“3403118136073488133”}

Mark,

The pat is only needed in the xxxx_api shortcut. The shortcut goes in the test scene shortcut.

Please read my reply to Robert two messages earlier

Hi Kurt,
Im still confused, to operate my garage door opener I just need the one API shortcut?
(ST_Device_CMD_API) (I have the pat in it and the api.smartthings in the dictionary part of the shortcut)
and the test device on.shortcut? (I have deviceid in it)

Mark,

Sorry, I didn’t read the error message carefully enough. It looks like the Meross uses a different capability than switch to control the garage door (GD). So there are a few options to get these shortcuts to control the Meross

Option 1: Create two Manual Run Routines (Scenes). One to open the GD and one to close the GD. Then duplicate the ‘test scene’ shortcut twice and rename them as appropriate (i.e. GD Open, GD Close). Edit each shortcut and change the sceneid in the dictionary with the corresponding scene id. Then edit the ST_Scene_API shortcut and change the locid with the your location id and the pat with your Personal Access Token. You can get the scene and location ids using Todd Austin’s excellent SmartThings® API Browser+

Option 2: Create an Automatic Routine that controls your GD in order to fine out what the capability and commands are for the Meross. You can use anything in the If part of the routine (I usually use time since it the 1st option). In the Then part select your Meross device and then select either open or close. Then use SmartThings® API Browser+ to examine the json created for the routine (select the Automations drop down, select the routine you just created and then select Details. The json will be shown on the right). After the If part of the json you see something like this

“commands”: [
{
“component”: “main”,
“capability”: "Merosscapability ",
“command”: "open”
}
],

With this information you should be able to change the cmdJSON in the ‘test device off’ shortcut with the Meross capability and command to something like this:

{“commands”: [{“component”: “main”,“capability”:”Merosscapability",“command”:“open”}]}

Then change the deviceid in the shortcut with the Meross device id and update the ST_Device_API with your pat

Note, I don’t have a Meross so I’m just guessing at the capability and commands

Option 3: Create of virtual Garage Door device (vGD). Create two Automatic Routines (one to open the GD, one to close the GD). Use your vGD device in the If part (If vGD turns on) and control your Meross in the Then part (Then Open GD) of each routine.
Then you can use the ‘device test off’ shortcut to control the vGD device (using either off or on in the cmdJSON), changing the deviceid to the id of the vGD

With all these options you will need two shortcuts, one to open the GD and one to close the GD

I know it’s a little convoluted to get these shortcuts to work with the Meross. It seems like option 1 would be the simplest to implement. But you’ll gain additional insight into haw ST works behind the scene the using option 2 method

If you use the option 2 method, please post the capability and command that the Meross uses for control so other users can benefit from the information

Please let me how it works out and if you have further questions

1 Like

Mark,

Looking at the virtual Garage Door device details, I think I figured out what the Meross is likely using for capacity and command

Update the the cmdJSON in the test device off’ shortcut (duplicate and rename it the shortcut first) with the following json

{“commands”: [{“component”: “main”,“capability”: “doorControl”,“command”:“close”}]}

A shortcut I created using the above json to control the vGD worked as expected

Hi Kurt,

First, thanks for your great job, I was looking for a solution to turn on/off my Samsung TV with Siri, and you gave me the solution.

Second, I still have a small problem. I would like to lower the volume at the same time as I turn on the TV (the children tend to turn up the volume!!), and I can’t find the command to do that.

I’ve tried the JSON command {“commands”: [{“component”: “main”,“capability”: “switch”,“command”:“mute”}]}, but it didn’t work. In fact, I don’t know how to find correct comment ?!?!

Thanks

Baash,

Check out option 2 from post 35 above. You should be able to find out the command json by following those steps.

Let me know if that works ir you need further assistance

Sure, Kurt,

I found the post you mentioned, but I’m not very good at this, and I don’t see where to create an automatic routine or even what it is!

Can you give me more information?

Thanks

For reasons which no one outside the company understands, SmartThings recently decided to rename their automations.

They used to have “routines“ which were automations which would run when a specific “if“ condition was met.

And “scenes“ which were the state settings for a group of devices that would be activated when someone either tapped the scene tile in the app or included the scene as an action in a routine.

These two terms are consistent with how most home automation platforms use them.

But then…somebody at Samsung decided it would be a good idea to change these terms. :thinking:

So now routines are called “automatic routines“ and scenes are called “manually run routines“ even though you can include a scene in an automatic routine, and it will also run automatically. So not only is the new term different from what pretty much everybody else in the industry uses, it also doesn’t make any sense. But there it is. :man_shrugging:t2:

To create an “automatic routine“, you just create a routine in the SmartThings app and don’t select “manually run“ for the If option.