Energiemanager optimiert, Easee-Ladestation eingefügt.
This commit is contained in:
@@ -24,6 +24,10 @@
|
||||
{
|
||||
"caption": "Easee - Nur Solarladen",
|
||||
"value": 5
|
||||
},
|
||||
{
|
||||
"caption": "Easee",
|
||||
"value": 6
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -48,35 +52,48 @@
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "Zeit_Zwischen_Zustandswechseln",
|
||||
"caption": "Mindestlaufzeit des Verbrauchers bei Lastschaltung (Für Easee Solarladen zwingend 1 Minute einstellen)",
|
||||
"caption": "Mindestlaufzeit des Verbrauchers bei Lastschaltung ",
|
||||
"suffix": ""
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "Ein_Zeit",
|
||||
"caption": "Mindestlaufzeit Ladestation wenn Ein",
|
||||
"suffix": ""
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "Aus_Zeit",
|
||||
"caption": "Mindestlaufzeit Ladestation wenn Aus",
|
||||
"suffix": ""
|
||||
},
|
||||
{
|
||||
"type": "ValidationTextBox",
|
||||
"name": "IP_Adresse",
|
||||
"caption": "IP-Adresse Ladestation"
|
||||
},
|
||||
{
|
||||
"type": "ValidationTextBox",
|
||||
"name": "Geräte-ID Smart-Me / ECarUp / Easee",
|
||||
"caption": "ID"
|
||||
|
||||
},
|
||||
{
|
||||
"type": "ValidationTextBox",
|
||||
"name": "Seriennummer Smart-Me / ECarUp / Easee",
|
||||
"caption": "Seriennummer"
|
||||
"caption": "Geräte-ID Smart-Me / ECarUp / Easee",
|
||||
"name": "ID"
|
||||
|
||||
},
|
||||
{
|
||||
"type": "ValidationTextBox",
|
||||
"name": "Username / Benutzernahme Solarladen",
|
||||
"caption": "Username"
|
||||
"caption": "Seriennummer Smart-Me / ECarUp / Easee",
|
||||
"name": "Seriennummer"
|
||||
|
||||
},
|
||||
{
|
||||
"type": "ValidationTextBox",
|
||||
"caption": "Username / Benutzernahme Solarladen",
|
||||
"name": "Username"
|
||||
|
||||
},
|
||||
{ "type": "PasswordTextBox",
|
||||
"name": "Password -> Bei Anwendung mit Pico-Stationen",
|
||||
"caption": "Passwort"
|
||||
"caption": "Password -> Bei Anwendung mit Pico-Stationen",
|
||||
"name": "Password"
|
||||
},
|
||||
{
|
||||
"type": "SelectVariable",
|
||||
|
||||
@@ -17,6 +17,8 @@ class Ladestation_v2 extends IPSModule
|
||||
$this->RegisterPropertyInteger("Interval", 5); // Recheninterval
|
||||
$this->RegisterPropertyInteger("Max_Current_abs", 32); // Recheninterval
|
||||
$this->RegisterPropertyInteger("Zeit_Zwischen_Zustandswechseln", 1);
|
||||
$this->RegisterPropertyInteger("Ein_Zeit", 0); // Recheninterval
|
||||
$this->RegisterPropertyInteger("Aus_Zeit", 0); // Recheninterval
|
||||
$this->RegisterPropertyInteger("Token_Easee", 0); // Recheninterval
|
||||
$this->RegisterPropertyInteger("Token_ECarUp", 0); // Recheninterval
|
||||
|
||||
@@ -41,8 +43,18 @@ class Ladestation_v2 extends IPSModule
|
||||
IPS_SetHidden($this->GetIDForIdent("Peak"), true);
|
||||
|
||||
$this->RegisterVariableBoolean("IsTimerActive", "IsTimerActive", "", false);
|
||||
IPS_SetHidden($this->GetIDForIdent("IsTimerActive"), true);
|
||||
|
||||
$this->RegisterTimer("ZustandswechselTimer",0,"IPS_RequestAction(" .$this->InstanceID .', "ResetTimer", "");');
|
||||
|
||||
$this->RegisterVariableBoolean("IsTimerActive_Null_Timer", "IsTimerActive_Null_Timer", "", false);
|
||||
IPS_SetHidden($this->GetIDForIdent("IsTimerActive_Null_Timer"), true);
|
||||
|
||||
$this->RegisterTimer("Null_Timer",0,"IPS_RequestAction(" .$this->InstanceID .', "ResetNullTimer", "");');
|
||||
|
||||
$this->RegisterVariableString("Letzer_User", "Letzter registrierter Benutzer");
|
||||
IPS_SetHidden($this->GetIDForIdent("Letzer_User"), true);
|
||||
|
||||
|
||||
|
||||
// Variabeln für Kommunkation mit Manager
|
||||
@@ -75,6 +87,9 @@ class Ladestation_v2 extends IPSModule
|
||||
$this->RegisterVariableInteger("Leistung_Delta", "Leistung_Delta", "", 0);
|
||||
IPS_SetHidden($this->GetIDForIdent("Leistung_Delta"), true);
|
||||
|
||||
$this->RegisterVariableString("Token_Intern", "Internes Token Easee");
|
||||
IPS_SetHidden($this->GetIDForIdent("Token_Intern"), true);
|
||||
|
||||
// Hilfsvariabeln für Idle zustand
|
||||
$this->RegisterPropertyInteger("IdleCounterMax", 2);
|
||||
$this->RegisterVariableInteger("IdleCounter", "IdleCounter", "", 0);
|
||||
@@ -85,6 +100,7 @@ class Ladestation_v2 extends IPSModule
|
||||
$this->SetValue("Idle", true);
|
||||
|
||||
$this->RegisterTimer("Timer_Do_UserCalc_EVC",$this->ReadPropertyInteger("Interval")*1000,"IPS_RequestAction(" .$this->InstanceID .', "Do_UserCalc", "");');
|
||||
$this->RegisterTimer("Timer_Refresh_Token",0,"IPS_RequestAction(" .$this->InstanceID .', "Refresh_Token", "");');
|
||||
|
||||
}
|
||||
|
||||
@@ -93,6 +109,14 @@ class Ladestation_v2 extends IPSModule
|
||||
parent::ApplyChanges();
|
||||
$this->SetTimerInterval("Timer_Do_UserCalc_EVC",$this->ReadPropertyInteger("Interval")*1000);
|
||||
|
||||
// erstelle einen Timer der das Request token aktualisiert wenn die station dies braucht.
|
||||
if($this->ReadPropertyInteger("Ladestation")==6){
|
||||
|
||||
$this->Refresh_Token();
|
||||
$this->SetTimerInterval("Timer_Refresh_Token",1800000);
|
||||
|
||||
}
|
||||
|
||||
// Zusätzliche Anpassungen nach Bedarf
|
||||
}
|
||||
|
||||
@@ -142,6 +166,14 @@ class Ladestation_v2 extends IPSModule
|
||||
|
||||
case "ResetTimer":
|
||||
$this->ResetTimer();
|
||||
break;
|
||||
|
||||
case "ResetNullTimer":
|
||||
$this->ResetNullTimer();
|
||||
break;
|
||||
|
||||
case "Refresh_Token":
|
||||
$this->Refresh_Token();
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -158,6 +190,8 @@ class Ladestation_v2 extends IPSModule
|
||||
$this->SetValue("Car_detected", true);
|
||||
if($this->GetValue("Max_Current")<6){
|
||||
$this->SetValue("Car_is_full", true);
|
||||
$this->ResetTimer();
|
||||
$this->ResetNullTimer();
|
||||
|
||||
}
|
||||
|
||||
@@ -165,7 +199,8 @@ class Ladestation_v2 extends IPSModule
|
||||
$this->SetValue("Car_detected", false);
|
||||
$this->SetValue("Leistung_Delta", 0);
|
||||
$this->SetValue("Car_is_full", false);
|
||||
$this->SetValue("IsTimerActive", false);
|
||||
$this->ResetTimer();
|
||||
$this->ResetNullTimer();
|
||||
$this->SetValue("Is_1_ph", false);
|
||||
$this->SetValue("Aktuelle_Leistung", 0);
|
||||
$this->SetValue("IdleCounter", 0);
|
||||
@@ -231,6 +266,21 @@ class Ladestation_v2 extends IPSModule
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Methode zum Setzen der PowerSteps und Timer starten
|
||||
public function SetTimerNullMindestlast($time)
|
||||
{
|
||||
if($time>0){
|
||||
$this->SetTimerInterval("Null_Timer", $time * 60000); // Timer in Millisekunden
|
||||
// Timer-Status auf true setzen
|
||||
$this->SetValue("IsTimerActive_Null_Timer", true);
|
||||
}else{
|
||||
$this->SetValue("IsTimerActive_Null_Timer", false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Methode zum Zurücksetzen von PowerSteps nach Ablauf des Timers
|
||||
public function ResetTimer()
|
||||
{
|
||||
@@ -241,6 +291,17 @@ class Ladestation_v2 extends IPSModule
|
||||
$this->SetValue("IsTimerActive", false);
|
||||
}
|
||||
|
||||
// Methode zum Zurücksetzen von PowerSteps nach Ablauf des Timers
|
||||
public function ResetNullTimer()
|
||||
{
|
||||
// Timer stoppen
|
||||
$this->SetTimerInterval("Null_Timer", 0);
|
||||
|
||||
// Timer-Status auf false setzen
|
||||
$this->SetValue("IsTimerActive_Null_Timer", false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function Get_Car_Status(int $carType)
|
||||
{
|
||||
@@ -345,31 +406,101 @@ class Ladestation_v2 extends IPSModule
|
||||
]);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
if ($response === false) {
|
||||
IPS_LogMessage("Ladestation", "Fehler beim Abrufen der eCarUp API-Daten");
|
||||
return;
|
||||
}
|
||||
|
||||
$data = json_decode($response, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
IPS_LogMessage("Ladestation", "Fehler beim Dekodieren der JSON-Antwort");
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($data['driverIdentifier']) && ($data['driverIdentifier']==$this->ReadPropertyInteger("Username"))) {
|
||||
$this->SetValue("Ladeleistung_Effektiv", $this->GetValue("Power"));
|
||||
$this->SetValue("Fahrzeugstatus", 2);
|
||||
$car_on_station = true;
|
||||
|
||||
} else {
|
||||
$car_on_station = false;
|
||||
$this->SetValue("Fahrzeugstatus", 1);
|
||||
$this->SetValue("Ladeleistung_Effektiv", 0);
|
||||
curl_close($ch);
|
||||
|
||||
if (json_last_error() === JSON_ERROR_NONE && isset($data["driverIdentifier"])) {
|
||||
|
||||
$this->SetValue("Letzer_User", $data["driverIdentifier"]);
|
||||
|
||||
if($this->ReadPropertyString("Username") === $data["driverIdentifier"]){
|
||||
$this->SetValue("Solarladen", true);
|
||||
}else{
|
||||
$this->SetValue("Solarladen", false);
|
||||
}
|
||||
}
|
||||
|
||||
//Aktueller Zustand Ladestation abfragen (Leistung, auto eingesteckt?)
|
||||
$ch2 = curl_init();
|
||||
|
||||
$url2 = "https://api.easee.com/api/chargers/".$this->ReadPropertyString("Seriennummer")."/state";
|
||||
curl_setopt_array($ch2, [
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => "GET",
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"Authorization: Bearer ".GetValue($this->ReadPropertyInteger("Token_Easee"))."",
|
||||
"content-type: application/*+json"
|
||||
],
|
||||
]);
|
||||
|
||||
curl_setopt($ch2, CURLOPT_URL, $url2);
|
||||
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
|
||||
$response_easee = curl_exec($ch2);
|
||||
curl_close($ch2);
|
||||
|
||||
$easee_data = json_decode($response_easee, true);
|
||||
|
||||
|
||||
if (json_last_error() === JSON_ERROR_NONE && isset($easee_data["chargerOpMode"])) {
|
||||
|
||||
if ($easee_data["chargerOpMode"] != 1 && (($easee_data["chargerOpMode"] != 6)||($this->GetValue("Car_detected")==true)) && $easee_data["chargerOpMode"] != 7) {
|
||||
$car_on_station = true;
|
||||
}
|
||||
else{
|
||||
$car_on_station = false;
|
||||
}
|
||||
$this->SetValue("Ladeleistung_Effektiv", round($easee_data["totalPower"]*1000));
|
||||
$this->SetValue("Fahrzeugstatus", $easee_data["chargerOpMode"]);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case 6:
|
||||
|
||||
|
||||
|
||||
//Aktueller Zustand Ladestation abfragen (Leistung, auto eingesteckt?)
|
||||
$ch2 = curl_init();
|
||||
|
||||
$url2 = "https://api.easee.com/api/chargers/".$this->ReadPropertyString("Seriennummer")."/state";
|
||||
curl_setopt_array($ch2, [
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => "GET",
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"Authorization: Bearer ".$this->GetBuffer("Token_Intern")."",
|
||||
"content-type: application/*+json"
|
||||
],
|
||||
]);
|
||||
|
||||
curl_setopt($ch2, CURLOPT_URL, $url2);
|
||||
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
|
||||
$response_easee = curl_exec($ch2);
|
||||
curl_close($ch2);
|
||||
|
||||
$easee_data = json_decode($response_easee, true);
|
||||
|
||||
|
||||
if (json_last_error() === JSON_ERROR_NONE && isset($easee_data["chargerOpMode"])) {
|
||||
|
||||
if ($easee_data["chargerOpMode"] != 1 && (($easee_data["chargerOpMode"] != 6)||($this->GetValue("Car_detected")==true)) && $easee_data["chargerOpMode"] != 7) {
|
||||
$car_on_station = true;
|
||||
}
|
||||
else{
|
||||
$car_on_station = false;
|
||||
}
|
||||
$this->SetValue("Ladeleistung_Effektiv", round($easee_data["totalPower"]*1000));
|
||||
$this->SetValue("Fahrzeugstatus", $easee_data["chargerOpMode"]);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->SetValue("Car_detected", false);
|
||||
$this->SetValue("Fahrzeugstatus", -1);
|
||||
@@ -384,10 +515,10 @@ class Ladestation_v2 extends IPSModule
|
||||
{
|
||||
$maxCurrent = 32;
|
||||
if($is_1_ph){
|
||||
$maxCurrent = 1.5 + ($this->GetValue("Ladeleistung_Effektiv") / 230);
|
||||
$maxCurrent = 2.5 + ($this->GetValue("Ladeleistung_Effektiv") / 230);
|
||||
}
|
||||
else{
|
||||
$maxCurrent = 1.5 + ($this->GetValue("Ladeleistung_Effektiv") / (1.71*400));
|
||||
$maxCurrent = 2.5 + ($this->GetValue("Ladeleistung_Effektiv") / (1.71*400));
|
||||
}
|
||||
if($maxCurrent>$this->ReadPropertyInteger("Max_Current_abs")){
|
||||
$maxCurrent = $this->ReadPropertyInteger("Max_Current_abs");
|
||||
@@ -406,10 +537,24 @@ class Ladestation_v2 extends IPSModule
|
||||
return $current;
|
||||
}
|
||||
|
||||
public function Get_Array_From_Current(bool $is_1_ph, float $current)
|
||||
public function Get_Array_From_Current(bool $is_1_ph, float $current, int $power, bool $timer)
|
||||
{
|
||||
$resultArray = [];
|
||||
$resultArray[] = 0;
|
||||
|
||||
if ($timer) {
|
||||
// Timer an
|
||||
if ($power === 0) {
|
||||
// power == 0: nur eine 0 zurückgeben
|
||||
$resultArray[] = 0;
|
||||
return $resultArray;
|
||||
}
|
||||
// power > 0: keine 0 am Anfang, Schleife normal durchlaufen
|
||||
} else {
|
||||
// Timer aus: wie bisher, 0 am Anfang
|
||||
$resultArray[] = 0;
|
||||
}
|
||||
|
||||
// Schleife wie gehabt
|
||||
for ($i = 6; $i <= $current; $i++) {
|
||||
if ($is_1_ph) {
|
||||
$resultArray[] = $i * 230;
|
||||
@@ -417,12 +562,13 @@ class Ladestation_v2 extends IPSModule
|
||||
$resultArray[] = $i * 400 * 1.71;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $resultArray;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function SetAktuelle_Leistung(int $power)
|
||||
{
|
||||
// Hier eine Leistungsänderung detektieren für Idle und interne Mindestlaufzeiten
|
||||
@@ -431,6 +577,14 @@ class Ladestation_v2 extends IPSModule
|
||||
$this->SetTimerOn();
|
||||
}
|
||||
|
||||
if (($this->GetValue("Aktuelle_Leistung") == 0) && ($power>0)) {
|
||||
$this->SetTimerNullMindestlast($this->ReadPropertyInteger("Ein_Zeit"));
|
||||
}
|
||||
elseif(($this->GetValue("Aktuelle_Leistung") > 0) && ($power==0)){
|
||||
$this->SetTimerNullMindestlast($this->ReadPropertyInteger("Aus_Zeit"));
|
||||
|
||||
}
|
||||
|
||||
$internalPower = GetValue($this->GetIDForIdent("Aktuelle_Leistung"));
|
||||
|
||||
// Aktuelle Leistungsvorgabe setzen
|
||||
@@ -444,7 +598,7 @@ class Ladestation_v2 extends IPSModule
|
||||
if ($power != $internalPower) {
|
||||
// Setze die interne Leistungsvorgabe
|
||||
|
||||
// Idle für 4 Zyklen auf false setzen
|
||||
// Idle für x Zyklen auf false setzen
|
||||
SetValue($this->GetIDForIdent("Idle"), false);
|
||||
SetValue(
|
||||
$this->GetIDForIdent("IdleCounter"),
|
||||
@@ -511,13 +665,13 @@ class Ladestation_v2 extends IPSModule
|
||||
if (!$ladebereit) {
|
||||
$powerSteps = [0];
|
||||
} elseif (!$Peak && !$solarladen) {
|
||||
$powerSteps = [max($this->Get_Array_From_Current($this->GetValue("Is_1_ph"),$this->GetValue("Max_Current")))];
|
||||
$powerSteps = [max($this->Get_Array_From_Current($this->GetValue("Is_1_ph"),$this->GetValue("Max_Current"), $this->GetValue("Aktuelle_Leistung"), $this->GetValue("IsTimerActive_Null_Timer")))];
|
||||
} elseif (!$Peak && $solarladen) {
|
||||
$powerSteps = $this->Get_Array_From_Current($this->GetValue("Is_1_ph"),$this->GetValue("Max_Current"));
|
||||
$powerSteps = $this->Get_Array_From_Current($this->GetValue("Is_1_ph"),$this->GetValue("Max_Current"), $this->GetValue("Aktuelle_Leistung"), $this->GetValue("IsTimerActive_Null_Timer"));
|
||||
} elseif ($solarladen && $Peak) {
|
||||
$powerSteps = [0];
|
||||
} else {
|
||||
$powerSteps = $this->Get_Array_From_Current($this->GetValue("Is_1_ph"),$this->GetValue("Max_Current"));
|
||||
$powerSteps = $this->Get_Array_From_Current($this->GetValue("Is_1_ph"),$this->GetValue("Max_Current"), $this->GetValue("Aktuelle_Leistung"), $this->GetValue("IsTimerActive_Null_Timer"));
|
||||
}
|
||||
|
||||
// PowerSteps in der RegisterVariable speichern
|
||||
@@ -528,7 +682,7 @@ class Ladestation_v2 extends IPSModule
|
||||
if($this->GetValue("Aktuelle_Leistung")>(1.11*$this->GetValue("Ladeleistung_Effektiv"))){
|
||||
$this->SetValue("Pending_Counter", $counter+1);
|
||||
|
||||
}elseif(max($this->Get_Array_From_Current($this->GetValue("Is_1_ph"),$this->GetValue("Max_Current")))<(1.11*$this->GetValue("Ladeleistung_Effektiv"))){ // diesen elseif ggf wieder rauslöschen
|
||||
}elseif(max($this->Get_Array_From_Current($this->GetValue("Is_1_ph"),$this->GetValue("Max_Current"), $this->GetValue("Aktuelle_Leistung"), $this->GetValue("IsTimerActive_Null_Timer")))<(1.11*$this->GetValue("Ladeleistung_Effektiv"))){ // diesen elseif ggf wieder rauslöschen
|
||||
$this->SetValue("Pending_Counter", $counter+1);
|
||||
|
||||
}
|
||||
@@ -544,9 +698,6 @@ class Ladestation_v2 extends IPSModule
|
||||
$this->Calc_Max_Current($this->GetValue("Is_1_ph"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return $powerSteps;
|
||||
}
|
||||
|
||||
@@ -571,6 +722,9 @@ class Ladestation_v2 extends IPSModule
|
||||
case 5:
|
||||
// Keine base Url nötig
|
||||
break;
|
||||
case 6:
|
||||
// Keine base Url nötig
|
||||
break;
|
||||
}
|
||||
|
||||
$ch = curl_init();
|
||||
@@ -595,6 +749,9 @@ class Ladestation_v2 extends IPSModule
|
||||
// Nichts zu tun für Dummy station
|
||||
return;
|
||||
case 5:
|
||||
if($this->ReadPropertyString("Username") != $this->GetValue("Letzer_User")){
|
||||
return;
|
||||
}
|
||||
$url = "https://api.easee.com/api/chargers/".$this->ReadPropertyString("Seriennummer")."/commands/set_dynamic_charger_current";
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_ENCODING => "",
|
||||
@@ -602,13 +759,31 @@ class Ladestation_v2 extends IPSModule
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => "{\"amps\":". $value .",\"minutes\":1}",
|
||||
CURLOPT_POSTFIELDS => "{\"amps\":". $value .",\"minutes\":0}",
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"Authorization: Bearer ".GetValue($this->ReadPropertyInteger("Token_Easee"))."",
|
||||
"content-type: application/*+json"
|
||||
],
|
||||
]);
|
||||
|
||||
break;
|
||||
|
||||
case 6:
|
||||
|
||||
$url = "https://api.easee.com/api/chargers/".$this->ReadPropertyString("Seriennummer")."/commands/set_dynamic_charger_current";
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => "{\"amps\":". $value .",\"minutes\":0}",
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"Authorization: Bearer ".$this->GetBuffer("Token_Intern")."",
|
||||
"content-type: application/*+json"
|
||||
],
|
||||
]);
|
||||
break;
|
||||
|
||||
default:
|
||||
return "Invalid station type.";
|
||||
}
|
||||
@@ -637,6 +812,9 @@ class Ladestation_v2 extends IPSModule
|
||||
// Nichts zu tun für Dummy station
|
||||
return;
|
||||
case 5:
|
||||
if($this->ReadPropertyString("Username") != $this->GetValue("Letzer_User")){
|
||||
return;
|
||||
}
|
||||
$url2 = "https://api.easee.com/api/chargers/".$this->ReadPropertyString("Seriennummer")."/commands/set_dynamic_charger_current";
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_ENCODING => "",
|
||||
@@ -644,13 +822,31 @@ class Ladestation_v2 extends IPSModule
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => "{\"amps\":". $value .",\"minutes\":1}",
|
||||
CURLOPT_POSTFIELDS => "{\"amps\":". $value .",\"minutes\":0}",
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"Authorization: Bearer ".GetValue($this->ReadPropertyInteger("Token_Easee"))."",
|
||||
"content-type: application/*+json"
|
||||
],
|
||||
]);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
|
||||
$url2 = "https://api.easee.com/api/chargers/".$this->ReadPropertyString("Seriennummer")."/commands/set_dynamic_charger_current";
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => "{\"amps\":". $value .",\"minutes\":0}",
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"Authorization: Bearer ".$this->GetBuffer("Token_Intern")."",
|
||||
"content-type: application/*+json"
|
||||
],
|
||||
]);
|
||||
break;
|
||||
|
||||
default:
|
||||
return "Invalid station type.";
|
||||
}
|
||||
@@ -678,6 +874,43 @@ class Ladestation_v2 extends IPSModule
|
||||
}
|
||||
}
|
||||
|
||||
public function Refresh_Token(){
|
||||
|
||||
$payload = json_encode([
|
||||
'userName' => $this->ReadPropertyString("Username"),
|
||||
'password' => $this->ReadPropertyString("Password"),
|
||||
]);
|
||||
|
||||
// cURL-Handle initialisieren
|
||||
$ch = curl_init('https://api.easee.com/api/accounts/login');
|
||||
|
||||
// cURL-Optionen setzen
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_RETURNTRANSFER => true, // Antwort als String zurückgeben
|
||||
CURLOPT_POST => true, // POST-Methode verwenden
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Accept: application/json',
|
||||
'Content-Type: application/json',
|
||||
],
|
||||
CURLOPT_POSTFIELDS => $payload, // JSON-Body übergeben
|
||||
]);
|
||||
|
||||
// Anfrage ausführen und Antwort speichern
|
||||
$response = curl_exec($ch);
|
||||
|
||||
// Auf Fehler prüfen
|
||||
if ($response === false) {
|
||||
echo 'cURL-Fehler: ' . curl_error($ch);
|
||||
curl_close($ch);
|
||||
exit;
|
||||
}
|
||||
|
||||
// cURL-Handle schließen
|
||||
curl_close($ch);
|
||||
$this->SetBuffer("Token_Intern", (json_decode($response, true)['accessToken']));
|
||||
|
||||
}
|
||||
|
||||
public function CheckIdle($power)
|
||||
{
|
||||
$lastpower = GetValue($this->GetIDForIdent("Aktuelle_Leistung"));
|
||||
|
||||
Reference in New Issue
Block a user