Logging Thermostat Status to Xively

Some folks were asking for this feature, so here’s the app for you:

Please note that I don’t own an ST-compatible thermostat, so I have only tested it in a simulator. Let me know if it works or not.

Enjoy :slight_smile:


I have it working with a Nest and 2Gig CT 101 thermostat.

Excellent, this is awesome! Thank you so much for writing this up. This is working with my Filtrete 3M-50. Just thinking out loud, you could probably do the same thing for all of the SmartThings Multi’s and graph that too!

You’re welcome. Yes, it’s just a matter of adding few lines of code. There’s however a limit how often you can post to Xively feed.

I can’t seem to get any data from my Nest.

I have the TemperatureLogger working fine, so I know I have the API Key and Feed ID setup correctly.

I finally got a temp reading from my Nest thermostat, but only one and no operating state yet.

Here is the temperature readings from my Multisensor:
From ST Multisensor

Here is the reading from my Nest:
From Nest Thermostat

Yes I changed the Channel Name, I also changed the Channel name in the SmartApp:

 *  ThermostatLogger. Logs thermostat temperature and operating state to Xively feed.
 *  See http://build.smartthings.com/projects/xively/ for more information.
 *  Author: @kernelhack
 *  Date: 2014-01-21
preferences {
    section("Configure") {
        input "xi_apikey", "text", title: "Xively API Key"
        input "xi_feed", "number", title: "Xively Feed ID"
        input "thermostat1", "capability.thermostat ", title: "Select thermostat"

def installed() {
    log.debug "Installed with settings: ${settings}"

def updated() {
    log.debug "Updated with settings: ${settings}"

def initialize() {
    // Subscribe to attributes, devices, locations, etc.
    subscribe(thermostat1, "temperature", handleThermostatTemperature)
    subscribe(thermostat1, "thermostatOperatingState", handleThermostatOperatingState)

def parseHttpResponse(response) {
    log.debug "HTTP Response: ${response}"

def writeChannelData(feed, channel, value) {
    def uri = "https://api.xively.com/v2/feeds/${feed}.json"
    def json = "{\"version\":\"1.0.0\",\"datastreams\":[{\"id\":\"${channel}\",\"current_value\":\"${value}\"}]}"

    def headers = [
        "X-ApiKey" : "${xi_apikey}"

    def params = [
        uri: uri,
        headers: headers,
        body: json

    httpPutJson(params) {response -> parseHttpResponse(response)}

// Handle temperature event
def handleThermostatTemperature(evt) {
    log.debug "Tempreature event: $evt.value"
    writeChannelData(xi_feed, "TempUP", evt.value)

// Handle thermostatOperatingState event
def handleThermostatOperatingState(evt) {
    log.debug "OperatingState event: $evt.value"

    def opState = 0
    if (evt.value == "heating") {
        opState = 1
    } else if (evt.value == "cooling") {
        opState = -1

    writeChannelData(xi_feed, "OperatingStateUP", opState)

I’m using this for the Nest Device Type https://gist.github.com/Dianoga/6055918

Anyone know what it is I’m doing wrong?

Yes, this Nest thermostat app does not generate thermostatOperatingState events.

So is it that I can’t get Operating State from a Nest? Or do I need some different code in the Device Type to do it?

I have only gotten one Temp reading sent to Xively in the last 14 Hours, shouldn’t I be getting more than that?

Your best bet is to contact the author of Nest device type and ask if it’s possible to get current operating state from the Nest and if so, update the device code. With regards to temperature reading, is it being updated in your smartphone app? You can also look for clues in IDE logs (https://graph.api.smartthings.com/ide/logs)

I’m new but this objective will be one of my first. Can anyone describe in more detail the exact data being extracted, Ie. Does it include all of the following 1) device state (on/off) 2) Device Temperature assessment , and 3) device setpoint?

Does anyone know if the CT 101 sold under Iris at Lowe’s is the same thermostat?

@rjlo yes, that is the same one I have. It works with Smartthings.


Can you pull this from the archives? I’d love to do some of this stuff. I apparently missed this sometime ago and would like to incorporate it :smile:


Feel free to use my modified one:

Mine doesn’t rely on subscribe, but it could…

Just use this with pollster and refresh at your desire, I do 10 minute samples.


1 Like


I take back all the things i’ve said about you :wink:

This is amazing! So sad i am just seeing this. Totally behind the times aparrently! lol

Yeah, works with almost all data point type devices. Great to see temp, humidity and other statuses over time in Xively.

Tried to download this @kernelhack but it takes me to the home page?

Patrick, I think I’m missing something obvious. Got my Xively account set up, but I’m seeing an error response to the feed put: “Datastreams stream is invalid”.

I tried creating a channel for one of the items in the feed - do I need to create a channel in Xively for everything I want to log?


So you have a develop device in Xively set up? Got your API key? Feed URL?

The channels should be created automatically once you send data to it.