From 2225dc8860468bba4dbaa41613f934eda0ecc835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=A4fliger?= Date: Wed, 19 Feb 2025 15:36:34 +0100 Subject: [PATCH] =?UTF-8?q?Dummy-Ladestation=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ladestation_Universal/form.json | 4 +++ Ladestation_Universal/module.php | 52 +++++++++++++++++++++++++++++--- library.json | 2 +- 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/Ladestation_Universal/form.json b/Ladestation_Universal/form.json index 96d720b..a385b80 100644 --- a/Ladestation_Universal/form.json +++ b/Ladestation_Universal/form.json @@ -16,6 +16,10 @@ { "caption": "Smart-Me Pico", "value": 3 + }, + { + "caption": "Dummy Station (Ohne Ansteuerung)", + "value": 4 } ] }, diff --git a/Ladestation_Universal/module.php b/Ladestation_Universal/module.php index 47658bd..f01c510 100644 --- a/Ladestation_Universal/module.php +++ b/Ladestation_Universal/module.php @@ -182,12 +182,28 @@ class Ladestation_Universal extends IPSModule CURLOPT_URL, "http://" . $this->ReadPropertyString("IP_Adresse") . "/api/status" ); + // Setze die Option, die Antwort als String zurückzugeben + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + // Führe die Anfrage aus und speichere die Antwort + $response = curl_exec($ch); + + // Schließe cURL + curl_close($ch); }elseif($this->ReadPropertyInteger("Ladestation")==1){ curl_setopt( $ch, CURLOPT_URL, "http://" . $this->ReadPropertyString("IP_Adresse") . "/mqtt?payload=" ); + // Setze die Option, die Antwort als String zurückzugeben + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + // Führe die Anfrage aus und speichere die Antwort + $response = curl_exec($ch); + + // Schließe cURL + curl_close($ch); } elseif($this->ReadPropertyInteger("Ladestation")==3){ curl_setopt( @@ -197,10 +213,7 @@ class Ladestation_Universal extends IPSModule ); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERPWD, $this->ReadPropertyString("Username") . ":" . $this->ReadPropertyString("Password")); - } - - - // Setze die Option, die Antwort als String zurückzugeben + // Setze die Option, die Antwort als String zurückzugeben curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Führe die Anfrage aus und speichere die Antwort @@ -208,6 +221,15 @@ class Ladestation_Universal extends IPSModule // Schließe cURL curl_close($ch); + } + elseif($this->ReadPropertyInteger("Ladestation")==4){ + + $response = true; + + } + + + // Überprüfe, ob die Antwort nicht leer ist if ($response) { @@ -257,6 +279,20 @@ class Ladestation_Universal extends IPSModule } } } + if($this->ReadPropertyInteger("Ladestation")==4){ + // Überprüfe, ob das JSON-Dekodieren erfolgreich war und der Schlüssel "car" existiert + + SetValue( + $this->GetIDForIdent("Ladeleistung_Effektiv"), + GetValue("Ladeleistung") + ); + + + + + + } + } @@ -381,7 +417,11 @@ class Ladestation_Universal extends IPSModule }elseif($this->ReadPropertyInteger("Ladestation")==3){ // Nichts zu tun für Smart-Me station +} }elseif($this->ReadPropertyInteger("Ladestation")==4){ + // Nichts zu tun für Dummy station } + + // Second request @@ -449,7 +489,9 @@ class Ladestation_Universal extends IPSModule // Return responses return; - } + }elseif($this->ReadPropertyInteger("Ladestation")==4){ + // Nichts zu tun für Dummy station +} } diff --git a/library.json b/library.json index c0e5c4a..9626df8 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "1.040", + "version": "1.042", "build": 0, "date": 0 } \ No newline at end of file