Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //FETCH OTA STATUS
- setInterval(function ( ) {
- var xhttp = new XMLHttpRequest();
- xhttp.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- document.getElementById("ota_status").innerHTML = xhttp.responseText;
- }
- };
- xhttp.open("GET", "/OTA_Status", true);
- xhttp.send();
- }, interval );
- //FETCH MQTT STATUS
- setInterval(function ( ) {
- var xhttp = new XMLHttpRequest();
- xhttp.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- document.getElementById("mqtt_status").innerHTML = xhttp.responseText;
- }
- };
- xhttp.open("GET", "/MQTT_Status", true);
- xhttp.send();
- }, interval );
- var interval = 1000;
- var kwh_price = 0.1587;
- document.getElementById("input_interval").placeholder = interval;
- document.getElementById("kwh_price").placeholder = kwh_price;
- //Chart Clock timezone
- Highcharts.setOptions({
- global: {
- useUTC: false
- }
- });
- //Chart Configs
- var chartT = new Highcharts.Chart({
- chart:{
- renderTo : 'chart-current'
- },
- title: {
- text: ''
- },
- series: [{
- showInLegend: false,
- data: []
- }],
- plotOptions: {
- line: { animation: true,
- dataLabels: { enabled: true }
- },
- series: { color: '#0066ff' }
- },
- xAxis: { type: 'datetime',
- dateTimeLabelFormats: { second: '%H:%M:%S' }
- },
- yAxis: {
- title: { text: 'Power (Watts)' }
- },
- credits: { enabled: false }
- });
- //Update Values
- setInterval(function ( ) {
- var xhttp = new XMLHttpRequest();
- xhttp.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- //Update Chart
- var x = (new Date()).getTime(),
- y = parseFloat(this.responseText);
- if(chartT.series[0].data.length > 40) {
- chartT.series[0].addPoint([x, y], true, true, true);
- } else {
- chartT.series[0].addPoint([x, y], true, false, true);
- }
- document.getElementById("power").innerHTML = this.responseText + "W";
- }
- };
- xhttp.open("GET", "/POWER", true);
- xhttp.send();
- }, interval );
- setInterval(function ( ) {
- var xhttp = new XMLHttpRequest();
- xhttp.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- document.getElementById("voltage").innerHTML = this.responseText + "V";
- }
- };
- xhttp.open("GET", "/VOLTAGE", true);
- xhttp.send();
- }, interval ) ;
- setInterval(function ( ) {
- var xhttp = new XMLHttpRequest();
- xhttp.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- document.getElementById("current").innerHTML = this.responseText + "A";
- }
- };
- xhttp.open("GET", "/CURRENT", true);
- xhttp.send();
- }, interval ) ;
- setInterval(function ( ) {
- var xhttp = new XMLHttpRequest();
- xhttp.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- document.getElementById("energy").innerHTML = this.responseText + "KWh";
- }
- };
- xhttp.open("GET", "/ENERGY", true);
- xhttp.send();
- }, interval ) ;
- setInterval(function ( ) {
- var xhttp = new XMLHttpRequest();
- xhttp.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- document.getElementById("frequency").innerHTML = this.responseText + "Hz";
- }
- };
- xhttp.open("GET", "/FREQUENCY", true);
- xhttp.send();
- }, interval ) ;
- setInterval(function ( ) {
- var xhttp = new XMLHttpRequest();
- xhttp.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- document.getElementById("pf").innerHTML = this.responseText;
- }
- };
- xhttp.open("GET", "/PF", true);
- xhttp.send();
- }, interval ) ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement