SmartThings Developer CLI

Developer CLI Community Documentation

Usage

  1. Download the appropriate binary from the
    releases
    tab of the github page.
  2. Install it on your path and rename it to “smartthings”. It does not need
    administrator privileges but of course will need to be executable.
  3. Run smartthings --help to make sure it’s working.
  4. Run a specific command with smartthings <command>

Input and Output Considerations

Many commands in the CLI handle complex input and/or output, mostly for use with
the SmartThings REST API. Input can always be passed as JSON or YAML and in
a couple cases a “question and answer” mode is provided. The output format
will match the input format unless otherwise specified.

Name Shortcut Description
json j Write output in JSON format.
yaml y Write output in YAML format.
indent Specify the number of spaces for YAML or JSON output
input i Specify a filename for input.
output o Specify a filename for output. The extension of this file will control its type unless overridden with --json or --yaml.

Configuration

The CLI can be configured by creating a YAML file called config.yaml in the
following location:

  • $HOME/.config/@smartthings/cli on OS/X or Linux
  • %LOCALAPPDATA%\@smartthings\cli on Windows

Authentication

The CLI supports an automatic login flow that pops up a browser window
asking you to log in and give the CLI permission to access your account.
The CLI will automatically request login as needed.

More details about configuration of the CLI can be found on the configuration documentation page.

Helpful Hints

  1. You can get more specific information about any command or sub-hierarchy
    of commands by using --help with a specific command or branch. For
    example, you can run any of the following commands for varying level of
    detail:
    • smartthings capabilities --help,
    • smartthings capabilities:presentation --help
    • smartthings capabilities:presentation:create --help
  2. The CLI accepts data in YAML or JSON format and can
    output data in either format as well as the default table format.
  3. Commands that take input accept stdin or a file specified
    by the --input (shortcut -i) flag.
  4. Commands that output data will output the data to stdout unless a file
    is specified the using --output (shortcut -o`) flag.
  5. When a command takes input and results in output, the format of the output
    will match the input format unless an output filename is specified
    using --output with a different extension.

More Info

6 Likes

@jody.albritton
I can’t make this to work.
I downloaded CLI pre4 for Mac OS and when I issue the command “st apps”, the terminal opens a new browser tab and prompt me to authorize the CLI to have access to my ST account.
After that, I authorize the action a new message tell me to close the tab, but CLI does not return anything.
Only the “One dot after another” loading but no response from webpage

If you cannot get the authorization to work you can create the config manually.

@jody.albritton

Thanks for your reply.
It works for me!!

System requirements for macOS?

Like access to your system or resource usage?

It’s a simple stand alone executable that provides a wrapper for a typescript based CLI. I don’t think we have done any exhaustive tests on memory or cpu usage at this point.

Ok… will it run satisfactorily on Snow Leopard?

Haven’t tested but it should

@jody.albritton, would the Linux version work on ARM architecture, like a RPi?

If not, would be possible to release a compiled version for ARM as well?