diff --git a/EaseeGateway/README.md b/EaseeGateway/README.md index 426ae66..5880104 100644 --- a/EaseeGateway/README.md +++ b/EaseeGateway/README.md @@ -1,7 +1,8 @@ # Easee SignalR Gateway Das Gateway hält eine gemeinsame SignalR-Verbindung zum Easee-Konto und verteilt -die Observations 109 (Charger Op Mode) und 120 (Total Power) an alle verbundenen +die Observations 47 (Max Charger Current), 109 (Charger Op Mode), 110 +(Output Phase) und 120 (Total Power) an alle verbundenen Ladestation_v2-Instanzen. Benutzername und Passwort werden ausschließlich im Gateway eingetragen. Mehrere diff --git a/EaseeGateway/module.php b/EaseeGateway/module.php index 23414c5..e2c44f2 100644 --- a/EaseeGateway/module.php +++ b/EaseeGateway/module.php @@ -499,7 +499,7 @@ class EaseeGateway extends IPSModule if ( $serialNumber !== "" && $valueExists && - ($observationID === 109 || $observationID === 120) + in_array($observationID, [47, 109, 110, 120], true) ) { $this->PublishObservation($serialNumber, $observationID, $value); } diff --git a/Ladestation_v2/README.md b/Ladestation_v2/README.md index 69ef14d..6f401df 100644 --- a/Ladestation_v2/README.md +++ b/Ladestation_v2/README.md @@ -19,9 +19,16 @@ Ladestationsinstanz muss die Easee-Seriennummer hinterlegt sein. Das Gateway liefert: +- Observation 47: maximaler Ladestrom der Station - Observation 109: Fahrzeug-/Ladestatus +- Observation 110: aktive Ausgangsphase - Observation 120: aktuelle Gesamtleistung in kW +Bei Easee erfolgt die Fahrzeug- und Phasenerkennung ohne den zeitbasierten +`Pending_Counter`. Der maximale Ladestrom wird aus Observation 47 übernommen +und zusätzlich durch `Max_Current_abs` begrenzt. Die Typen 1 bis 4 verwenden +weiterhin unverändert die bisherige zeit- und leistungsbasierte Erkennung. + Stromvorgaben von 0 bis 32 A werden ebenfalls über das Gateway gesendet. ## Andere Ladestationstypen diff --git a/Ladestation_v2/module.php b/Ladestation_v2/module.php index 69b62f9..951df27 100644 --- a/Ladestation_v2/module.php +++ b/Ladestation_v2/module.php @@ -505,7 +505,7 @@ class Ladestation_v2 extends IPSModule } $updated = (int)($response["state"]["updated"] ?? time()); - foreach ([109, 120] as $observationID) { + foreach ([47, 109, 110, 120] as $observationID) { $key = (string)$observationID; if (array_key_exists($key, $response["state"])) { $this->StoreEaseeObservation( @@ -519,7 +519,7 @@ class Ladestation_v2 extends IPSModule private function StoreEaseeObservation(int $observationID, $value, int $timestamp) { - if ($observationID !== 109 && $observationID !== 120) { + if (!in_array($observationID, [47, 109, 110, 120], true)) { return; } @@ -547,15 +547,7 @@ class Ladestation_v2 extends IPSModule } $chargerOpMode = (int)$state["109"]; - if ( - $chargerOpMode != 1 && - ($chargerOpMode != 6 || $this->GetValue("Car_detected") == true) && - $chargerOpMode != 7 - ) { - $currentState = true; - } else { - $currentState = false; - } + $currentState = in_array($chargerOpMode, [2, 3, 4, 6], true); if (array_key_exists("120", $state)) { $this->SetValue( @@ -568,6 +560,73 @@ class Ladestation_v2 extends IPSModule return $currentState; } + private function DetectEaseeCar(int $carType): bool + { + $wasDetected = $this->GetValue("Car_detected"); + $carDetected = $this->Get_Car_Status($carType); + $state = json_decode($this->GetBuffer("EaseeGatewayState"), true); + if (!is_array($state)) { + $state = []; + } + + $this->SetValue("Pending_Counter", 0); + + // Observation 110: 10-15 = einphasig, 20-22 = zweiphasig, + // 30 = dreiphasig. Das bestehende Modul unterscheidet nur 1/3 Phasen; + // zweiphasig wird deshalb wie mehrphasig behandelt. + if (array_key_exists("110", $state)) { + $outputPhase = (int)$state["110"]; + if ($outputPhase >= 10 && $outputPhase <= 15) { + $this->SetValue("Is_1_ph", true); + } elseif ( + ($outputPhase >= 20 && $outputPhase <= 22) || + $outputPhase === 30 + ) { + $this->SetValue("Is_1_ph", false); + } + } + + // Observation 47 ist der nichtflüchtige maximale Ladestrom der + // Station. Die lokal konfigurierte Obergrenze bleibt zusätzlich aktiv. + $maxCurrent = (float)$this->ReadPropertyInteger("Max_Current_abs"); + if (array_key_exists("47", $state) && (float)$state["47"] > 0) { + $maxCurrent = min($maxCurrent, (float)$state["47"]); + } + $this->SetValue("Max_Current", $maxCurrent); + + if (!$carDetected) { + $this->SetValue("Car_detected", false); + $this->SetValue("Car_is_full", false); + + $chargerOpMode = (int)($state["109"] ?? -1); + if ($chargerOpMode === 1) { + $this->SetValue("Leistung_Delta", 0); + $this->ResetTimer(); + $this->ResetNullTimer(); + $this->SetValue("Is_1_ph", false); + $this->SetValue("Aktuelle_Leistung", 0); + $this->SetValue("IdleCounter", 0); + $this->SetValue("Idle", true); + } + + return false; + } + + $this->SetValue("Car_detected", true); + $this->SetValue("Car_is_full", (int)($state["109"] ?? 0) === 4); + + if (!$wasDetected) { + if ($this->GetValue("Is_1_ph")) { + $power = $this->GetValue("Mindestaldestrom") * 230; + } else { + $power = $this->GetValue("Mindestaldestrom") * 400 * 1.71; + } + $this->SetValue("Power", $power); + } + + return true; + } + private function SendEaseeCurrentToGateway(float $value) { $response = $this->SendEaseeGatewayRequest([ @@ -590,6 +649,10 @@ class Ladestation_v2 extends IPSModule public function Detect_Car(int $carType) { + if ($this->UsesEaseeGateway($carType)) { + return $this->DetectEaseeCar($carType); + } + if($this->GetValue("Car_detected")==true){ if($this->Get_Car_Status($carType)==true){ $this->SetValue("Car_detected", true); @@ -1048,7 +1111,8 @@ class Ladestation_v2 extends IPSModule // PowerSteps in der RegisterVariable speichern SetValue($this->GetIDForIdent("PowerSteps"), json_encode($powerSteps)); // Rückgabe der Powersteps - $counter = $this->GetValue("Pending_Counter"); + if (!$this->UsesEaseeGateway($this->ReadPropertyInteger("Ladestation"))) { + $counter = $this->GetValue("Pending_Counter"); if($this->GetValue("Aktuelle_Leistung")>(1.11*$this->GetValue("Ladeleistung_Effektiv"))){ $this->SetValue("Pending_Counter", $counter+1); @@ -1079,6 +1143,9 @@ class Ladestation_v2 extends IPSModule } } + } else { + $this->SetValue("Pending_Counter", 0); + } return $powerSteps; }