Last active
July 30, 2018 18:01
-
-
Save marksharratt/8435524 to your computer and use it in GitHub Desktop.
Simple energyhive data grab test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p>This is a simple test to show that we can get energyhive data via imported GISTs. Pretty cool eh?</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pwer_reading { | |
font-size: 32px; | |
color: #f0f; | |
margin: 30px 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="row-fluid"> | |
<div class="span6 offset3 gridON center"> | |
<h1>This is my realtime energy usage data</h1> | |
<div id="pwer_reading"></div> | |
<div id="sensor_id"></div> | |
<div id="pwer_age"></div> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
getInstantData = function() { | |
$.ajax({ | |
url: '/proxy/getCurrentValuesSummary', | |
type: 'GET', | |
dataType: 'json', | |
data: '', | |
timeout: 9000, | |
success: function(json){ | |
if (json.error && json !== null) { | |
alert('Error!') | |
} else { | |
for (var index in json) { | |
var reading = 0; | |
var ts = 0; | |
for (var d in json[index].data[0]) { | |
reading = json[index].data[0][d]; | |
ts = d; | |
} | |
if (json[index].cid === 'PWER') { | |
if (reading !== null) { | |
$('#pwer_reading').text(reading/1000 + ' kW'); | |
$('#sensor_id').text('SensorID:' + json[index].sid); | |
$('#pwer_age').text('last reading:' + json[index].age + ' seconds ago'); | |
} | |
} | |
} | |
} | |
} | |
}); | |
}; | |
getInstantData(); | |
setInterval(getInstantData, 6000); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment