diff --git a/Bat_EV_SDL_V3_Beta/form.json b/Bat_EV_SDL_V3_Beta/form.json index 9a50854..7b134c9 100644 --- a/Bat_EV_SDL_V3_Beta/form.json +++ b/Bat_EV_SDL_V3_Beta/form.json @@ -107,6 +107,11 @@ "suffix": "Sekunden", "minimum": 0, "maximum": 86400 + }, + { + "type": "CheckBox", + "name": "FilterAktiv", + "caption": "Aktuelle Leistung filtern" } ] } diff --git a/Bat_EV_SDL_V3_Beta/module.php b/Bat_EV_SDL_V3_Beta/module.php index 92f8b39..2c7c4e3 100644 --- a/Bat_EV_SDL_V3_Beta/module.php +++ b/Bat_EV_SDL_V3_Beta/module.php @@ -11,6 +11,7 @@ class Bat_EV_SDL_V3_Beta extends IPSModule $this->RegisterPropertyInteger("SDL_Leistung_Laden", 0); $this->RegisterPropertyInteger("SDL_Leistung_Entladen", 0); // W $this->RegisterPropertyInteger("UpdateInterval", 5); // Minuten + $this->RegisterPropertyBoolean("FilterAktiv", true); // Status $this->RegisterVariableBoolean("State", "Aktiv", "~Switch", 1); $this->EnableAction("State"); @@ -876,11 +877,28 @@ private function CalculateBatteryDistribution(float $pEvW, float $pSdlW): array $tolW_EV = abs($targetEV) * $tolPct; $tolW_SDL = abs($targetSDL) * $tolPct; - $fEV = $filterCurrent("EV", $rawEV, $targetEV, $tolW_EV, $needHits); - $fSDL = $filterCurrent("SDL", $rawSDL, $targetSDL, $tolW_SDL, $needHits); + $filterAktiv = $this->ReadPropertyBoolean("FilterAktiv"); + if ($filterAktiv) { + $fEV = $filterCurrent("EV", $rawEV, $targetEV, $tolW_EV, $needHits); + $fSDL = $filterCurrent("SDL", $rawSDL, $targetSDL, $tolW_SDL, $needHits); + } else { + // Filter deaktiviert: Rohwerte direkt übernehmen + $fEV = $rawEV; + $fSDL = $rawSDL; + + // Optional: alte Filter-Buffer zurücksetzen + $this->SetBuffer("CUR_EV_INIT", ""); + $this->SetBuffer("CUR_EV_VAL", ""); + $this->SetBuffer("CUR_EV_PEND", ""); + $this->SetBuffer("CUR_EV_HITS", ""); + + $this->SetBuffer("CUR_SDL_INIT", ""); + $this->SetBuffer("CUR_SDL_VAL", ""); + $this->SetBuffer("CUR_SDL_PEND", ""); + $this->SetBuffer("CUR_SDL_HITS", ""); + } - // Setzen (wichtig: SetIdentValue!) $this->SetIdentValue("Aktuelle_Leistung_EV", (float)$fEV); $this->SetIdentValue("Aktuelle_Leistung_SDL", (float)$fSDL);