diff --git a/Bat_EV_SDL_V4/form.json b/Bat_EV_SDL_V4/form.json index 8d09e7b..499fa6c 100644 --- a/Bat_EV_SDL_V4/form.json +++ b/Bat_EV_SDL_V4/form.json @@ -93,6 +93,19 @@ "edit": { "type": "SelectVariable" } + }, + { + "caption": "Min. SoC", + "name": "minPhysicalSocPct", + "width": "100px", + "suffix": " %", + "add": 5, + "edit": { + "type": "NumberSpinner", + "minimum": 0, + "maximum": 30, + "digits": 1 + } } ], "values": [] diff --git a/Bat_EV_SDL_V4/module.php b/Bat_EV_SDL_V4/module.php index fce8ad7..685de36 100644 --- a/Bat_EV_SDL_V4/module.php +++ b/Bat_EV_SDL_V4/module.php @@ -225,6 +225,8 @@ class Bat_EV_SDL_V4 extends IPSModule $pBatW = max(0.0, (float)($b["powerbat"] ?? 0)); $pBatKW = $pBatW / 1000.0; $capKWh = max(0.0, (float)($b["capazity"] ?? 0)); + $minPhysicalSocPct = max(0.0, min(100.0, (float)($b["minPhysicalSocPct"] ?? 5.0))); + $minPhysicalKWh = $capKWh * $minPhysicalSocPct / 100.0; if ($capKWh <= 0.0 || $pBatKW <= 0.0) { continue; @@ -239,12 +241,14 @@ class Bat_EV_SDL_V4 extends IPSModule $evShareKW_laden = max(0.0, $pBatKW - $sdlShareKW_laden); $evShareKW_entladen = max(0.0, $pBatKW - $sdlShareKW_entladen); - // Grenzen: individuell nach Reservezeit. - $underKWh = $sdlShareKW_entladen * $reserveH; - $upKWh = $capKWh - ($sdlShareKW_laden * $reserveH); + $sdlLowerKWh = $sdlShareKW_entladen * $reserveH; + $sdlUpperKWh = $sdlShareKW_laden * $reserveH; - $underKWh = max(0.0, min($capKWh, $underKWh)); - $upKWh = max(0.0, min($capKWh, $upKWh)); + $underKWh = $minPhysicalKWh + $sdlLowerKWh; + $upKWh = $capKWh - $sdlUpperKWh; + + $underKWh = max($minPhysicalKWh, min($capKWh, $underKWh)); + $upKWh = max($minPhysicalKWh, min($capKWh, $upKWh)); // Falls Reserve zu groß ist, EV-Fenster sauber auf 0 setzen. if ($upKWh < $underKWh) { @@ -253,10 +257,8 @@ class Bat_EV_SDL_V4 extends IPSModule $upKWh = $mid; } - $sdlLowerKWh = $underKWh; - $sdlUpperKWh = $capKWh - $upKWh; $SDL_kWh = max(0.0, $sdlLowerKWh + $sdlUpperKWh); - $EV_kWh = max(0.0, $capKWh - $SDL_kWh); + $EV_kWh = max(0.0, $upKWh - $underKWh); $realSocPct = $this->ReadSocPercent($socVarId); $realKWh = $capKWh * $realSocPct / 100.0; @@ -268,6 +270,11 @@ class Bat_EV_SDL_V4 extends IPSModule "capKWh" => $capKWh, "pBatW" => $pBatW, + "minPhysicalSocPct" => $minPhysicalSocPct, + "minPhysicalKWh" => $minPhysicalKWh, + "sdlLowerKWh" => $sdlLowerKWh, + "sdlUpperKWh" => $sdlUpperKWh, + "underKWh" => $underKWh, "upKWh" => $upKWh, "SDL_kWh_total" => $SDL_kWh,