-
Notifications
You must be signed in to change notification settings - Fork 5
/
FP4ALL.plugin.txt
41 lines (37 loc) · 1.65 KB
/
FP4ALL.plugin.txt
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
37
38
39
40
41
///////// <version>1.0.2</version>
///////// FP4ALL /////////////
///////// Plugin to extract FP4ALL Solar data for Toon ///////////////
///////// By Oepi-Loepi ///////////////
function getSolarData(passWord,userName,apiKey,siteid,urlString,totalValue){
if (debugOutput) console.log("*********SolarPanel Start getFP4ALLData")
var http = new XMLHttpRequest();
http.open("GET", "http://" + urlString + "/status.xml", true)
http.onreadystatechange = function() {
if (http.readyState == XMLHttpRequest.DONE) {
if (http.status === 200 || http.status === 300 || http.status === 302) {
try {
var response = http.responseText
var n201 = response.indexOf("<gauge_power>") + "<gauge_power>".length
var n202 = response.indexOf("<", n201)
currentPower = response.substring(n201, n202);
var today2
var n205 = response.indexOf("<energy_today>") + "<energy_today>".length
var n206 = response.indexOf("<", n205)
today2 = response.substring(n205, n206);
var n208 = response.indexOf("<energy_total>") + "<energy_total>".length
var n209 = response.indexOf("<", n208)
totalValue = response.substring(n208, n209);
parseReturnData(currentPower,totalValue,today2,0,0,0,0,http.status,"succes")
}
catch (e){
currentPower = 0
parseReturnData(0,totalValue,todayValue,0,0,0,0, http.status,"error")
}
} else {
if (debugOutput) console.log("*********SolarPanel error: " + http.status)
parseReturnData(0,totalValue,0,0,0,0,0, http.status,"error")
}
}
}
http.send();
}