diff --git a/Ladestation_Universal/form.json b/Ladestation_Universal/form.json index 17c6a93..364d862 100644 --- a/Ladestation_Universal/form.json +++ b/Ladestation_Universal/form.json @@ -3,7 +3,7 @@ { "type": "ValidationTextBox", "name": "IP_Adresse", - "caption": "IP-Adresse Go-E", + "caption": "IP-Adresse Ladestation", "suffix": "" }, { diff --git a/Ladestation_Universal/module.php b/Ladestation_Universal/module.php index 2e56761..46b6b9b 100644 --- a/Ladestation_Universal/module.php +++ b/Ladestation_Universal/module.php @@ -63,6 +63,8 @@ class Ladestation_Universal extends IPSModule } } + + public function SetAktuelle_Leistung(int $power) { $internalPower = GetValue($this->GetIDForIdent("Aktuelle_Leistung")); @@ -156,11 +158,20 @@ class Ladestation_Universal extends IPSModule $ch = curl_init(); // Setze die URL - curl_setopt( + if(ReadPropertyInteger("Ladestation")==2){ + curl_setopt( $ch, CURLOPT_URL, "http://" . $this->ReadPropertyString("IP_Adresse") . "/api/status" - ); + ); + }elseif(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); @@ -235,9 +246,14 @@ class Ladestation_Universal extends IPSModule public function sendPowerToStation($value) { + + if(ReadPropertyInteger("Ladestation")==2){ + $baseUrl ="http://" . $this->ReadPropertyString("IP_Adresse") . "/api/set?"; + }elseif(ReadPropertyInteger("Ladestation")==1){ + $baseUrl ="http://" . $this->ReadPropertyString("IP_Adresse") . "/mqtt?payload="; + } // Base URL - $baseUrl = - "http://" . $this->ReadPropertyString("IP_Adresse") . "/api/set?"; + IPS_LogMessage("Ladestation", "Aufgerufene ip" . $baseUrl); $value = $this->convertPowerToCurrent( $value, @@ -248,7 +264,12 @@ class Ladestation_Universal extends IPSModule // If value is 0, make a single request if ($value == 0) { - $url = $baseUrl . "frc=1"; + if(ReadPropertyInteger("Ladestation")==2){ + $url = $baseUrl . "frc=1"; + }elseif(ReadPropertyInteger("Ladestation")==1){ + $url = $baseUrl . "alw=0"; + + } curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); @@ -259,7 +280,13 @@ class Ladestation_Universal extends IPSModule // For value between 1 and 32, make two requests elseif ($value >= 1 && $value <= 32) { // First request - $url1 = $baseUrl . "frc=2"; + if ($value == 0) { + if(ReadPropertyInteger("Ladestation")==2){ + $url = $baseUrl . "frc=2"; + }elseif(ReadPropertyInteger("Ladestation")==1){ + $url = $baseUrl . "alw=1"; + + } curl_setopt($ch, CURLOPT_URL, $url1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response1 = curl_exec($ch); @@ -271,7 +298,14 @@ class Ladestation_Universal extends IPSModule } // Second request - $url2 = $baseUrl . "amp=$value"; + + if ($value == 0) { + if(ReadPropertyInteger("Ladestation")==2){ + $url2 = $baseUrl . "amp=$value"; + }elseif(ReadPropertyInteger("Ladestation")==1){ + $url2 = $baseUrl . "amx=$value"; + + } curl_setopt($ch, CURLOPT_URL, $url2); $response2 = curl_exec($ch); diff --git a/library.json b/library.json index e470f5e..414251c 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "0.190", + "version": "0.191", "build": 0, "date": 0 } \ No newline at end of file