smartthings-cli
smartthings-cli copied to clipboard
question: How to run multiple commands at one?
What is your question? Please describe. How can I run multiple commands?
I want to submit multiple commands like this: [ {"capability":"samsungce.dryerCycle", "command":"setDryerCycle", "arguments":["Course_1F"]}, {"capability":"samsungce.dryerDelayEnd", "command":"setDelayTime", "arguments":["642"]}, {"capability":"samsungce.dryerOperatingState", "command":"start"}, ]
This is possible with curl POST but I don't want to have to keep renewing the PAT/bearer token ever 24 hours. How long does the token last with this cli tool? It's been > 24hrs since I last authenticated so I assume smartthings-cli uses a long living token or smartapp token maybe?
Ah, never mind I had a type-typo in the json, it works as required with -i <file.json>.
-i file.json works, but can't get this to work with -j even when using the same json.
./smartthings devices:commands cdXXXXXX-275e-XXXX-ef4b-XXXXXX6ba429 -j ' [
{
"capability": "samsungce.dryerCycle",
"command": "setDryerCycle",
"arguments": ["Course_1F"]
}]'
AxiosError: Request failed with status code 422:
{"requestId":"40229XXXXXXXXXX7115","error":{"code":"ConstraintViolationError","message":"The request is
malformed.","details":[{"code":"NotValidValue","target":"commands[0].component","message":"\n [\n
{\n \"capability\" is not a valid value.","details":[]}]}}
Code: ERR_BAD_REQUEST
The -j ~command~ flag doesn't take any arguments and you can't specify more than one command on the command line like that. You could instead pipe the commands to the CLI:
echo '[{"component": "main", "capability": "switch", "command": "off"}]' | st devices:commands <device-id>
(Note that JSON is the default for non-tty input so there is seldom a need for the -j flag.)
Thanks. this works just as required and with multiple commands.
Will the authentication token work indefinitely of will it need to be renewed/re-auth'd periodically?
No, the token won't work indefinitely - you'll be prompted to log in once it expires.
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.