I use terminal command to control my Samsung Oven mit SmartThings CLI. The command in the terminal is as follows and it works fine in the linux terminal:
When I do run this in the Exec-Node I do get "command failed" due to the time-out that I did set.
Neither "exec" nor "spawn" options works. The time-out is 120s, which should be long enough.
It must be something about the options. If I do just call the "smartthings" command I do get a reply from the api.
I did copy & paste the command from terminal into the exec-node to be sure there is no typo.
Maybe something about the characters "/-
That should have read 'connect the exec node outputs to three debug nodes'.
You can find the full path to the command (smartthings) using the command which smartthings
which will say something like /usr/bin/smartthings
in which case the command to use in the exec node would be /usr/bin/smartthings devices:commands <myDeviceID> --token=<myToken> 'main:execute:execute("/mode/vs/0",{"x.com.samsung.da.options":["Sound_Off"]})'
Hi @Colin
thanks for the fast reply.
Yes, the full path is this: /usr/bin/smartthings
And the filling works in my linux terminal: /usr/bin/smartthings devices:commands <myDeviceID> --token=<myToken> 'main:execute:execute("/mode/vs/0",{"x.com.samsung.da.options":["Sound_Off"]})'
Again, when using the Exec-Node I do rin into a time-out.
Status of the Exec-Node turns to killed
Only two of the three output nodes delivers a feedback (in exec mode):
When passing a command including embedded quotes, in here '..."..."...' through exec node, I wonder if there is not a problem of quotes on what is executed on the host??
I would try to see effectively what is happening on the host by replacing the command itself /usr/bin/smartthings with a shell script that is saving the parameters of the exec command.
Of course as a work-around I could pack everything into a bash script and just call the script from with my exe node, but this would take some flexibility in sending different commands, that I would like to create later for more advanced use-cases.
I am not suggestions to do that forever. I am proposing to look on the host itself (in the Shell) how the full command looks like.
Simple quote and double quotes, even worse when they are embedded like in your case can give « interesting » results.
I thought that some of the "special" characters might be being mangled , deleted or misinterpreted by the shell. In fact I think your single quotes protect them all from the shell apart from the = in --token=blah
What happens if you put the single quotes around everything after smartthings?
And does this work?
Just to clarify: when you say it works in the terminal, do you mean that typing that exact command at the dollar prompt works, or is smartthings interactive and you type in response to it's prompt?
Just to clarify: when you say it works in the terminal, do you mean that typing that exact command at the dollar prompt works, or is smartthings interactive and you type in response to it's prompt?
I am putting in the command and it will be executed - see screenshot:
The Command executed successfully is the reply from the remote API
I also tried setting the single quotes after devices:command and also around each command. But then I had the same issue as in the beginning -> running into a time-out after 120 seconds
I did put the command /usr/sbin/sound_off.sh into my exec-node and interestingly getting this result after waiting 120 seconds (the timeout that I did set):
First a succes message and then a time-out error: {"_msgid":"442ed2ec574d589e","topic":"","payload":"Command executed successfully\n","rc":{"code":null,"message":"Command failed: /usr/sbin/sound_off.sh\n","signal":"SIGTERM"}}
Same result in "exec" and "spawn" mode (in spawn mode the above message will be split into two messages)