# Collecting SmartThings data in InfluxDB on Raspberry Pi

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

Author: Simon Hearne (https://simonhearne.com/about/)
Published: 2020-01-07
Canonical: https://simonhearne.com/2020/pi-smartthings-influx/
Tags: homeautomation, raspberrypi

---
Now that you've [got your Pi set up with Influx & Grafana](/2020/pi-influx-grafana/), you're [collecting some system stats](/2020/pi-speedtest-influx/), and [measuring network performance](/2020/pi-speetest-influx/), it's time to collect data from SmartThings!

[Samsung SmartThings](https://www.samsung.com/uk/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](/2020/pi-influx-grafana/) 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](https://graph.api.smartthings.com/)
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](https://raw.githubusercontent.com/codersaur/SmartThings/master/smartapps/influxdb-logger/influxdb-logger.groovy)
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.](https://simonhearne.com/images/pi-smartthings-influx/sm_2.png)

Click on the app to open the settings:

![Configuring InfluxDB Settings.](https://simonhearne.com/images/pi-smartthings-influx/sm_3.png)

Select all devices which you would like to log:

![Selecting Devices to Log.](https://simonhearne.com/images/pi-smartthings-influx/sm_4.png)

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.](https://simonhearne.com/images/pi-smartthings-influx/sm_5.png)

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

