no message
This commit is contained in:
@@ -38,6 +38,7 @@ class Bat_EV_SDL_V3_Beta extends IPSModule
|
|||||||
$this->SetTimerInterval("UpdateTimer", ($intervalSec > 0) ? $intervalSec * 1000 : 0);
|
$this->SetTimerInterval("UpdateTimer", ($intervalSec > 0) ? $intervalSec * 1000 : 0);
|
||||||
// Cache neu bauen (force)
|
// Cache neu bauen (force)
|
||||||
$this->BuildBatteryCache(true);
|
$this->BuildBatteryCache(true);
|
||||||
|
$this->ResetSDLTo50Percent();
|
||||||
$this->Update();
|
$this->Update();
|
||||||
}
|
}
|
||||||
public function RequestAction($Ident, $Value)
|
public function RequestAction($Ident, $Value)
|
||||||
@@ -89,12 +90,6 @@ class Bat_EV_SDL_V3_Beta extends IPSModule
|
|||||||
$Esdl_kWh = 0.0;
|
$Esdl_kWh = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SDL-Gesamtkapazität aus Cache vorab berechnen
|
|
||||||
$SDL_kWh_ges_cfg = 0.0;
|
|
||||||
|
|
||||||
foreach ($cache["bats"] as $bc) {
|
|
||||||
$SDL_kWh_ges_cfg += (float)($bc["SDL_kWh_total"] ?? 0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Beim allerersten Lauf NICHT mit 0 % starten,
|
// Beim allerersten Lauf NICHT mit 0 % starten,
|
||||||
// sondern virtuell auf Mitte setzen.
|
// sondern virtuell auf Mitte setzen.
|
||||||
@@ -362,35 +357,26 @@ class Bat_EV_SDL_V3_Beta extends IPSModule
|
|||||||
$intHash = $cacheHash;
|
$intHash = $cacheHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wenn Hash gewechselt hat => Definition von SDL-Fenster hat sich geändert
|
if ($cacheHash !== "" && $cacheHash !== $intHash) {
|
||||||
if ($cacheHash !== "" && $cacheHash !== $intHash) {
|
|
||||||
|
|
||||||
// Physikalisches Resync: passt sofort zu den aktuellen SoCs / neuem SDL-Fenster
|
// Bei Cache-/SDL-Leistungsänderung wieder auf 50 %
|
||||||
$Esdl_kWh = $real_kWh_sdl_ges;
|
$Esdl_kWh = $SDL_kWh_ges_cfg * 0.5;
|
||||||
|
|
||||||
// Optional: Zeitstempel neu setzen, damit dt nicht "nachläuft"
|
$lastTs = $now;
|
||||||
$lastTs = $now;
|
$this->SetBuffer("Int_LastTs", (string)$now);
|
||||||
$this->SetBuffer("Int_LastTs", (string)$now);
|
|
||||||
|
|
||||||
// Hash aktualisieren
|
$this->SetBuffer("Int_CFG_HASH", $cacheHash);
|
||||||
$this->SetBuffer("Int_CFG_HASH", $cacheHash);
|
$this->SetBuffer("Int_Init_SDL", "1");
|
||||||
|
|
||||||
// Optional: Init-Flag setzen (damit klar ist: Konto ist gültig)
|
$this->SendDebug("SDL", "Reset wegen CacheHash-Change auf 50%: Esdl_kWh=" . round($Esdl_kWh, 3), 0);
|
||||||
$this->SetBuffer("Int_Init_SDL", "1");
|
}
|
||||||
|
|
||||||
$this->SendDebug("SDL", "Resync wegen CacheHash-Change: Esdl_kWh=" . round($Esdl_kWh, 3), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Init SDL-Konto einmalig auf physikalische Referenz (nur beim ersten Lauf)
|
|
||||||
if ($this->GetBufferSafe("Int_Init_SDL") !== "1") {
|
|
||||||
$Esdl_kWh = $real_kWh_sdl_ges;
|
|
||||||
$this->SetBuffer("Int_Init_SDL", "1");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Init SDL-Konto einmalig auf physikalische Referenz (nur beim ersten Lauf)
|
// Init SDL-Konto einmalig auf physikalische Referenz (nur beim ersten Lauf)
|
||||||
if ($this->GetBufferSafe("Int_Init_SDL") !== "1") {
|
if ($this->GetBufferSafe("Int_Init_SDL") !== "1") {
|
||||||
$Esdl_kWh = $real_kWh_sdl_ges;
|
$Esdl_kWh = $SDL_kWh_ges_cfg * 0.5;
|
||||||
$this->SetBuffer("Int_Init_SDL", "1");
|
$this->SetBuffer("Int_Init_SDL", "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -991,5 +977,34 @@ private function WriteByVendorRegistersSingleMode(string $typ, array $cfg, float
|
|||||||
// $setInt($varMode, 0);
|
// $setInt($varMode, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function ResetSDLTo50Percent(): void
|
||||||
|
{
|
||||||
|
$cache = json_decode($this->GetBufferSafe("BatCacheJSON"), true);
|
||||||
|
|
||||||
|
if (!is_array($cache) || empty($cache["bats"])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sdlKWhTotal = 0.0;
|
||||||
|
|
||||||
|
foreach ($cache["bats"] as $bat) {
|
||||||
|
$sdlKWhTotal += (float)($bat["SDL_kWh_total"] ?? 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($sdlKWhTotal <= 0.0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->SetBuffer("Int_E_SDL_kWh", (string)($sdlKWhTotal * 0.5));
|
||||||
|
$this->SetBuffer("Int_Init_SDL", "1");
|
||||||
|
$this->SetBuffer("Int_LastTs", (string)microtime(true));
|
||||||
|
|
||||||
|
// wichtig: Hash merken, damit direkt danach kein Resync kommt
|
||||||
|
$cacheHash = (string)$this->GetBufferSafe("BatCacheHash");
|
||||||
|
if ($cacheHash !== "") {
|
||||||
|
$this->SetBuffer("Int_CFG_HASH", $cacheHash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user