-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery_nest.js
24 lines (23 loc) · 992 Bytes
/
jquery_nest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(function($) {
$.nest = function(container) {
$.get('/python/nest.py', function(data) {
container.html('<img src="nestEmpty.png"/>').append('<div id="currentStatus"></div>').append('<div id="currentSettings"></div>').append('<div id="awayStatus"></div>');
var status = $.parseJSON(data);
if (status.away) {
$('#awayStatus').html("Away");
} else {
$('#awayStatus').html("Home");
}
var current = "" + status.current_temperature;
current = current.substring(0, current.indexOf("."));
$('#currentStatus').html(current).append("°F");
container.removeClass();
if (status.mode == "HEAT") {
container.addClass("heat");
} else {
container.addClass("cool");
}
$('#currentSettings').html(status.set_temp).append("°F");
});
}
})(jQuery);