Command line interface to query and control SmartThings devices
-
Log into https://graph.api.smartthings.com/ and under My SmartApps, create a new SmartApp with the code in groovy/app.groovy.
-
Click App Settings and under OAuth, click Enable OAuth in Smart App. Note down the OAuth Client ID and OAuth Client Secret. Update the OAuth Client Display to SmartThings CLI Control. Click Update.
-
Go back to My SmartApps then click on SmartThings CLI Control. Click Publish => For Me.
-
Clone the smartthings_cli repository, create a virtualenv if desired, then run the following commands, replacing CLIENTID and CLIENTSECRET with the ID and secret from step 2.
python setup.py install smartthings_cli --clientid CLIENTID --clientsecret CLIENTSECRET
-
smartthings_cli will direct you to a URL to authorized access. Go to that URL in a browser and specify which devices the CLI should be able to access. Click Authorize when finished. You should be redirected to a page reporting smartthings_cli.py received auth code.
-
You can now use smartthings_cli.py to query and control devices managed by SmartThings. Examples:
-
smartthings_cli query switch all
-
smartthings_cli query switch "Switch Name"
-
smartthings_cli set switch "Switch Name" on