no message
This commit is contained in:
@@ -635,24 +635,34 @@ foreach ($meters as $name => $mm) {
|
|||||||
return $closest ?? (float)GetValue($varId);
|
return $closest ?? (float)GetValue($varId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getDeltaFromArchive(int $varId, int $tStart, int $tEnd): float
|
private function getDeltaFromArchive(int $varId, int $tStart, int $tEnd): float
|
||||||
{
|
{
|
||||||
// Beide Werte: immer letzter geloggter Wert VOR/GENAU zum Zeitpunkt
|
// Werte holen
|
||||||
$startValue = $this->GetValueAt($varId, $tStart, false);
|
$startValue = $this->GetValueAt($varId, $tStart, false);
|
||||||
$endValue = $this->GetValueAt($varId, $tEnd, false);
|
$endValue = $this->GetValueAt($varId, $tEnd, false);
|
||||||
|
|
||||||
if ($startValue === null || $endValue === null) {
|
// --- Logging ---
|
||||||
return 0.0;
|
IPS_LogMessage("KostenModul", "getDeltaFromArchive(varId=$varId)");
|
||||||
}
|
IPS_LogMessage("KostenModul", " Startzeit: " . date('Y-m-d H:i:s', $tStart) . " | Startwert: " . var_export($startValue, true));
|
||||||
|
IPS_LogMessage("KostenModul", " Endzeit: " . date('Y-m-d H:i:s', $tEnd) . " | Endwert: " . var_export($endValue, true));
|
||||||
|
|
||||||
$diff = $endValue - $startValue;
|
if ($startValue === null || $endValue === null) {
|
||||||
if ($diff < 0) {
|
IPS_LogMessage("KostenModul", " -> Einer der Werte ist NULL, Delta = 0.0");
|
||||||
// Sicherheitsnetz bei Zähler-Reset
|
return 0.0;
|
||||||
$diff = 0.0;
|
|
||||||
}
|
|
||||||
return (float)$diff;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delta berechnen
|
||||||
|
$diff = $endValue - $startValue;
|
||||||
|
|
||||||
|
if ($diff < 0) {
|
||||||
|
IPS_LogMessage("KostenModul", " WARNUNG: Negatives Delta erkannt! Zähler wurde vermutlich zurückgesetzt. Delta wird auf 0 gesetzt.");
|
||||||
|
$diff = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
IPS_LogMessage("KostenModul", " Delta = $diff");
|
||||||
|
return (float)$diff;
|
||||||
|
}
|
||||||
|
|
||||||
private function toUnixTs($val, $endOfDay = false)
|
private function toUnixTs($val, $endOfDay = false)
|
||||||
{
|
{
|
||||||
if (is_int($val)) {
|
if (is_int($val)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user