smart me ladestation integriert
This commit is contained in:
@@ -62,22 +62,27 @@
|
|||||||
"name": "ID",
|
"name": "ID",
|
||||||
"caption": "ID",
|
"caption": "ID",
|
||||||
"suffix": "",
|
"suffix": "",
|
||||||
"visible": false,
|
"visible": true
|
||||||
"visibilityCondition": {
|
|
||||||
"field": "Ladestation",
|
|
||||||
"value": 3
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "ValidationTextBox",
|
"type": "ValidationTextBox",
|
||||||
"name": "Seriennummer",
|
"name": "Seriennummer",
|
||||||
"caption": "Seriennummer",
|
"caption": "Seriennummer",
|
||||||
"suffix": "",
|
"suffix": "",
|
||||||
"visible": false,
|
"visible": true
|
||||||
"visibilityCondition": {
|
|
||||||
"field": "Ladestation",
|
},
|
||||||
"value": 3
|
|
||||||
}
|
{
|
||||||
}
|
"type": "ValidationTextBox",
|
||||||
|
"name": "Username",
|
||||||
|
"caption": "Username",
|
||||||
|
"suffix": "",
|
||||||
|
"visible": true
|
||||||
|
|
||||||
|
},
|
||||||
|
{ "type": "PasswordTextBox", "name": "Password", "caption": "Passwort" }
|
||||||
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,10 @@ class Ladestation_Universal extends IPSModule
|
|||||||
$this->RegisterPropertyInteger("MaxLeistung_1ph", 7800);
|
$this->RegisterPropertyInteger("MaxLeistung_1ph", 7800);
|
||||||
$this->RegisterPropertyString("IP_Adresse", "0.0.0.0");
|
$this->RegisterPropertyString("IP_Adresse", "0.0.0.0");
|
||||||
$this->RegisterPropertyInteger("Ladestation", 2);
|
$this->RegisterPropertyInteger("Ladestation", 2);
|
||||||
|
$this->RegisterPropertyString("ID", "");
|
||||||
|
$this->RegisterPropertyString("Seriennummer", "");
|
||||||
|
$this->RegisterPropertyString("Username", "");
|
||||||
|
$this->RegisterPropertyString("Password", "");
|
||||||
|
|
||||||
|
|
||||||
// Ladestationspezifische Variabeln
|
// Ladestationspezifische Variabeln
|
||||||
@@ -171,6 +175,15 @@ class Ladestation_Universal extends IPSModule
|
|||||||
"http://" . $this->ReadPropertyString("IP_Adresse") . "/mqtt?payload="
|
"http://" . $this->ReadPropertyString("IP_Adresse") . "/mqtt?payload="
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
elseif($this->ReadPropertyInteger("Ladestation")==3){
|
||||||
|
curl_setopt(
|
||||||
|
$ch,
|
||||||
|
CURLOPT_URL,
|
||||||
|
"https://api.smart-me.com/pico/charging/". $this->ReadPropertyInteger("ID");
|
||||||
|
);
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||||
|
curl_setopt($ch, CURLOPT_USERPWD, $this->ReadPropertyInteger("Username") . ":" . $$this->ReadPropertyInteger("Password"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Setze die Option, die Antwort als String zurückzugeben
|
// Setze die Option, die Antwort als String zurückzugeben
|
||||||
@@ -187,6 +200,7 @@ class Ladestation_Universal extends IPSModule
|
|||||||
// Dekodiere die JSON-Antwort
|
// Dekodiere die JSON-Antwort
|
||||||
$data = json_decode($response, true);
|
$data = json_decode($response, true);
|
||||||
|
|
||||||
|
if($this->ReadPropertyInteger("Ladestation")==2||$this->ReadPropertyInteger("Ladestation")==1){
|
||||||
// Überprüfe, ob das JSON-Dekodieren erfolgreich war und der Schlüssel "car" existiert
|
// Überprüfe, ob das JSON-Dekodieren erfolgreich war und der Schlüssel "car" existiert
|
||||||
if (json_last_error() === JSON_ERROR_NONE && isset($data["car"])) {
|
if (json_last_error() === JSON_ERROR_NONE && isset($data["car"])) {
|
||||||
// Speichere den Wert von "car" in der Variable $status
|
// Speichere den Wert von "car" in der Variable $status
|
||||||
@@ -205,7 +219,28 @@ class Ladestation_Universal extends IPSModule
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if($this->ReadPropertyInteger("Ladestation")==3){
|
||||||
|
// Überprüfe, ob das JSON-Dekodieren erfolgreich war und der Schlüssel "car" existiert
|
||||||
|
if (json_last_error() === JSON_ERROR_NONE && isset($data["State"])) {
|
||||||
|
// Speichere den Wert von "car" in der Variable $status
|
||||||
|
|
||||||
|
SetValue(
|
||||||
|
$this->GetIDForIdent("Ladeleistung_Effektiv"),
|
||||||
|
round($data["ActiveChargingPower"]*1000)
|
||||||
|
);
|
||||||
|
|
||||||
|
SetValue($this->GetIDForIdent("Fahrzeugstatus"), $data["State"]);
|
||||||
|
|
||||||
|
if ($data["ActiveChargingPower"]/$data["MaxAllowedChargingCurrent"] > 0.4 && $data["car"] != 1) {
|
||||||
|
SetValue($this->GetIDForIdent("Lademodus"), 1);
|
||||||
|
} elseif ($data["car"] != 1) {
|
||||||
|
SetValue($this->GetIDForIdent("Lademodus"), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Peak-Wert speichern
|
// Peak-Wert speichern
|
||||||
$this->SetValue("Peak", $Peak);
|
$this->SetValue("Peak", $Peak);
|
||||||
|
|
||||||
@@ -251,7 +286,9 @@ class Ladestation_Universal extends IPSModule
|
|||||||
$baseUrl ="http://" . $this->ReadPropertyString("IP_Adresse") . "/api/set?";
|
$baseUrl ="http://" . $this->ReadPropertyString("IP_Adresse") . "/api/set?";
|
||||||
}elseif($this->ReadPropertyInteger("Ladestation")==1){
|
}elseif($this->ReadPropertyInteger("Ladestation")==1){
|
||||||
$baseUrl ="http://" . $this->ReadPropertyString("IP_Adresse") . "/mqtt?payload=";
|
$baseUrl ="http://" . $this->ReadPropertyString("IP_Adresse") . "/mqtt?payload=";
|
||||||
}
|
}elseif($this->ReadPropertyInteger("Ladestation")==3){
|
||||||
|
$baseUrl ="https://api.smart-me.com/pico/loadmanagementgroup/current/" . $this->ReadPropertyString("Seriennummer") . "?current=";
|
||||||
|
}
|
||||||
// Base URL
|
// Base URL
|
||||||
|
|
||||||
IPS_LogMessage("Ladestation", "Aufgerufene ip" . $baseUrl);
|
IPS_LogMessage("Ladestation", "Aufgerufene ip" . $baseUrl);
|
||||||
@@ -266,15 +303,33 @@ class Ladestation_Universal extends IPSModule
|
|||||||
if ($value == 0) {
|
if ($value == 0) {
|
||||||
if($this->ReadPropertyInteger("Ladestation")==2){
|
if($this->ReadPropertyInteger("Ladestation")==2){
|
||||||
$url = $baseUrl . "frc=1";
|
$url = $baseUrl . "frc=1";
|
||||||
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
$response = curl_exec($ch);
|
||||||
|
curl_close($ch);
|
||||||
|
return $response;
|
||||||
|
|
||||||
}elseif($this->ReadPropertyInteger("Ladestation")==1){
|
}elseif($this->ReadPropertyInteger("Ladestation")==1){
|
||||||
$url = $baseUrl . "alw=0";
|
$url = $baseUrl . "alw=0";
|
||||||
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
$response = curl_exec($ch);
|
||||||
|
curl_close($ch);
|
||||||
|
return $response;
|
||||||
|
|
||||||
}
|
}elseif($this->ReadPropertyInteger("Ladestation")==3){
|
||||||
|
$url = $baseUrl . "0";
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
|
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||||
|
curl_setopt($ch, CURLOPT_USERPWD, $this->ReadPropertyInteger("Username") . ":" . $$this->ReadPropertyInteger("Password"));
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
$response = curl_exec($ch);
|
$response = curl_exec($ch);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
return $response;
|
return $response;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// For value between 1 and 32, make two requests
|
// For value between 1 and 32, make two requests
|
||||||
@@ -285,7 +340,9 @@ class Ladestation_Universal extends IPSModule
|
|||||||
}elseif($this->ReadPropertyInteger("Ladestation")==1){
|
}elseif($this->ReadPropertyInteger("Ladestation")==1){
|
||||||
$url = $baseUrl . "alw=1";
|
$url = $baseUrl . "alw=1";
|
||||||
|
|
||||||
}
|
}elseif($this->ReadPropertyInteger("Ladestation")==3){
|
||||||
|
// Nichts zu tun für Smart-Me station
|
||||||
|
}
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
$response1 = curl_exec($ch);
|
$response1 = curl_exec($ch);
|
||||||
@@ -301,11 +358,43 @@ class Ladestation_Universal extends IPSModule
|
|||||||
|
|
||||||
if($this->ReadPropertyInteger("Ladestation")==2){
|
if($this->ReadPropertyInteger("Ladestation")==2){
|
||||||
$url2 = $baseUrl . "amp=$value";
|
$url2 = $baseUrl . "amp=$value";
|
||||||
|
curl_setopt($ch, CURLOPT_URL, $url2);
|
||||||
|
$response2 = curl_exec($ch);
|
||||||
|
|
||||||
|
// Check for errors
|
||||||
|
if (curl_errno($ch)) {
|
||||||
|
curl_close($ch);
|
||||||
|
return "Error:" . curl_error($ch);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close cURL session
|
||||||
|
curl_close($ch);
|
||||||
|
|
||||||
|
// Return responses
|
||||||
|
return [$response1, $response2];
|
||||||
}elseif($this->ReadPropertyInteger("Ladestation")==1){
|
}elseif($this->ReadPropertyInteger("Ladestation")==1){
|
||||||
$url2 = $baseUrl . "amp=$value";
|
$url2 = $baseUrl . "amp=$value";
|
||||||
|
curl_setopt($ch, CURLOPT_URL, $url2);
|
||||||
|
$response2 = curl_exec($ch);
|
||||||
|
|
||||||
|
// Check for errors
|
||||||
|
if (curl_errno($ch)) {
|
||||||
|
curl_close($ch);
|
||||||
|
return "Error:" . curl_error($ch);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close cURL session
|
||||||
|
curl_close($ch);
|
||||||
|
|
||||||
|
// Return responses
|
||||||
|
return [$response1, $response2];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
elseif($this->ReadPropertyInteger("Ladestation")==3){
|
||||||
|
$url2 = $baseUrl . $value*1000;
|
||||||
curl_setopt($ch, CURLOPT_URL, $url2);
|
curl_setopt($ch, CURLOPT_URL, $url2);
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||||
|
curl_setopt($ch, CURLOPT_USERPWD, $this->ReadPropertyInteger("Username") . ":" . $$this->ReadPropertyInteger("Password"));
|
||||||
$response2 = curl_exec($ch);
|
$response2 = curl_exec($ch);
|
||||||
|
|
||||||
// Check for errors
|
// Check for errors
|
||||||
@@ -319,6 +408,9 @@ class Ladestation_Universal extends IPSModule
|
|||||||
|
|
||||||
// Return responses
|
// Return responses
|
||||||
return [$response1, $response2];
|
return [$response1, $response2];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If value is out of range
|
// If value is out of range
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"compatibility": {
|
"compatibility": {
|
||||||
"version": "7.1"
|
"version": "7.1"
|
||||||
},
|
},
|
||||||
"version": "0.198",
|
"version": "0.199",
|
||||||
"build": 0,
|
"build": 0,
|
||||||
"date": 0
|
"date": 0
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user