no message
This commit is contained in:
+84
-8
@@ -271,6 +271,25 @@ class Ladestation extends IPSModule
|
|||||||
// Einen noch vorhandenen Token-Timer aus Altinstanzen sicher stilllegen.
|
// Einen noch vorhandenen Token-Timer aus Altinstanzen sicher stilllegen.
|
||||||
$this->SetTimerInterval("Timer_Refresh_Token", 0);
|
$this->SetTimerInterval("Timer_Refresh_Token", 0);
|
||||||
$stationType = $this->ReadPropertyInteger("Ladestation");
|
$stationType = $this->ReadPropertyInteger("Ladestation");
|
||||||
|
|
||||||
|
// Bestehende Pico-Instanzen können aus der bisherigen Erkennung einen
|
||||||
|
// ungültigen Grenzwert von 2.5 A und dadurch "voll" gespeichert haben.
|
||||||
|
// Diese Altlast wird beim ersten Laden der korrigierten Version einmalig
|
||||||
|
// zurückgesetzt.
|
||||||
|
if (
|
||||||
|
$stationType === 3 &&
|
||||||
|
$this->GetBuffer("SmartMeFullDetectionVersion") !== "2"
|
||||||
|
) {
|
||||||
|
$this->SetValue("Car_is_full", false);
|
||||||
|
$this->SetValue("Pending_Counter", 0);
|
||||||
|
$this->SetValue(
|
||||||
|
"Max_Current",
|
||||||
|
(float)$this->ReadPropertyInteger("Max_Current_abs")
|
||||||
|
);
|
||||||
|
$this->SetBuffer("SmartMeChargingEnabled", "0");
|
||||||
|
$this->SetBuffer("SmartMeFullDetectionVersion", "2");
|
||||||
|
}
|
||||||
|
|
||||||
$usesEaseeGateway = $this->UsesEaseeGateway($stationType);
|
$usesEaseeGateway = $this->UsesEaseeGateway($stationType);
|
||||||
IPS_SetHidden(
|
IPS_SetHidden(
|
||||||
$this->GetIDForIdent("Easee_Gateway_Connected"),
|
$this->GetIDForIdent("Easee_Gateway_Connected"),
|
||||||
@@ -918,6 +937,10 @@ class Ladestation extends IPSModule
|
|||||||
|
|
||||||
private function DetectSmartMeCar(): bool
|
private function DetectSmartMeCar(): bool
|
||||||
{
|
{
|
||||||
|
// Bei einem fehlgeschlagenen Abruf darf eine alte Freigabe keinesfalls
|
||||||
|
// zur Ladeende-Erkennung weiterverwendet werden.
|
||||||
|
$this->SetBuffer("SmartMeChargingEnabled", "0");
|
||||||
|
|
||||||
$deviceID = trim($this->ReadPropertyString("ID"));
|
$deviceID = trim($this->ReadPropertyString("ID"));
|
||||||
if ($deviceID === "") {
|
if ($deviceID === "") {
|
||||||
return $this->GetValue("Car_detected");
|
return $this->GetValue("Car_detected");
|
||||||
@@ -954,6 +977,37 @@ class Ladestation extends IPSModule
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Die Pico-API unterscheidet zwischen der extern vorgegebenen
|
||||||
|
// Stromgrenze und der effektiv verfügbaren Stromgrenze. Nur wenn beide
|
||||||
|
// vorhandenen Grenzen mindestens dem Stationsminimum entsprechen, ist
|
||||||
|
// die Ladung wirklich freigegeben. Eine Regelungsunterbrechung mit 0 A
|
||||||
|
// darf nicht als abgeschlossenes Laden ausgewertet werden.
|
||||||
|
$minStationCurrent = $chargingData["MinStationCurrent"] ??
|
||||||
|
$chargingData["minStationCurrent"] ?? 6;
|
||||||
|
$minStationCurrent = is_numeric($minStationCurrent)
|
||||||
|
? max(1.0, (float)$minStationCurrent)
|
||||||
|
: 6.0;
|
||||||
|
|
||||||
|
$maxDynamicCurrent = $chargingData["MaxDynamicCurrent"] ??
|
||||||
|
$chargingData["maxDynamicCurrent"] ?? null;
|
||||||
|
$maxAllowedCurrent = $chargingData["MaxAllowedChargingCurrent"] ??
|
||||||
|
$chargingData["maxAllowedChargingCurrent"] ?? null;
|
||||||
|
|
||||||
|
$hasCurrentLimit = is_numeric($maxDynamicCurrent) ||
|
||||||
|
is_numeric($maxAllowedCurrent);
|
||||||
|
$dynamicCurrentAllowsCharging = !is_numeric($maxDynamicCurrent) ||
|
||||||
|
(float)$maxDynamicCurrent >= $minStationCurrent;
|
||||||
|
$allowedCurrentAllowsCharging = !is_numeric($maxAllowedCurrent) ||
|
||||||
|
(float)$maxAllowedCurrent >= $minStationCurrent;
|
||||||
|
$chargingEnabled = $hasCurrentLimit
|
||||||
|
? $dynamicCurrentAllowsCharging && $allowedCurrentAllowsCharging
|
||||||
|
: $this->GetValue("Aktuelle_Leistung") > 0;
|
||||||
|
|
||||||
|
$this->SetBuffer(
|
||||||
|
"SmartMeChargingEnabled",
|
||||||
|
$chargingEnabled ? "1" : "0"
|
||||||
|
);
|
||||||
|
|
||||||
$isOnePhase = null;
|
$isOnePhase = null;
|
||||||
$deviceData = $this->ReadJsonEndpoint(
|
$deviceData = $this->ReadJsonEndpoint(
|
||||||
"https://api.smart-me.com/Devices/" . $deviceID,
|
"https://api.smart-me.com/Devices/" . $deviceID,
|
||||||
@@ -984,13 +1038,17 @@ class Ladestation extends IPSModule
|
|||||||
}
|
}
|
||||||
|
|
||||||
$carDetected = in_array($stationState, [2, 3, 4, 6], true);
|
$carDetected = in_array($stationState, [2, 3, 4, 6], true);
|
||||||
$carIsFull = $this->GetValue("Car_is_full");
|
$wasFull = $this->GetValue("Car_is_full");
|
||||||
if (!$carIsFull) {
|
$carIsCharging = is_numeric($chargingPowerWatts) &&
|
||||||
$learnedMaxCurrent = (float)$this->GetValue("Max_Current");
|
abs((float)$chargingPowerWatts) >= 100;
|
||||||
$carIsFull = $carDetected &&
|
$carIsFull = $carDetected && $wasFull && !$carIsCharging;
|
||||||
$this->GetValue("Car_detected") &&
|
|
||||||
$learnedMaxCurrent > 0 &&
|
// Ein aus einer früheren Regelungsunterbrechung gelernter Wert unter
|
||||||
$learnedMaxCurrent < 6;
|
// dem Mindestladestrom darf die Station nicht dauerhaft blockieren.
|
||||||
|
// Ein korrekt bestätigtes Ladeende wird dagegen bis zum Abstecken oder
|
||||||
|
// bis zur erneuten Leistungsaufnahme gehalten.
|
||||||
|
if (!$carIsFull && (float)$this->GetValue("Max_Current") < 6) {
|
||||||
|
$this->SetValue("Max_Current", $maxCurrent);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->ApplyDirectStationDetection(
|
return $this->ApplyDirectStationDetection(
|
||||||
@@ -1517,12 +1575,15 @@ class Ladestation extends IPSModule
|
|||||||
$maxPowerStep = count($powerSteps) > 0 ? max($powerSteps) : 0;
|
$maxPowerStep = count($powerSteps) > 0 ? max($powerSteps) : 0;
|
||||||
$goEEnabled = !in_array($stationType, [1, 2], true) ||
|
$goEEnabled = !in_array($stationType, [1, 2], true) ||
|
||||||
$this->GetBuffer("GoEChargingEnabledFromStatus") === "1";
|
$this->GetBuffer("GoEChargingEnabledFromStatus") === "1";
|
||||||
|
$smartMeEnabled = $stationType !== 3 ||
|
||||||
|
$this->GetBuffer("SmartMeChargingEnabled") === "1";
|
||||||
$canEvaluate = $ladebereit &&
|
$canEvaluate = $ladebereit &&
|
||||||
$this->GetValue("Car_detected") &&
|
$this->GetValue("Car_detected") &&
|
||||||
!$this->GetValue("Car_is_full") &&
|
!$this->GetValue("Car_is_full") &&
|
||||||
$requestedPower > 0 &&
|
$requestedPower > 0 &&
|
||||||
$maxPowerStep > 0 &&
|
$maxPowerStep > 0 &&
|
||||||
$goEEnabled;
|
$goEEnabled &&
|
||||||
|
$smartMeEnabled;
|
||||||
|
|
||||||
$requestedMismatch = $requestedPower > (1.11 * $actualPower);
|
$requestedMismatch = $requestedPower > (1.11 * $actualPower);
|
||||||
$availableMismatch = $maxAvailablePower < (1.11 * $actualPower);
|
$availableMismatch = $maxAvailablePower < (1.11 * $actualPower);
|
||||||
@@ -1537,6 +1598,21 @@ class Ladestation extends IPSModule
|
|||||||
$this->SetValue("Pending_Counter", 0);
|
$this->SetValue("Pending_Counter", 0);
|
||||||
if ($requestedMismatch) {
|
if ($requestedMismatch) {
|
||||||
$this->Calc_Max_Current($this->GetValue("Is_1_ph"));
|
$this->Calc_Max_Current($this->GetValue("Is_1_ph"));
|
||||||
|
|
||||||
|
// Smart-Me liefert keinen eindeutigen Status "Auto
|
||||||
|
// voll". Erst wenn während einer echten Freigabe über
|
||||||
|
// 90 Sekunden praktisch kein Strom angenommen wird,
|
||||||
|
// bestätigt der gelernte Wert unter 6 A das Ladeende.
|
||||||
|
if (
|
||||||
|
$stationType === 3 &&
|
||||||
|
$this->GetBuffer("SmartMeChargingEnabled") === "1" &&
|
||||||
|
(float)$this->GetValue("Max_Current") > 0 &&
|
||||||
|
(float)$this->GetValue("Max_Current") < 6
|
||||||
|
) {
|
||||||
|
$this->SetValue("Car_is_full", true);
|
||||||
|
$this->ResetTimer();
|
||||||
|
$this->ResetNullTimer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -281,6 +281,25 @@ class Ladestation_v2 extends IPSModule
|
|||||||
);
|
);
|
||||||
$this->SetTimerInterval("Timer_Do_UserCalc_EVC",$this->ReadPropertyInteger("Interval")*1000);
|
$this->SetTimerInterval("Timer_Do_UserCalc_EVC",$this->ReadPropertyInteger("Interval")*1000);
|
||||||
$stationType = $this->ReadPropertyInteger("Ladestation");
|
$stationType = $this->ReadPropertyInteger("Ladestation");
|
||||||
|
|
||||||
|
// Bestehende Pico-Instanzen können aus der bisherigen Erkennung einen
|
||||||
|
// ungültigen Grenzwert von 2.5 A und dadurch "voll" gespeichert haben.
|
||||||
|
// Diese Altlast wird beim ersten Laden der korrigierten Version einmalig
|
||||||
|
// zurückgesetzt.
|
||||||
|
if (
|
||||||
|
$stationType === 3 &&
|
||||||
|
$this->GetBuffer("SmartMeFullDetectionVersion") !== "2"
|
||||||
|
) {
|
||||||
|
$this->SetValue("Car_is_full", false);
|
||||||
|
$this->SetValue("Pending_Counter", 0);
|
||||||
|
$this->SetValue(
|
||||||
|
"Max_Current",
|
||||||
|
(float)$this->ReadPropertyInteger("Max_Current_abs")
|
||||||
|
);
|
||||||
|
$this->SetBuffer("SmartMeChargingEnabled", "0");
|
||||||
|
$this->SetBuffer("SmartMeFullDetectionVersion", "2");
|
||||||
|
}
|
||||||
|
|
||||||
$usesEaseeGateway = $this->UsesEaseeGateway($stationType);
|
$usesEaseeGateway = $this->UsesEaseeGateway($stationType);
|
||||||
IPS_SetHidden(
|
IPS_SetHidden(
|
||||||
$this->GetIDForIdent("Easee_Gateway_Connected"),
|
$this->GetIDForIdent("Easee_Gateway_Connected"),
|
||||||
@@ -938,6 +957,10 @@ class Ladestation_v2 extends IPSModule
|
|||||||
|
|
||||||
private function DetectSmartMeCar(): bool
|
private function DetectSmartMeCar(): bool
|
||||||
{
|
{
|
||||||
|
// Bei einem fehlgeschlagenen Abruf darf eine alte Freigabe keinesfalls
|
||||||
|
// zur Ladeende-Erkennung weiterverwendet werden.
|
||||||
|
$this->SetBuffer("SmartMeChargingEnabled", "0");
|
||||||
|
|
||||||
$deviceID = trim($this->ReadPropertyString("ID"));
|
$deviceID = trim($this->ReadPropertyString("ID"));
|
||||||
if ($deviceID === "") {
|
if ($deviceID === "") {
|
||||||
return $this->GetValue("Car_detected");
|
return $this->GetValue("Car_detected");
|
||||||
@@ -974,6 +997,37 @@ class Ladestation_v2 extends IPSModule
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Die Pico-API unterscheidet zwischen der extern vorgegebenen
|
||||||
|
// Stromgrenze und der effektiv verfügbaren Stromgrenze. Nur wenn beide
|
||||||
|
// vorhandenen Grenzen mindestens dem Stationsminimum entsprechen, ist
|
||||||
|
// die Ladung wirklich freigegeben. Eine Regelungsunterbrechung mit 0 A
|
||||||
|
// darf nicht als abgeschlossenes Laden ausgewertet werden.
|
||||||
|
$minStationCurrent = $chargingData["MinStationCurrent"] ??
|
||||||
|
$chargingData["minStationCurrent"] ?? 6;
|
||||||
|
$minStationCurrent = is_numeric($minStationCurrent)
|
||||||
|
? max(1.0, (float)$minStationCurrent)
|
||||||
|
: 6.0;
|
||||||
|
|
||||||
|
$maxDynamicCurrent = $chargingData["MaxDynamicCurrent"] ??
|
||||||
|
$chargingData["maxDynamicCurrent"] ?? null;
|
||||||
|
$maxAllowedCurrent = $chargingData["MaxAllowedChargingCurrent"] ??
|
||||||
|
$chargingData["maxAllowedChargingCurrent"] ?? null;
|
||||||
|
|
||||||
|
$hasCurrentLimit = is_numeric($maxDynamicCurrent) ||
|
||||||
|
is_numeric($maxAllowedCurrent);
|
||||||
|
$dynamicCurrentAllowsCharging = !is_numeric($maxDynamicCurrent) ||
|
||||||
|
(float)$maxDynamicCurrent >= $minStationCurrent;
|
||||||
|
$allowedCurrentAllowsCharging = !is_numeric($maxAllowedCurrent) ||
|
||||||
|
(float)$maxAllowedCurrent >= $minStationCurrent;
|
||||||
|
$chargingEnabled = $hasCurrentLimit
|
||||||
|
? $dynamicCurrentAllowsCharging && $allowedCurrentAllowsCharging
|
||||||
|
: $this->GetValue("Aktuelle_Leistung") > 0;
|
||||||
|
|
||||||
|
$this->SetBuffer(
|
||||||
|
"SmartMeChargingEnabled",
|
||||||
|
$chargingEnabled ? "1" : "0"
|
||||||
|
);
|
||||||
|
|
||||||
$isOnePhase = null;
|
$isOnePhase = null;
|
||||||
$deviceData = $this->ReadJsonEndpoint(
|
$deviceData = $this->ReadJsonEndpoint(
|
||||||
"https://api.smart-me.com/Devices/" . $deviceID,
|
"https://api.smart-me.com/Devices/" . $deviceID,
|
||||||
@@ -1004,13 +1058,17 @@ class Ladestation_v2 extends IPSModule
|
|||||||
}
|
}
|
||||||
|
|
||||||
$carDetected = in_array($stationState, [2, 3, 4, 6], true);
|
$carDetected = in_array($stationState, [2, 3, 4, 6], true);
|
||||||
$carIsFull = $this->GetValue("Car_is_full");
|
$wasFull = $this->GetValue("Car_is_full");
|
||||||
if (!$carIsFull) {
|
$carIsCharging = is_numeric($chargingPowerWatts) &&
|
||||||
$learnedMaxCurrent = (float)$this->GetValue("Max_Current");
|
abs((float)$chargingPowerWatts) >= 100;
|
||||||
$carIsFull = $carDetected &&
|
$carIsFull = $carDetected && $wasFull && !$carIsCharging;
|
||||||
$this->GetValue("Car_detected") &&
|
|
||||||
$learnedMaxCurrent > 0 &&
|
// Ein aus einer früheren Regelungsunterbrechung gelernter Wert unter
|
||||||
$learnedMaxCurrent < 6;
|
// dem Mindestladestrom darf die Station nicht dauerhaft blockieren.
|
||||||
|
// Ein korrekt bestätigtes Ladeende wird dagegen bis zum Abstecken oder
|
||||||
|
// bis zur erneuten Leistungsaufnahme gehalten.
|
||||||
|
if (!$carIsFull && (float)$this->GetValue("Max_Current") < 6) {
|
||||||
|
$this->SetValue("Max_Current", $maxCurrent);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->ApplyDirectStationDetection(
|
return $this->ApplyDirectStationDetection(
|
||||||
@@ -1530,12 +1588,15 @@ class Ladestation_v2 extends IPSModule
|
|||||||
$maxPowerStep = count($powerSteps) > 0 ? max($powerSteps) : 0;
|
$maxPowerStep = count($powerSteps) > 0 ? max($powerSteps) : 0;
|
||||||
$goEEnabled = !in_array($stationType, [1, 2], true) ||
|
$goEEnabled = !in_array($stationType, [1, 2], true) ||
|
||||||
$this->GetBuffer("GoEChargingEnabledFromStatus") === "1";
|
$this->GetBuffer("GoEChargingEnabledFromStatus") === "1";
|
||||||
|
$smartMeEnabled = $stationType !== 3 ||
|
||||||
|
$this->GetBuffer("SmartMeChargingEnabled") === "1";
|
||||||
$canEvaluate = $ladebereit &&
|
$canEvaluate = $ladebereit &&
|
||||||
$this->GetValue("Car_detected") &&
|
$this->GetValue("Car_detected") &&
|
||||||
!$this->GetValue("Car_is_full") &&
|
!$this->GetValue("Car_is_full") &&
|
||||||
$requestedPower > 0 &&
|
$requestedPower > 0 &&
|
||||||
$maxPowerStep > 0 &&
|
$maxPowerStep > 0 &&
|
||||||
$goEEnabled;
|
$goEEnabled &&
|
||||||
|
$smartMeEnabled;
|
||||||
|
|
||||||
$requestedMismatch = $requestedPower > (1.11 * $actualPower);
|
$requestedMismatch = $requestedPower > (1.11 * $actualPower);
|
||||||
$availableMismatch = $maxAvailablePower < (1.11 * $actualPower);
|
$availableMismatch = $maxAvailablePower < (1.11 * $actualPower);
|
||||||
@@ -1550,6 +1611,21 @@ class Ladestation_v2 extends IPSModule
|
|||||||
$this->SetValue("Pending_Counter", 0);
|
$this->SetValue("Pending_Counter", 0);
|
||||||
if ($requestedMismatch) {
|
if ($requestedMismatch) {
|
||||||
$this->Calc_Max_Current($this->GetValue("Is_1_ph"));
|
$this->Calc_Max_Current($this->GetValue("Is_1_ph"));
|
||||||
|
|
||||||
|
// Smart-Me liefert keinen eindeutigen Status "Auto
|
||||||
|
// voll". Erst wenn während einer echten Freigabe über
|
||||||
|
// 90 Sekunden praktisch kein Strom angenommen wird,
|
||||||
|
// bestätigt der gelernte Wert unter 6 A das Ladeende.
|
||||||
|
if (
|
||||||
|
$stationType === 3 &&
|
||||||
|
$this->GetBuffer("SmartMeChargingEnabled") === "1" &&
|
||||||
|
(float)$this->GetValue("Max_Current") > 0 &&
|
||||||
|
(float)$this->GetValue("Max_Current") < 6
|
||||||
|
) {
|
||||||
|
$this->SetValue("Car_is_full", true);
|
||||||
|
$this->ResetTimer();
|
||||||
|
$this->ResetNullTimer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user