This repository has been archived by the owner on Mar 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCCUfunctions.ino
59 lines (54 loc) · 2.01 KB
/
CCUfunctions.ino
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
void setStateCCU(String id, String type, String value) {
if (WiFi.status() == WL_CONNECTED && String(HomeMaticConfig.ccuIP) != "" && String(HomeMaticConfig.ccuIP) != "0.0.0.0") {
myGLCD.setColor(0, 0, 255);
myGLCD.drawLine(319, 0, 319, 240);
http.setTimeout(HTTPTimeOut);
String url = "http://" + String(HomeMaticConfig.ccuIP) + ":8181/wemos.exe?ret=dom.GetObject(%22BidCos-RF." + id + ":" + type + "%22).State(" + value + ")";
Serial.println("setStateCCU URL: " + url);
http.begin(url);
int httpCode = http.GET();
Serial.println("setStateCCU with id: " + id + ", Type = " + type + " und Wert " + value + " ergab: " + String(httpCode));
if (httpCode > 0) {
String payload = http.getString();
Serial.println("setStateCCU Payload = " + payload);
}
if (httpCode != 200) {
myGLCD.setColor(255, 0, 0);
myGLCD.drawLine(319, 0, 319, 240);
}
else {
myGLCD.setColor(0, 255, 0);
myGLCD.drawLine(319, 0, 319, 240);
lastSyncMillis = millis();
}
http.end();
}
}
String getStateFromCCU(String id, String type) {
if (WiFi.status() == WL_CONNECTED && String(HomeMaticConfig.ccuIP) != "" && String(HomeMaticConfig.ccuIP) != "0.0.0.0") {
myGLCD.setColor(0, 0, 255);
myGLCD.drawLine(319, 0, 319, 240);
http.setTimeout(HTTPTimeOut);
http.begin("http://" + String(HomeMaticConfig.ccuIP) + ":8181/wemos.exe?ret=dom.GetObject(%22BidCos-RF." + id + ":" + type + "%22).State()");
int httpCode = http.GET();
String payload = "error";
if (httpCode > 0) {
payload = http.getString();
}
if (httpCode != 200) {
myGLCD.setColor(255, 0, 0);
myGLCD.drawLine(319, 0, 319, 240);
}
else {
myGLCD.setColor(0, 255, 0);
myGLCD.drawLine(319, 0, 319, 240);
}
http.end();
payload = payload.substring(payload.indexOf("<ret>"));
payload = payload.substring(5, payload.indexOf("</ret>"));
Serial.println("getStateFromCCU Payload: " + payload);
return payload;
} else {
return "error";
}
}