Thursday, February 6, 2014

@SmartThings and #Arduino: Color the Weather

photoI’ve been tinkering with SmartThings quite a bit lately and am loving it.  We’ve added several switches, a smoke detector, and gotten used to the interface a bit more.  For the most part, things have “just worked”.  Lights turn on on schedule, and off when people leave.  That’s cool and all, but one project I’m particularly excited about is the idea of an ambient colored light around chest-of-drawers, closet, coat-racks and the like to indicate the weather.  The idea is that without looking it up, I know if I need to carry an umbrella or jacket right in the place I’m making the decision.

To pull it together, you obviously need a SmartThings hub and some color-changing device that works with it.  I haven’t tested with Phillips Hue, but in theory these should work and certainly be easier than what I describe below. In fact, I suspect you could do similar with some IFTTT recipes and not need SmartThings, but where’s the fun in that?  Instead, I used an Arduino and SmartThings Shield.  A little SmartThings DeviceType and SmartApp code glue it all together.  It’s a little convoluted, but here’s a step by step on getting it running:

  • Put the SmartThings Shield on the Arduino.
  • Clone this project from and push it down to your Arduino
  • Copy SmartThingsShieldDeviceType.groovy from this gist to a new Device Type in your SmartThings environment.
  • Power up your Arduino in a convenient place and let it pair with the SmartHub. 
  • Go to My Devices –> SmartShield –> Edit and change the device type to the one you created above.
  • Copy ColorTheWeather.groovy from the same gist to a new SmartApp in your SmartThings environment.
  • Publish the app
  • On your mobile phone, add the app you just published and configure it.

Whenever you switch on the light, or at the schedule you provide, it will look up the weather and color the light accordingly.  It will also output the weather forecast to the “Hello Home” page in your mobile app (the little notification button on the top-right).

It’s still an experiment and obviously not for the faint-hearted, but I’ve cobbled together enough of a system to share.  One interesting aside related to this project is that it was built entirely using web-based development environments.  The SmartThings app was built using their web-based IDE. The Arduino bit I did using a web based IDE for programming Arduino.   I’ll let that soak in:  I wrote a custom home automation app, including a hardware update, using nothing but my web browser.  No funky downloads or library headaches or path variables.  I do most of my “day job” development in virtual machines these days, but am keeping a close eye on web-based tools like “Visual Studio Online” and similar.  The prospect of never having to install a bunch of “goo” just to write code is pretty inviting to somebody who used to spend days setting up machines for development.

No comments: