diff --git a/Bat_EV_SDL_V3_Beta/module.php b/Bat_EV_SDL_V3_Beta/module.php index 6f96447..12cd02d 100644 --- a/Bat_EV_SDL_V3_Beta/module.php +++ b/Bat_EV_SDL_V3_Beta/module.php @@ -26,6 +26,7 @@ class Bat_EV_SDL_V3_Beta extends IPSModule $this->RegisterVariableFloat("P_SDL_entladen", "P SDL entladen max (W)", "", 22); $this->RegisterVariableInteger("P_EV_laden", "P EV laden max (W)", "", 31); $this->RegisterVariableInteger("P_EV_entladen", "P EV entladen max (W)", "", 32); + $this->RegisterVariableFloat("SDL_Start_Pos", "SDL Start SoC (%)", "", 35); // Debug $this->RegisterVariableString("CalcJSON", "Berechnung (JSON)", "", 99); // Timer: wichtig -> Prefix muss passen @@ -127,13 +128,30 @@ class Bat_EV_SDL_V3_Beta extends IPSModule $EV_kWh_ges = 0.0; $totalCapKWh = 0.0; - // SDL-Gesamtkapazität aus Cache vorab berechnen - $SDL_kWh_ges_cfg = 0.0; + + + $SDL_kWh_ges_cfg = 0.0; + $SDL_start_kWh_cfg = 0.0; foreach ($cache["bats"] as $bc) { - $SDL_kWh_ges_cfg += (float)($bc["SDL_kWh_total"] ?? 0.0); + $SDL_kWh_ges_cfg += (float)($bc["SDL_kWh_total"] ?? 0.0); + $SDL_start_kWh_cfg += (float)($bc["underKWh"] ?? 0.0); } + $startPct = ($SDL_kWh_ges_cfg > 0.0) + ? ($SDL_start_kWh_cfg / $SDL_kWh_ges_cfg * 100.0) + : 0.0; + + $startPct = max(0.0, min(100.0, $startPct)); + + $this->SetIdentValue("SDL_Start_Pos", round($startPct, 3)); + + + + + + + // aktueller virtueller SDL-Stand $sdlVirtPct = ($SDL_kWh_ges_cfg > 0.0) ? ($Esdl_kWh / $SDL_kWh_ges_cfg * 100.0)