That may well be the best plan.
I'll try that.
Also just realized there is a node-red smarthings contrib
https://flows.nodered.org/node/node-red-contrib-smartthings
Let's see how these are going...
Looking at the issues page for that node there are numerous unadressed issues, so it may be that the node is not longer supported.
So this is what happens:
{"_msgid":"49ab6b798649273d","topic":"","payload":"Command executed successfully\n","rc":{"code":1,"message":"Command failed: /usr/sbin/sound_off.sh\n/usr/sbin/sound_off.sh: line 2: kill: (2008) - No such process\n"}}
{"_msgid":"49ab6b798649273d","topic":"","payload":"/usr/sbin/sound_off.sh: line 2: kill: (2008) - No such process\n","rc":{"code":1,"message":"Command failed: /usr/sbin/sound_off.sh\n/usr/sbin/sound_off.sh: line 2: kill: (2008) - No such process\n"}}
{"_msgid":"49ab6b798649273d","topic":"","payload":{"code":1,"message":"Command failed: /usr/sbin/sound_off.sh\n/usr/sbin/sound_off.sh: line 2: kill: (2008) - No such process\n"}}
When I do run it in the linux terminal:
$ /usr/sbin/sound_off.sh
Command executed successfully
/usr/sbin/sound_off.sh: line 2: kill: (1995) - No such process
First of all thank you very much for the support ypou did provide to me!
So, here is my solution to the issue: I decided to use the http-request node and send the commands directly to the cloud API, instead of using exec-node to call the local smartthings script.
However, the local smartthings script turned out to be very useful in this approach, because you can call it in debug mode and you see all the RestAPI calls. In this way, I can get all my settings to the Samsung devices running manually in the smartthings scripts and copy everything into the http-request node.
To call the smartthings script in debug mode I use:
SMARTTHINGS_DEBUG=true /usr/bin/smartthings devices:commands <deviceID> --token=<authToken> 'main:execute:execute("/mode/vs/0",{"x.com.samsung.da.options":["Sound_Off"]})'
In reply I get this information:
{"url":"https://api.smartthings.com/devices/__deviceID__/commands","method":"post","headers":{"Content-Type":"application/json;charset=utf-8","Accept":"application/json","User-Agent":"@smartthings/cli/1.10.2 linux-x64 node-v18.20.4","Accept-Language":"de-DE","Authorization":"Bearer __authTOKEN__"},"data":{"commands":[{"component":"main","capability":"execute","command":"execute","arguments":["/mode/vs/0",{"x.com.samsung.da.options":["Sound_Off"]}]}]}}
And here is my flow, that I used to turn sound on and off:
[
{
"id": "12d3080a2a78e624",
"type": "inject",
"z": "ba4e13d6eb48084d",
"name": "Sound OFF",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{\"commands\":[{\"component\":\"main\",\"capability\":\"execute\",\"command\":\"execute\",\"arguments\":[\"/mode/vs/0\",{\"x.com.samsung.da.options\":[\"Sound_Off\"]}]}]}",
"payloadType": "json",
"x": 130,
"y": 940,
"wires": [
[
"21a430afc34454d6"
]
]
},
{
"id": "21a430afc34454d6",
"type": "http request",
"z": "ba4e13d6eb48084d",
"name": "",
"method": "POST",
"ret": "txt",
"paytoqs": "ignore",
"url": "https://api.smartthings.com/devices/__deviceID__/commands",
"tls": "4b9925bda87b4f12",
"persist": false,
"proxy": "",
"insecureHTTPParser": true,
"authType": "",
"senderr": true,
"headers": [
{
"keyType": "Content-Type",
"keyValue": "",
"valueType": "other",
"valueValue": "application/json;charset=utf-8"
},
{
"keyType": "Accept",
"keyValue": "",
"valueType": "other",
"valueValue": "application/json"
},
{
"keyType": "Accept-Language",
"keyValue": "",
"valueType": "other",
"valueValue": "de-DE"
},
{
"keyType": "Authorization",
"keyValue": "",
"valueType": "other",
"valueValue": "Bearer __authToken__"
}
],
"x": 410,
"y": 940,
"wires": [
[
"560664932e24f093"
]
]
},
{
"id": "560664932e24f093",
"type": "debug",
"z": "ba4e13d6eb48084d",
"name": "http reply",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 640,
"y": 940,
"wires": []
},
{
"id": "dc485cbc3331e2fd",
"type": "inject",
"z": "ba4e13d6eb48084d",
"name": "Sound ON",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{\"commands\":[{\"component\":\"main\",\"capability\":\"execute\",\"command\":\"execute\",\"arguments\":[\"/mode/vs/0\",{\"x.com.samsung.da.options\":[\"Sound_On\"]}]}]}",
"payloadType": "json",
"x": 120,
"y": 1000,
"wires": [
[
"21a430afc34454d6"
]
]
},
{
"id": "4b9925bda87b4f12",
"type": "tls-config",
"name": "",
"cert": "",
"key": "",
"ca": "",
"certname": "",
"keyname": "",
"caname": "",
"servername": "",
"verifyservercert": true,
"alpnprotocol": ""
}
]
I've been very successful with the node-red-contrib-smartthings node and have several home automations that are controlled through node-red-contrib-smartthings nodes.