Skip to content

Commit

Permalink
add some units and prefixes to the JSON output
Browse files Browse the repository at this point in the history
  • Loading branch information
sirleech committed May 9, 2012
1 parent 191e727 commit 51b1fbd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion temperature.py
Expand Up @@ -24,7 +24,7 @@ def exportToJson(temperature):
import utils
import json
f = open('sensors/temperature.json','w')
reading = {'temperature': temperature, 'lastUpdated': utils.getTimeString()}
reading = {'unit':'degrees celcius','unitPrefix':'°C','value': temperature, 'lastUpdated': utils.getTimeString()}
f.write(json.dumps(reading))
f.close()

Expand Down
4 changes: 2 additions & 2 deletions web/index.html
Expand Up @@ -20,8 +20,8 @@
client.onreadystatechange = function() {
//alert(client.responseText);
var temperatureReading = eval('(' + client.responseText + ')');
document.getElementById("temp").innerHTML = Math.round(temperatureReading.temperature*10)/10 +"c";
document.getElementById("lastUpdated").innerHTML = temperatureReading.lastUpdated;
document.getElementById("temp").innerHTML = Math.round(temperatureReading.value*10)/10 + temperatureReading.unitPrefix;
document.getElementById("lastUpdated").innerHTML = temperatureReading.value;
}
client.send();
}
Expand Down

0 comments on commit 51b1fbd

Please sign in to comment.