smartthings-cli
-
This works in Windows, Mac, Linux, Raspberry Pi. You can list and control your SmartThings devices with the Samsung SmartThings cli (command line interface) tool.
https://github.com/SmartThingsCommunity/smartthings-cli#smartthings-devicescommands-id-command
smartthings.exe devices ────────────────────────────────────────────────────────────────────────────────────────────────────────────── # Label Name Type Device Id ────────────────────────────────────────────────────────────────────────────────────────────────────────────── 1 Front Door base-contact ZWAVE 5bebe423-f899-486e-9f62-8c63707a9b6c 2 Front Lights switch1 DTH fb132245-8bd0-478d-be4b-ca311ae64656 3 Home Hub SmartThings v2 Hub HUB 9079eb4d-10b4-435d-9a05-b2b9629cb50a 4 Motion Sensor Motion Sensor DTH b8a3a1ab-daac-44fb-a6c9-53bac4382df9 5 Notepad Notepad DTH a83bbda3-d461-44ae-948a-7d8fd13b5799 6 Samsung 7 Series (40) [TV] Samsung 7 Series (40) OCF 01253b2b-71ed-4b74-b7dd-74dd94522d96 7 THERMOSTAT Honeywell TCC 6000 Thermostat VIPER 86b567ac-0da3-4257-9b03-47a3cfc3b469 8 Kitchen Switch Z-Wave Switch DTH e2237460-e3fa-4bf5-8a24-3e6d64f89352
To turn on my Kitchen z-wave switch, I can run a command like this:
smartthings.exe devices:commands e2237460-e3fa-4bf5-8a24-3e6d64f89352 switch:on
SmartThings devices can be controlled with the SmartThings app of course, but this might be useful in scripts - whether you run them remotely via TRIGGERcmd or not.
-
This is a very powerful tool. Just started making my own automations with it in a Linux environment (Raspberry Pi).
I am putting my commands in bash scripts and bashing them in with other tools.
However some commands, like
./smarthings devices
will only run manually from the command line and will not work with sudo. In case I run it as root with sudo I get a "logging in..." message and it's just stuck there before i hit cntr-c. Also user level cron will not run this command.
While
sudo ./smartthings --version
executes with no problem and can be executed in crontab also.
I think it is a problem with permissions, but i cannot figure it out.
Any help would be much appreciated! -
@Toivo-Sokka, I wonder if it's the path to the smart things cli is wrong in those contexts because you're using ./
Please try using the full path to the executable in your commands like this:
/usr/local/bin/smartthings --version
-
@Russ The problem was not the paths. It turned out that smartthings-cli wanted a fresh login by root.
I tried logging in to GUI with root, but was unable to initiate the login prcess that way.
But typing--token <uuid>
after each command did the trick!
(<uuid> being the token from https://account.smartthings.com/tokens)Cron and other services that start at boot are still unable to run the commands.
Now I get "Error: did not get any data from stdin".I bypassed the problem by running a python script manually. This script stays open and executes the smartthings commands as needed. The downside is that if the power goes out and RasPi reboots the script does not run automatically.