/smartthings_cli

Command line interface to query and control SmartThings devices

Primary LanguagePythonApache License 2.0Apache-2.0

smartthings_cli

Command line interface to query and control SmartThings devices

Usage

  1. Log into https://graph.api.smartthings.com/ and under My SmartApps, create a new SmartApp with the code in groovy/app.groovy.

  2. 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.

  3. Go back to My SmartApps then click on SmartThings CLI Control. Click Publish => For Me.

  4. 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
    
  5. 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.

  6. 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