RSS
Search

Collecting SmartThings data in InfluxDB on Raspberry Pi

How to collect data from your Home Automation system into a local timeseries database.

Now that you've got your Pi set up with Influx & Grafana, you're collecting some system stats, and measuring network performance, it's time to collect data from SmartThings!

Samsung SmartThings is a multi-protocol smart home hub produced by Samsung, it supports Z-Wave, Zigbee and Bluetooth and is surprisingly configurable. One of my main frustrations with the service is the lack of visibility into the huge amounts of data that it collects, so I decided to store that data myself! This way I can query it and visualise it in Grafana, set alerts and get insight into how my home is performing.

Step 0: Set up InfluxDB and Grafana

This post assumes that you have an InfluxDB and Grafana server running already, take a look at my post on getting a Raspberry Pi configured if you need to get set up first.

Step 1: Adding the SmartApp

We need to install a SmartApp to SmartThings to collect the sensor data. This is a relatively straighforward process but is daunting the first time you do it.

  1. Log in to the IDE
  2. Navigate to the My SmartApps section
  3. Click the blue + New SmartApp button in the top right of the screen
  4. Select the From Code tab
  5. Copy and Paste the groovy code from influxdb-logger
  6. Hit Create - you should see a green "Created SmartApp" banner
  7. Click the Publish -> For Me button to make the app available

Step 2: Configure the Logger

Now the SmartApp is enabled, you should see it in your SmartThings mobile application under SmartApps:

New InfluxDB Logger SmartApp.
New InfluxDB Logger SmartApp.

Click on the app to open the settings:

Configuring InfluxDB Settings.
Configuring InfluxDB Settings.

Select all devices which you would like to log:

Selecting Devices to Log.
Selecting Devices to Log.

Save the settings and make sure that the app is enabled, you'll see data in your InfluxDB immediately if everything is working correctly. You can debug by viewing the live logs of your SmartThings location - click on Live Logging in the menu of the SmartThings IDE:

Viewing Live Logs in SmartThings.
Viewing Live Logs in SmartThings.

With any luck you'll have an InfluxDB filling up with device data!