My Raspberry Pi Smartthings Experiment

Diagram of what talks to what: from phone to Raspberry Pi

Diagram of what talks to what: from phone to Raspberry Pi

Over the past couple of years I’ve experimented with smart devices with an eye toward learning. I’m generally curious about automating things around the house. I like to explore first hand the usability, accessibility, and what’s changing in this ecosystem of apps, hardware, and cloud services.

Recently, I wanted to build a garage door controller. The key for me is to be able to take something flexible and programmable like a Raspberry Pi and make it work with Smartthings.

Two helpful resources got me rolling. With this excellent article I got a great overview of using the Smartthings API tools. Then based on this handy example I was able to see code that performed similar tasks. I used this code as a foundation to learn and build from.

Using those resources I was able to learn enough of the Smartthings world to get a button on my phone to activate an LED controlled by GPIO on a Raspberry Pi.

Here’s a simplified overview of the process:

  1. Get your server script up and running. For example, this python script which uses Flask on a Raspberry Pi. This script is what listens to API calls from your Smartthings hub.
  2. Setup your device handler script via api.smartthings.com. This will be a script written in the groovy language. In my case: “simulated garage door controller V3”.
  3. Setup your device also via api.smartthings.com. This allows running the device handler on your hub. Some key parts of this step:
    • Choose your hub
    • Choose the device type, based on the device handler you created
    • Look for the IP address of your Raspberry Pi and the port your server will be listening on, combined that’s your host name.
    • Set the hostname setting on your device
  4. Add your device via the Smartthings app on your phone.
  5. Try it out. You should see events coming in to your event handling server.

It works, now what?

This may be a lot of effort to blink a light. But now I can see how it’s possible to make this experiment actually work as a garage door opener. More than that, I see how it’s possible to make Smartthings and Raspberry Pi work together.