Ladestation auf neue API umgebaut
This commit is contained in:
@@ -32,6 +32,7 @@ public function Create() {
|
|||||||
$this->RegisterVariableBoolean("Solarladen", "Solarladen", "~Switch", 11);
|
$this->RegisterVariableBoolean("Solarladen", "Solarladen", "~Switch", 11);
|
||||||
$this->RegisterVariableInteger("Fahrzeugstatus", "Fahrzeugstatus", "", 0);
|
$this->RegisterVariableInteger("Fahrzeugstatus", "Fahrzeugstatus", "", 0);
|
||||||
$this->RegisterVariableInteger("Lademodus", "Lademodus", "", 0);
|
$this->RegisterVariableInteger("Lademodus", "Lademodus", "", 0);
|
||||||
|
$this->RegisterVariableFloat("Ladeleistung_Effektiv", "Ladeleistung_Effektiv", "", 0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -158,7 +159,7 @@ public function GetCurrentData(bool $Peak) {
|
|||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
|
|
||||||
// Setze die URL
|
// Setze die URL
|
||||||
curl_setopt($ch, CURLOPT_URL, "http://" . $this->ReadPropertyString("IP_Adresse") . "/mqtt?payload=");
|
curl_setopt($ch, CURLOPT_URL, "http://" . $this->ReadPropertyString("IP_Adresse") . "/api/status");
|
||||||
|
|
||||||
// Setze die Option, die Antwort als String zurückzugeben
|
// Setze die Option, die Antwort als String zurückzugeben
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
@@ -177,6 +178,10 @@ public function GetCurrentData(bool $Peak) {
|
|||||||
// Ü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
|
||||||
|
|
||||||
|
|
||||||
|
SetValue($this->GetIDForIdent("Ladeleistung_Effektiv"), $data['tpa']);
|
||||||
|
|
||||||
SetValue($this->GetIDForIdent("Fahrzeugstatus"), $data['car']);
|
SetValue($this->GetIDForIdent("Fahrzeugstatus"), $data['car']);
|
||||||
|
|
||||||
|
|
||||||
@@ -229,7 +234,7 @@ public function GetCurrentData(bool $Peak) {
|
|||||||
|
|
||||||
public function sendPowerToStation($value) {
|
public function sendPowerToStation($value) {
|
||||||
// Base URL
|
// Base URL
|
||||||
$baseUrl = "http://" . $this->ReadPropertyString("IP_Adresse") . "/mqtt?payload=";
|
$baseUrl = "http://" . $this->ReadPropertyString("IP_Adresse") . "/api/set?";
|
||||||
IPS_LogMessage("Ladestation", "Aufgerufene ip" . $baseUrl);
|
IPS_LogMessage("Ladestation", "Aufgerufene ip" . $baseUrl);
|
||||||
$value = $this->convertPowerToCurrent($value, GetValue($this->GetIDForIdent("Lademodus")));
|
$value = $this->convertPowerToCurrent($value, GetValue($this->GetIDForIdent("Lademodus")));
|
||||||
// Initialize a cURL session
|
// Initialize a cURL session
|
||||||
@@ -237,7 +242,7 @@ public function sendPowerToStation($value) {
|
|||||||
|
|
||||||
// If value is 0, make a single request
|
// If value is 0, make a single request
|
||||||
if ($value == 0) {
|
if ($value == 0) {
|
||||||
$url = $baseUrl . "alw=0";
|
$url = $baseUrl . "frc=1";
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
$response = curl_exec($ch);
|
$response = curl_exec($ch);
|
||||||
@@ -248,7 +253,7 @@ public function sendPowerToStation($value) {
|
|||||||
// For value between 1 and 32, make two requests
|
// For value between 1 and 32, make two requests
|
||||||
else if ($value >= 1 && $value <= 32) {
|
else if ($value >= 1 && $value <= 32) {
|
||||||
// First request
|
// First request
|
||||||
$url1 = $baseUrl . "alw=1";
|
$url1 = $baseUrl . "frc=2";
|
||||||
curl_setopt($ch, CURLOPT_URL, $url1);
|
curl_setopt($ch, CURLOPT_URL, $url1);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
$response1 = curl_exec($ch);
|
$response1 = curl_exec($ch);
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
"compatibility": {
|
"compatibility": {
|
||||||
"version": "7.1"
|
"version": "7.1"
|
||||||
},
|
},
|
||||||
"version": "0.19",
|
"version": "0.20",
|
||||||
"build": 0,
|
"build": 0,
|
||||||
"date": 0
|
"date": 0
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user