no message

This commit is contained in:
belevo\mh
2026-04-21 10:37:54 +02:00
parent a338d5fbc2
commit 6037ade2cc
2 changed files with 26 additions and 13 deletions
+3 -3
View File
@@ -104,9 +104,9 @@
"type": "NumberSpinner",
"name": "UpdateInterval",
"caption": "Neuberechnung alle",
"suffix": "Sekunden",
"minimum": 0,
"maximum": 86400
"suffix": "Miliskeunden",
"minimum": 200,
"maximum": 100000
}
]
}
+23 -10
View File
@@ -13,7 +13,7 @@ class Bat_EV_SDL_V3_Beta extends IPSModule
//$this->RegisterPropertyInteger("$upKWh + $underKWh)", 0);
$this->RegisterPropertyInteger("SDL_Leistung_Laden", 0);
$this->RegisterPropertyInteger("SDL_Leistung_Entladen", 0); // W
$this->RegisterPropertyInteger("UpdateInterval", 5); // Minuten
$this->RegisterPropertyInteger("UpdateInterval", 2000); // Minuten
// Status
$this->RegisterVariableBoolean("State", "Aktiv", "~Switch", 1);
@@ -45,7 +45,7 @@ class Bat_EV_SDL_V3_Beta extends IPSModule
parent::ApplyChanges();
$intervalSec = (int)$this->ReadPropertyInteger("UpdateInterval");
$this->SetTimerInterval("UpdateTimer", ($intervalSec > 0) ? $intervalSec * 1000 : 0);
$this->SetTimerInterval("UpdateTimer", ($intervalSec > 0) ? $intervalSec : 0);
// Cache neu bauen (force)
$this->BuildBatteryCache(true);
@@ -95,16 +95,21 @@ class Bat_EV_SDL_V3_Beta extends IPSModule
// Integrator: State laden
// =====================
// Optional für 2s besser: microtime(true) statt time() verwenden
$now = time();
$lastTs = (int)$this->GetBufferSafe("Int_LastTs");
$lastPEV = (float)$this->GetBufferSafe("Int_LastP_EV_W"); // W (+ laden, - entladen)
$lastPSDL = (float)$this->GetBufferSafe("Int_LastP_SDL_W"); // W (+ laden, - entladen)
// Millisekunden-genau: microtime(true) liefert Sekunden als Float
$now = microtime(true);
$Eev = (float)$this->GetBufferSafe("Int_E_EV_kWh"); // kWh-Konto EV
$Esdl = (float)$this->GetBufferSafe("Int_E_SDL_kWh"); // kWh-Konto SDL
// Timestamp als Float aus Buffer lesen (nicht int!)
$lastTs = (float)$this->GetBufferSafe("Int_LastTs");
if ($lastTs <= 0) {
// Leistungen / Konten wie gehabt
$lastPEV = (float)$this->GetBufferSafe("Int_LastP_EV_W"); // W (+ laden, - entladen)
$lastPSDL = (float)$this->GetBufferSafe("Int_LastP_SDL_W"); // W (+ laden, - entladen)
$Eev = (float)$this->GetBufferSafe("Int_E_EV_kWh"); // kWh-Konto EV
$Esdl = (float)$this->GetBufferSafe("Int_E_SDL_kWh"); // kWh-Konto SDL
if ($lastTs <= 0.0) {
$lastTs = $now;
$lastPEV = 0.0;
$lastPSDL = 0.0;
@@ -112,7 +117,15 @@ class Bat_EV_SDL_V3_Beta extends IPSModule
$Esdl = 0.0;
}
$dtH = ($now - $lastTs) / 3600.0; // Stunden
// dt in Sekunden (Float) und Stunden
$dtSec = $now - $lastTs;
if ($dtSec < 0.0) $dtSec = 0.0;
// Sicherheitskappe bei Aussetzern (optional: z.B. max 10s)
if ($dtSec > 10.0) $dtSec = 10.0;
$dtH = $dtSec / 3600.0;
if ($dtH < 0) $dtH = 0.0;
if ($dtH > 1.0) $dtH = 1.0; // Sicherheitskappe