unterscheidung ladestation für go-e alt und neu

This commit is contained in:
2024-12-17 15:49:43 +01:00
parent e764d4adb6
commit 7d5c3e358a
3 changed files with 43 additions and 9 deletions

View File

@@ -3,7 +3,7 @@
{
"type": "ValidationTextBox",
"name": "IP_Adresse",
"caption": "IP-Adresse Go-E",
"caption": "IP-Adresse Ladestation",
"suffix": ""
},
{

View File

@@ -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);

View File

@@ -6,7 +6,7 @@
"compatibility": {
"version": "7.1"
},
"version": "0.190",
"version": "0.191",
"build": 0,
"date": 0
}