diff --git a/Bat_EV_SDL_V4/module.php b/Bat_EV_SDL_V4/module.php index 3d06808..b39a86f 100644 --- a/Bat_EV_SDL_V4/module.php +++ b/Bat_EV_SDL_V4/module.php @@ -416,8 +416,14 @@ class Bat_EV_SDL_V4 extends IPSModule $sdlStartPct = max(0.0, min(100.0, (float)$this->ReadPropertyFloat("SDL_Start_Pos_Config"))); $evStartPct = max(0.0, min(100.0, (float)$this->ReadPropertyFloat("EV_Start_Pos_Config"))); - $eSDL = ($sdlTotal > 0.0) ? $sdlTotal * $sdlStartPct / 100.0 : 0.0; - $eEV = ($evTotal > 0.0) ? $evTotal * $evStartPct / 100.0 : 0.0; + $lastSdlPct = (float)GetValue($this->GetIDForIdent("SDL_Pos")); + $lastEvPct = (float)GetValue($this->GetIDForIdent("SoC_EV")); + + $lastSdlPct = max(0.0, min(100.0, $lastSdlPct)); + $lastEvPct = max(0.0, min(100.0, $lastEvPct)); + + $eSDL = ($sdlTotal > 0.0) ? $sdlTotal * $lastSdlPct / 100.0 : 0.0; + $eEV = ($evTotal > 0.0) ? $evTotal * $lastEvPct / 100.0 : 0.0; $this->SetBuffer("Int_E_SDL_kWh", (string)$eSDL); $this->SetBuffer("Int_E_EV_kWh", (string)$eEV);