|
1 | | -///////// <version>1.0.2</version> |
| 1 | +///////// <version>1.0.3</version> |
2 | 2 | ///////// APS1 ///////////// |
3 | 3 | ///////// Plugin to extract APS data for Toon /////////////// |
4 | 4 | ///////// By Oepi-Loepi /////////////// |
|
7 | 7 | if (debugOutput) console.log("*********SolarPanel Start getAPSData") |
8 | 8 | userName = encodeURI(userName) |
9 | 9 | passWord = encodeURI(passWord) |
10 | | - var url = "https://apsystemsema.com:443/ema/loginEMA.action?username=" + userName + "&password=" + passWord |
11 | | - userName = encodeURI(userName) |
12 | | - var http = new XMLHttpRequest() |
13 | | - |
| 10 | + var url = "https://apsystemsema.com:443/ema/loginEMA.action?username=" + userName + "&password="+ passWord |
| 11 | + var http = new XMLHttpRequest() |
14 | 12 | http.open("POST", url, true); |
15 | 13 | http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); |
16 | 14 | http.onreadystatechange = function() { |
17 | 15 | if (http.readyState === 4) { |
18 | 16 | if (http.status === 200) { |
19 | | - getAPSData2() |
| 17 | + if (debugOutput) console.log(http.responseText) |
| 18 | + getAPSData3() |
20 | 19 | } else { |
21 | 20 | parseReturnData(currentPower,totalValue,0,0,0,0,0, http.status,"error") |
22 | 21 | } |
|
26 | 25 | } |
27 | 26 |
|
28 | 27 |
|
29 | | - function getAPSData2(){ |
| 28 | + function getAPSData3(){ |
30 | 29 | if (debugOutput) console.log("*********SolarPanel Start getAPSData2") |
31 | 30 | var http = new XMLHttpRequest() |
32 | 31 | var url = "https://apsystemsema.com/ema/ajax/getDashboardApiAjax/getDashboardProductionInfoAjax" |
|
35 | 34 | http.onreadystatechange = function() { // Call a function when the state changes. |
36 | 35 | if (http.readyState === 4) { |
37 | 36 | if (http.status === 200) { |
| 37 | + if (debugOutput)console.log(http.responseText) |
38 | 38 | var JsonObject= JSON.parse(http.responseText) |
39 | 39 | currentPower = parseInt(JsonObject.lastPower.replace(".", "")/1000000) |
40 | 40 | var today2 = parseInt(JsonObject.today.replace(".", "")/1000) |
41 | 41 | totalValue = parseInt(JsonObject.lifetime.replace(".", "")/1000) |
42 | | - console.log("currentPower: " + currentPower) |
43 | | - console.log("today2: " +today2) |
44 | | - console.log("totalValue: " +totalValue) |
| 42 | + if (debugOutput)console.log("currentPower: " + currentPower) |
| 43 | + if (debugOutput)console.log("today2: " +today2) |
| 44 | + if (debugOutput)console.log("totalValue: " +totalValue) |
45 | 45 | parseReturnData(currentPower,totalValue,today2,0,0,0,0,http.status,"succes") |
46 | 46 | } else { |
47 | 47 | if (debugOutput) console.log("*********SolarPanel error: " + http.status) |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | http.send(); |
53 | | - } |
| 53 | + } |
0 commit comments