-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
36 lines (34 loc) · 1.39 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
const formatNumber = (num) => {
return num.toFixed(0).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");
}
const loadMonitoringData = () => {
const $monitoringdata = $('#monitoring-data');
const apiKey = ''; // Insert API key here
const requestURL = 'https://api.enphaseenergy.com/api/v2/systems/27727/summary?callback=?';
let performancedata = 'Loading ...';
$.getJSON(requestURL, {
'key':apiKey,
}, (data) => {
console.log(`Enphase data: ${data}`);
performancedata = "<b>Current Power:</b> " +
formatNumber(data.current_power) + " W <br/>";
performancedata += "<b>Produced Today:</b> " +
formatNumber(data.energy_today/1000) + " kWh <br/>";
performancedata += "<b>Lifetime Production:</b> " +
formatNumber(data.energy_lifetime/1000000) + " MWh <br/>";
performancedata += "<a href='http://enphase.com' target='_blank'>Powered by Enphase Energy</a>";
performancedata += "<b>Status:</b> " + data.status + " <br/>";
$monitoringdata.html(performancedata);
});
}
window.onload = loadMonitoringData;
</script>
</head>
<body>
<div id="monitoring-data"></div>
</body>
</html>