|
1 | | -///////// <version>1.0.12</version> |
| 1 | +///////// <version>1.0.13</version> |
2 | 2 | ///////// GROW1 ///////////// |
3 | 3 | ///////// Plugin to extract Growatt Solar data for Toon /////////////// |
4 | 4 | ///////// By Oepi-Loepi /////////////// |
|
31 | 31 | var JsonString = http.responseText |
32 | 32 | if (debugOutput) console.log("*********SolarPanel JsonString " + JsonString) |
33 | 33 | var JsonObject= JSON.parse(JsonString) |
34 | | - var plantID = parseInt(JsonObject.back.data[0].plantId) |
35 | | - if (debugOutput) console.log("plantID " + plantID) |
36 | | - getGrowattStep2(plantID); |
| 34 | + getGrowattStep2(); |
37 | 35 | } else { |
38 | 36 | if (debugOutput) console.log("*********SolarPanel getGrowattStep2 http.status " + http.status) |
39 | 37 | currentPower = 0 |
|
46 | 44 |
|
47 | 45 |
|
48 | 46 |
|
49 | | - function getGrowattStep2(plantID){ |
| 47 | + function getGrowattStep2(){ |
50 | 48 | if (debugOutput) console.log("*********SolarPanel Start getGrowattStep3") |
51 | 49 | var http = new XMLHttpRequest() |
52 | | - var params = "language=5&plantId=" + plantID |
53 | | - var url2 = "https://server-api.growatt.com/newTwoPlantAPI.do?op=getUserCenterEnertyDataByPlantid" |
54 | | - console.log("*********SolarPanel url2" + url2) |
55 | | - http.open("POST", url2, true) |
| 50 | + var params = "language=5" |
| 51 | + var url2 = "https://server-api.growatt.com/newPlantAPI.do?action=getUserCenterEnertyDataTwo" |
| 52 | + console.log("*********SolarPanel url2 " + url2) |
| 53 | + http.open("GET", url2, true) |
56 | 54 | http.setRequestHeader("Content-type", "application/x-www-form-urlencoded") |
57 | 55 | http.setRequestHeader("Content-length", params.length) |
58 | 56 | http.setRequestHeader("Connection", "keep-alive") |
|
70 | 68 | if (debugOutput) console.log("today2: " + today2) |
71 | 69 | totalValue= Math.floor((JsonObject.totalValue)*1000) |
72 | 70 | if (debugOutput) console.log("totalValue: " + totalValue) |
| 71 | + //getGrowattStep3() |
73 | 72 | parseReturnData(currentPower,totalValue,today2,0,0,0,0,http.status,"succes") |
74 | 73 | } |
75 | 74 | catch (e){ |
76 | 75 | currentPower = 0 |
77 | | - parseReturnData(0,totalValue,todayValue,0,0,0,0, http.status,"error") |
| 76 | + parseReturnData(0,totalValue,0,0,0,0,0, http.status,"error") |
78 | 77 | } |
79 | 78 | } else { |
80 | 79 | if (debugOutput) console.log("*********SolarPanel getGrowattStep3 http.status " + http.status) |
81 | 80 | parseReturnData(0,totalValue,0,0,0,0,0, http.status,"error") |
82 | 81 | } |
83 | 82 | } |
84 | 83 | } |
85 | | - http.send(params); |
86 | | - } |
| 84 | + http.send(params); |
| 85 | + } |
0 commit comments