Temperature Map in Smartthings?

Hello Everyone,

I realized I almost have a temperature sensor in every single area of my house (most of them are actually door or window sensors that double up as temperature sensors) I even have them around the house as motion/gate/temperature sensors. I was wondering if anyone has created an add on to show a heatmap of the house so I can see which parts of the house are consistently warmer/cooler and see how efficient my AC system is. Even if this is a 3rd party paid solution Im willing to pay to get this feature. Of course it will require me to upload my floor plan.

Any advise is greatly appreciated!

https://i.imgur.com/oonXRoo.gifTemp

1 Like

Be careful with ones mounted to exterior doors, windows, walls, etc. They will show a different temperature than something a foot or so away from the exterior surface.

1 Like

Did you find anything?

No unfortunately. Do you know of any open source system?

I might try using this https://www.patrick-wied.at/static/heatmapjs/
I dont have any experience in anything like it so if I get anywhere with it I will update.

Thanks. Interesting site but not sure if it allows uploading of floor plans and sensor locations and sensor data. Also the “heat map” is pretty much targeted for mouse movement to track webvisitors. But really cool find! Wish it was open source.

you are right. that wont work. the frustrating part is I have all the data from the sensors, I just need to find a way to graph it over my floor plan.

Anything new on this topic?

Hey did you ever find anything for this? I really want to do this.

I was using the Google sheets logger to log temp and humidity. And with a rough sketch of my floor plan on a sheet, using conditional formating to color the cells based on temp or humidity from low to high.
Unfortunately, since the passing of groovy, I haven’t found a replacement for the Google sheets logger.
If you find a replacement please let me know. I’d be happy to help any way I can.

Is this suitable for you?
[Post-Groovy Google Spreadsheet Integration]

@TapioX you need to follow @TAustin instructions following that link and use the script below he provided me.
Currently it only pulls data for one device. I am just learning javascript so am trying to get it to work with multiples.

//
// This app retrieves temperature & humidity values from a SmartThings
// device via the SmartThings RESTful API, and posts them to a Google spreadsheet.
//
// User must be sure the sheet being posted to has three column headings: ‘Date’,
// ‘Temperature’, and ‘Humidity’
//
// The following constants in this file must be modified by the user:
// KEYFILE, GOOGLEDOCID, GSHEET_SHEETNAME, MYTOKEN, MYDEVICEID, RUNFREQUENCY
/
/

//GOOGLESHEETS CONSTANTS
const KEYFILE = ‘./xxxxxxxxxxxxxxxxxxxxxxxx.json’
const GOOGLEDOCID = ‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’

const GSHEET_SHEETNAME = ‘TempTracker’

const { GoogleSpreadsheet } = require(‘google-spreadsheet’);
const doc = new GoogleSpreadsheet(GOOGLEDOCID);

//SMARTTHINGS CONSTANTS
const MYTOKEN = ‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’

const MYDEVICEID = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’

const TEMP = {‘component’: ‘main’, ‘capability’: ‘temperatureMeasurement’, ‘attribute’: ‘temperature’}
const HUMIDITY = {‘component’: ‘main’, ‘capability’: ‘relativeHumidityMeasurement’, ‘attribute’: ‘humidity’}

const STAPIHOST = ‘api.smartthings.com’

// How often to fetch the device values and post in spreadsheet (in seconds)
RUNFREQUENCY = 60

//HTTP CONSTANTS
const HTTP_OK = 200

//REQUIRED NODE MODULES
const https = require(‘https’)

async function update_spreadsheet(tempval, humidityval) {

let sheet = doc.sheetsByTitle[GSHEET_SHEETNAME];

let dateTime = new Date();
let dateTimestr = String(dateTime).replace(/GMT.+/, ‘’);

try {
await sheet.addRow({ Date: dateTimestr, Temp: tempval, Humidity: humidityval});

} catch (err) {
console.log (‘\tERROR: Unable to add row to sheet’);
}

}

async function initauth() {

const creds = require(KEYFILE);

await doc.useServiceAccountAuth(creds);

await doc.loadInfo();

}

function get_value(deviceinfo) {

return new Promise((resolve, reject) => {

let options = {};
options.headers = {};

options.host = STAPIHOST;
options.path = `/v1/devices/${MYDEVICEID}/components/${deviceinfo.component}/capabilities/${deviceinfo.capability}/status`;

options.method = 'GET';
options.headers.accept = 'application/json';
options.headers.authorization = 'Bearer ' + MYTOKEN;

try {
  const req = https.request(options, res => {
    let body = '';
    
    res.on('data', data => {body += data})
    
    res.on('end', () => {
      resolve({statusCode: res.statusCode, data: body});
    })
    
  })
  
  req.on('error', error => {
    reject('SmartThings API request failed: ' + error.message);
  })
  
  req.on('timeout', () => {
    console.log ('SmartThings API request timed out');
    req.destroy();
  })
  
  req.end();
  
} catch(error) {
  reject('HTTPS failed: ' + error.message);
}

})
}

async function update() {

try {
let tempresult = await get_value(TEMP);
if (!tempresult) return;
if (tempresult.statusCode != 200) return;

const temp = JSON.parse(tempresult.data);

let humidityresult = await get_value(HUMIDITY);
if (!humidityresult) return;
if (humidityresult.statusCode != 200) return;

const humidity = JSON.parse(humidityresult.data);

update_spreadsheet(temp[TEMP.attribute].value, humidity[HUMIDITY.attribute].value);

} catch(error) {

console.log ('UPDATE FAILED: ' + error);

}
}

// MAIN ----------------------------------------------------------------

console.log(‘\nGooglesheet Updater from SmartThings API v1.0\n’)
initauth()
.then(result => {

update();

setInterval(function() {
  update();
}, RUNFREQUENCY * 1000);

})
.catch(error => {
console.log (“Error:”, error);
})

1 Like

@granzy Thanks for sharing this.
Do you have any more info on how to use this? Is it in a separate thread with @TAustin?
All help is greatly appreciated.

Edit: I already use a Raspberry Pi with NodeJS with Web Requestor for logging events to a google sheet. I’m just unsure how to incorporate this script, which you provide to periodically log temperature and humidity.

Have you looked into Sharp Tools or Action Tiles? Seems like one of both would be a possibility

@tbi Follow this link to get the logging set up. @TAustin has done an amazing job.
[Post-Groovy Google Spreadsheet Integration ]
Then use the script @TAustin provided me above.
Again, I am just learning javascript so am trying to get it to work with multiple devices.

EDIT: Lets continue this conversation on the thread provided above.
You may want to check out https://www.constantgraph.com/
I am not using it as I have specific uses for my data in google sheets, but it is a nice program.

Since you are already posting events to a Google spreadsheet using web requestor, think of this alternate app as a different way to get the device values from SmartThings. This code fetches the data values via the RESTful API, so doesn’t involved any Edge drivers. It also includes the code to post the values to a Google spreadsheet, so it doesn’t require the separate nodeJS app you are already using. It’s all built in to one app just to make things easy.

If you want to try using it, you should be able to run it in parallel to your current setup - it just needs to be modified with the same info for keyfile and Google Doc ID, along with some other things. For example it requires your SmartThings Personal Access Token. You’ll also need to modify it for whatever device ID(s) you are grabbing the values from.

@TAustin and @granzy, thank you both very much for your answers. I will give it a try in the coming days and give some feedback. All the best.

Hello were you able to build anything?

Most of the information above is beyond my understanding of programming. I was looking for a ready solution but this is very interesting.