Temperature Sensor with Embedded Chart

Here’s a preview of what I’ve cooked up recently:

Temperature Sensor with Embedded Chart

How it works:

This is totally hub-less setup – no SmartThings hardware is involved in this project. Although the same result can achieved with SmartThings MultiSensor, for example.

There’re two pieces of software involved - first is a small node.js (JavaScript) application running on Linux box, but it can be anything - Windows, Mac or a tiny BeagleBone or Raspberry Pi, etc. Anything that can run Node. This node app pulls temperature data directly from my WiFi thermostat using REST API. and pushes it to Xively cloud (xively.org).

The second piece of software is a custom SmartThings device type that periodically pulls temperature data from Xively data stream and updates its status.

If you’re not familiar with Xively, it’s a generic cloud data service for the Internet of Things, similar to ThingSpeak. I’m not in any way affiliated with Xively, I just use it since the time they were Pachube and later - Cosm.

Why not push data directly to SmartThings using custom REST end-point? Good question. First, ST end-point authentication is too cumbersome. With Xively, I can easily generate multiple API keys with specific permissions (read-only, write-only or read-write) and distribute them to my virtual devices. Second, Xively is very stable and in I never experienced service outage or data loss. Third, having my data written to Xively data streams, I can pull it from from anywhere anytime. It would be impossible to get historical data from SmartThings. And finally, it provides charting capability, allowing me to display temperature graph in SmartThings app.

For Android users, my condolences, no charts for you. It’s not my fault though. Keep putting pressure on SmartThings to update Android app.

Pretty cool Col. Hack, but would this work for those that may be currently running the Android beta of ST?

I don’t know about beta. The regular Android app works, but it does not display chart.

Very cool, Col. Hack. I tried out the temperature logger you posted recently and got it working. Sweet. I want to modify it to push data to my cloud couchdb host cloudant.com. I have a couchapp that serves up a chart of my hot water solar heater performance. On the Weather tab of the chart I have temperature sensors reporting the temperature outside, inside and of my concrete slab (that my radiant heat tubes run in).

I’ve been using WeatherDirect TX-60 temperature sensors for about 3 years now and I’d like to replace them. For some reason recently they’ve started chewing up their batteries really fast, and I have to scrape weatherdirect’s website to get the data they send. It would be a lot cleaner to have a smartapp send the data directly to my database.

I have two questions for you. One, is it reasonable to have a smartapp wake up and poll several different sensors and send the data to server all in one go? (It might jeopardize my status as a freeloader with cloudant if I have to push each sensor with a separate REST query).

Secondly, do you know if it’s possible to read the temperature data to 0.1 degree? So far as I can see the sensors only display in whole degrees. I know these sensors aren’t accurate to that precision (my SmartSense Multi is 4º low LOL), but it makes a smoother chart if the reporting is more precise.

Thanks for posting your work.

Yes, absolutely, if your web service allows posting data to multiple channels, that’s the way to do it. Regarding sensor resolution, it is the SmartThings mobile app that rounds the temperature to the whole degree. In the SmartDevice itself it’s stored as a floating point value, so it’s only limited by the resolution of your physical sensor. You can see what your sensor is actually reporting in the event log in web IDE.

Thanks. Oh yeah, I see the decimal temp values in the activity log. Regarding reporting multiple sensors at once, I was actually asking how feasible it is to implement in the Smartapp. But now, getting off my duff and actually going to look at your code, I can see it is quite easy. Where you have

`input “temperature1”, “capability.temperatureMeasurement”, title: “Which temperature”

Just add more of these… At smartapp install time I choose the sensors.

Thanks again.

You don’t need to add a separate line, just append “, multiple : true” and it will allow you to add as many sensors as you want. But the input will become a list, so code will have to be able to iterate over the list of inputs.

Interesting. Where does one find a description of this language? http://graph.api.smartthings.com/ide/documentation has just class definitions. I’ve seen that it’s a DSL based on groovy (a language I don’t know, but I guess it’s similar to some I do know.) Where is the definition of the DSL?


Documentation is incomplete and inaccurate. Your best bet is to look at the actual working code examples. Just search for SmartThings on GitHub.

Hi Col Hack where do I download your node.js app? I can’t find the link to the download in the description above.