clean
This commit is contained in:
18
src/main.cpp
18
src/main.cpp
@@ -1,7 +1,10 @@
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266HTTPClient.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
#include <settings.h>
|
||||
//#include <settings.h>
|
||||
#include <settings-my-ignore.h>
|
||||
|
||||
|
||||
|
||||
#define BUTTON_PIN D3 // GPIO-Pin verbunden mit Taster (D3 entspricht GPIO0)
|
||||
|
||||
@@ -104,6 +107,10 @@ void extractTasmotaValues(const String& url, String values[5]) {
|
||||
WiFiClient client;
|
||||
HTTPClient http;
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
values[i] = "?"; // Standardwert, falls Tasmota Gerät nicht antwortet
|
||||
}
|
||||
|
||||
if (http.begin(client, url)) {
|
||||
int httpResponseCode = http.GET();
|
||||
|
||||
@@ -116,7 +123,7 @@ void extractTasmotaValues(const String& url, String values[5]) {
|
||||
|
||||
// Werte initialisieren
|
||||
for (int i = 0; i < 5; i++) {
|
||||
values[i] = ""; // Standardwert, falls Key nicht gefunden wird
|
||||
values[i] = "?"; // Standardwert, falls Key nicht gefunden wird
|
||||
int keyIndex = response.indexOf("\"" + keys[i] + "\":");
|
||||
if (keyIndex != -1) {
|
||||
int valueStart = keyIndex + keys[i].length() + 3; // Position nach dem ":"
|
||||
@@ -132,6 +139,7 @@ void extractTasmotaValues(const String& url, String values[5]) {
|
||||
}
|
||||
} else {
|
||||
Serial.println("HTTP Fehler: " + String(httpResponseCode));
|
||||
|
||||
}
|
||||
http.end();
|
||||
} else {
|
||||
@@ -280,8 +288,6 @@ void loop() {
|
||||
|
||||
handleButtonPress();
|
||||
|
||||
//Serial.print(".");
|
||||
|
||||
if (WiFi.status() != WL_CONNECTED && !reconnecting) {
|
||||
reconnecting = true;
|
||||
connectToWiFi();
|
||||
@@ -292,11 +298,9 @@ void loop() {
|
||||
if (millis() - lastUpdateTime >= refreshRate) {
|
||||
lastUpdateTime = millis();
|
||||
|
||||
|
||||
extractTasmotaValues("http://" + ip_netzbezug + "/cm?cmnd=Status%208", ip_netzbezug_values);
|
||||
|
||||
switch (currentMode) {
|
||||
case 0:
|
||||
if (currentMode == 0) {
|
||||
extractTasmotaValues("http://" + ip_erzeugung + "/cm?cmnd=Status%208", ip_erzeugung_values);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user