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