no message
This commit is contained in:
+2
-11
@@ -107,17 +107,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "NumberSpinner",
|
"type": "NumberSpinner",
|
||||||
"name": "ReserveHoursLaden",
|
"name": "ReserveHours",
|
||||||
"caption": "SDL Reservezeit Laden",
|
"caption": "SDL Reservezeit",
|
||||||
"suffix": " h",
|
|
||||||
"minimum": 0,
|
|
||||||
"maximum": 24,
|
|
||||||
"digits": 2
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "NumberSpinner",
|
|
||||||
"name": "ReserveHoursEntladen",
|
|
||||||
"caption": "SDL Reservezeit Entladen",
|
|
||||||
"suffix": " h",
|
"suffix": " h",
|
||||||
"minimum": 0,
|
"minimum": 0,
|
||||||
"maximum": 24,
|
"maximum": 24,
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ class Bat_EV_SDL_V4 extends IPSModule
|
|||||||
$this->RegisterPropertyString("Batteries", "[]");
|
$this->RegisterPropertyString("Batteries", "[]");
|
||||||
$this->RegisterPropertyInteger("SDL_Leistung_Laden", 0); // W
|
$this->RegisterPropertyInteger("SDL_Leistung_Laden", 0); // W
|
||||||
$this->RegisterPropertyInteger("SDL_Leistung_Entladen", 0); // W
|
$this->RegisterPropertyInteger("SDL_Leistung_Entladen", 0); // W
|
||||||
$this->RegisterPropertyFloat("ReserveHoursLaden", 0.5); // h
|
$this->RegisterPropertyFloat("ReserveHours", 0.5); // h
|
||||||
$this->RegisterPropertyFloat("ReserveHoursEntladen", 0.5); // h
|
|
||||||
$this->RegisterPropertyFloat("SDL_Start_Pos_Config", 50.0); // %
|
$this->RegisterPropertyFloat("SDL_Start_Pos_Config", 50.0); // %
|
||||||
$this->RegisterPropertyFloat("EV_Start_Pos_Config", 50.0); // %
|
$this->RegisterPropertyFloat("EV_Start_Pos_Config", 50.0); // %
|
||||||
$this->RegisterPropertyInteger("UpdateInterval", 2); // Sekunden
|
$this->RegisterPropertyInteger("UpdateInterval", 2); // Sekunden
|
||||||
@@ -89,6 +88,23 @@ class Bat_EV_SDL_V4 extends IPSModule
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($Ident === "SDL_Reset") {
|
||||||
|
if ((bool)$Value) {
|
||||||
|
$this->ResetVirtualAccount("SDL");
|
||||||
|
SetValue($this->GetIDForIdent("SDL_Reset"), false);
|
||||||
|
$this->Update();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Ident === "EV_Reset") {
|
||||||
|
if ((bool)$Value) {
|
||||||
|
$this->ResetVirtualAccount("EV");
|
||||||
|
SetValue($this->GetIDForIdent("EV_Reset"), false);
|
||||||
|
$this->Update();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
throw new Exception("Invalid Ident: " . $Ident);
|
throw new Exception("Invalid Ident: " . $Ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,8 +173,7 @@ class Bat_EV_SDL_V4 extends IPSModule
|
|||||||
$sdlTotalW_laden = max(0, (int)$this->ReadPropertyInteger("SDL_Leistung_Laden"));
|
$sdlTotalW_laden = max(0, (int)$this->ReadPropertyInteger("SDL_Leistung_Laden"));
|
||||||
$sdlTotalW_entladen = max(0, (int)$this->ReadPropertyInteger("SDL_Leistung_Entladen"));
|
$sdlTotalW_entladen = max(0, (int)$this->ReadPropertyInteger("SDL_Leistung_Entladen"));
|
||||||
|
|
||||||
$reserveH_laden = max(0.0, (float)$this->ReadPropertyFloat("ReserveHoursLaden"));
|
$reserveH = max(0.0, (float)$this->ReadPropertyFloat("ReserveHours"));
|
||||||
$reserveH_entladen = max(0.0, (float)$this->ReadPropertyFloat("ReserveHoursEntladen"));
|
|
||||||
|
|
||||||
$hash = md5(json_encode([
|
$hash = md5(json_encode([
|
||||||
"Batteries" => $batteriesRaw,
|
"Batteries" => $batteriesRaw,
|
||||||
@@ -235,8 +250,8 @@ class Bat_EV_SDL_V4 extends IPSModule
|
|||||||
$evShareKW_entladen = max(0.0, $pBatKW - $sdlShareKW_entladen);
|
$evShareKW_entladen = max(0.0, $pBatKW - $sdlShareKW_entladen);
|
||||||
|
|
||||||
// Grenzen: individuell nach Reservezeit.
|
// Grenzen: individuell nach Reservezeit.
|
||||||
$underKWh = $sdlShareKW_entladen * $reserveH_entladen;
|
$underKWh = $sdlShareKW_entladen * $reserveH;
|
||||||
$upKWh = $capKWh - ($sdlShareKW_laden * $reserveH_laden);
|
$upKWh = $capKWh - ($sdlShareKW_laden * $reserveH);
|
||||||
|
|
||||||
$underKWh = max(0.0, min($capKWh, $underKWh));
|
$underKWh = max(0.0, min($capKWh, $underKWh));
|
||||||
$upKWh = max(0.0, min($capKWh, $upKWh));
|
$upKWh = max(0.0, min($capKWh, $upKWh));
|
||||||
@@ -769,6 +784,37 @@ class Bat_EV_SDL_V4 extends IPSModule
|
|||||||
$this->SetIdentValue("CalcJSON", json_encode(["error" => $reason], JSON_PRETTY_PRINT));
|
$this->SetIdentValue("CalcJSON", json_encode(["error" => $reason], JSON_PRETTY_PRINT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function ResetVirtualAccount(string $account): void
|
||||||
|
{
|
||||||
|
$plan = json_decode($this->GetBufferSafe("BatPlanJSON"), true);
|
||||||
|
if (!is_array($plan)) {
|
||||||
|
$this->BuildBatteryPlan(true);
|
||||||
|
$plan = json_decode($this->GetBufferSafe("BatPlanJSON"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_array($plan) || empty($plan["total"])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($account === "SDL") {
|
||||||
|
$total = (float)($plan["total"]["SDL_kWh_total"] ?? 0.0);
|
||||||
|
$startPct = 50.0;
|
||||||
|
|
||||||
|
$this->SetBuffer("Int_E_SDL_kWh", (string)($total * $startPct / 100.0));
|
||||||
|
$this->SetBuffer("Int_LastTs", (string)microtime(true));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($account === "EV") {
|
||||||
|
$total = (float)($plan["total"]["EV_kWh_total"] ?? 0.0);
|
||||||
|
$startPct = 50.0;
|
||||||
|
|
||||||
|
$this->SetBuffer("Int_E_EV_kWh", (string)($total * $startPct / 100.0));
|
||||||
|
$this->SetBuffer("Int_LastTs", (string)microtime(true));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function SetIdentValue(string $ident, $value): void
|
private function SetIdentValue(string $ident, $value): void
|
||||||
{
|
{
|
||||||
$id = @$this->GetIDForIdent($ident);
|
$id = @$this->GetIDForIdent($ident);
|
||||||
|
|||||||
Reference in New Issue
Block a user