From 17946b3a0280b79f6ff8a05b193e4e019a58f0a5 Mon Sep 17 00:00:00 2001 From: "belevo\\mh" Date: Fri, 4 Sep 2026 10:18:04 +0200 Subject: [PATCH] no message --- Bat_EV_SDL_V4/module.php | 78 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) diff --git a/Bat_EV_SDL_V4/module.php b/Bat_EV_SDL_V4/module.php index 58de5de..5f85223 100644 --- a/Bat_EV_SDL_V4/module.php +++ b/Bat_EV_SDL_V4/module.php @@ -708,6 +708,82 @@ class Bat_EV_SDL_V4 extends IPSModule * Batterie liefert real nur 3600 W. * Dann wird EV = 2700 W, SDL = 900 W angenommen. */ + + private function UpdateActualPowerSplit(float $pEvW, float $pSdlW): void +{ + $totalPowerIst = $this->GetTotalBatteryPowerIstW(); + + $eps = 0.01; + + $sumSoll = $pEvW + $pSdlW; + $sumAbsSoll = abs($pEvW) + abs($pSdlW); + + /* + * Die Abweichung zwischen realer Batterieleistung und + * Netto-Soll proportional auf EV und SDL verteilen. + * + * Funktioniert auch bei: + * EV = +42000 W + * SDL = -40000 W + */ + if ($sumAbsSoll > $eps) { + $abweichungW = $totalPowerIst - $sumSoll; + + $evAnteil = abs($pEvW) / $sumAbsSoll; + $sdlAnteil = abs($pSdlW) / $sumAbsSoll; + + $rawEV = $pEvW + ($abweichungW * $evAnteil); + $rawSDL = $pSdlW + ($abweichungW * $sdlAnteil); + } else { + $rawEV = (float)$this->GetBufferSafe("CUR_EV_VAL"); + $rawSDL = (float)$this->GetBufferSafe("CUR_SDL_VAL"); + } + + $filterAktiv = $this->ReadPropertyBoolean("FilterAktiv"); + + if ($filterAktiv) { + $tolPct = max( + 0.0, + (float)$this->ReadPropertyFloat("FilterTolerancePct") + ) / 100.0; + + $needHits = max( + 1, + (int)$this->ReadPropertyInteger("FilterHits") + ); + + $fEV = $this->FilterCurrent( + "EV", + $rawEV, + $pEvW, + abs($pEvW) * $tolPct, + $needHits + ); + + $fSDL = $this->FilterCurrent( + "SDL", + $rawSDL, + $pSdlW, + abs($pSdlW) * $tolPct, + $needHits + ); + } else { + $fEV = $rawEV; + $fSDL = $rawSDL; + $this->ClearCurrentFilterBuffers(); + } + + $this->SetIdentValue( + "Aktuelle_Leistung_EV", + (float)$fEV + ); + + $this->SetIdentValue( + "Aktuelle_Leistung_SDL", + (float)$fSDL + ); +} + /* private function UpdateActualPowerSplit(float $pEvW, float $pSdlW): void { $totalPowerIst = $this->GetTotalBatteryPowerIstW(); @@ -740,7 +816,7 @@ class Bat_EV_SDL_V4 extends IPSModule $this->SetIdentValue("Aktuelle_Leistung_EV", (float)$fEV); $this->SetIdentValue("Aktuelle_Leistung_SDL", (float)$fSDL); - } + }*/ /** * Filtert die rückgerechnete Istleistung. *