-
Notifications
You must be signed in to change notification settings - Fork 5
/
DOMOTICZ1.plugin.txt
33 lines (32 loc) · 1.46 KB
/
DOMOTICZ1.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
///////// <version>1.0.2</version>
///////// DOMOTICZ1 /////////////
///////// Plugin to extract Domoticz Solar data for Toon ///////////////
///////// By Oepi-Loepi ///////////////
function getSolarData(passWord,userName,apiKey,siteid,urlString,totalValue){
if (debugOutput) console.log("*********SolarPanel Start getDomoticzData")
var http = new XMLHttpRequest();
http.open("GET", "http://" + urlString + "/json.htm?type=devices&rid=" + apiKey, true)
http.onreadystatechange = function() {
if (http.readyState == XMLHttpRequest.DONE) {
if (http.status === 200 || http.status === 300 || http.status === 302) {
try {
var JsonString = http.responseText
var JsonObject= JSON.parse(JsonString)
var today2
currentPower = parseInt(JsonObject.result[0].Usage)
today2=(parseFloat(JsonObject.result[0].CounterToday))*1000
totalValue= (parseFloat(JsonObject.result[0].Data))*1000
parseReturnData(currentPower,totalValue,today2,0,0,0,0,http.status,"succes")
}
catch (e){
currentPower = 0
parseReturnData(0,totalValue,0,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();
}