Smartthings_exporter is a command line tool to export information about your SmartThings sensors in a format that can be scraped by Prometheus. The tool talks to the SmartThings API and collects sensor data which is exposed as metrics over http.
The installation instructions assume a properly installed and configured Go development environment. The very first step is to download and build Smartthings_exporter (this step will also download and compile the GoSmart library):
$ go get -u github.com/kadaan/smartthings_exporter
Before you can use Smartthings_exporter, you need to register it with SmartThings.
The first step is to setup the API that Smartthings_exporter uses to communicate with SmartThings. To do this you need to:
- Navigate to the SmartThings API website. Register a new account (or login if you already have an account).
- Once logged in, click on My SmartApps. This will show a list of the current SmartApps installed (it could be blank for new accounts).
- Click the
Settings
button at the top right. - Click the
Add new repository
link at the bottom of the settings dialog box. - In the new row fill in:
- Owner:
kadaan
- Name:
smartthings_exporter
- Branch:
master
- Owner:
- Press
Save
- Click
Update from Repo
at the top right - Choose
smartthings_exporter (master)
- Under the
New
list on the right checksmartapps/kadaan/smartthings-exporter-api.src/smartthings-exporter-api.groovy
- Check
Publish
at the bottom - Click
Execute Update
- Click the
Edit Properties
button for thekadaan : Smartthings Exporter API
entry - Click
OAuth
- Click
Enable OAuth in SmartApp
- In
Redirect URI
, enterhttp://localhost:4567/OAuthCallback
. Case is important here - Click
Update
- Click
OAuth
- Take note of the
Client ID
andClient Secret
. These will be used to authenticate and retrieve a token. Once the token is saved locally by the library, authentication can proceed without user intervention.
We now need to register Smartthings_exporter to with your SmartThings app.
Run:
$ smartthings_exporter register --smartthings.oauth-client=[client_id] > .st_token
Follow the prompts to authorize the app.
Now we can start Smartthings_exporter by running:
$ smartthings_exporter --smartthings.oauth-client=[client_id] --smartthings.oauth-token.file=.st_token