no message

This commit is contained in:
mh
2026-08-19 10:07:01 +02:00
parent d19fe26299
commit 6dd38afdc2
+24 -4
View File
@@ -87,10 +87,17 @@ class Energy_Pie extends IPSModule
$dbgProd = [];
$dbgFeed = [];
$dbgGrid = [];
$prod = $this->readDelta($this->ReadPropertyInteger('VarProduction'), $tStart, $tEnd, $dbgProd);
$feed = $this->readDelta($this->ReadPropertyInteger('VarFeedIn'), $tStart, $tEnd, $dbgFeed);
$grid = $this->readDelta($this->ReadPropertyInteger('VarGrid'), $tStart, $tEnd, $dbgGrid);
$hasData = (($dbgProd['inRange'] ?? 0) > 0) || (($dbgFeed['inRange'] ?? 0) > 0) || (($dbgGrid['inRange'] ?? 0) > 0);
if ($range === 'total') {
$prod = $this->readCurrentValue($this->ReadPropertyInteger('VarProduction'), $dbgProd);
$feed = $this->readCurrentValue($this->ReadPropertyInteger('VarFeedIn'), $dbgFeed);
$grid = $this->readCurrentValue($this->ReadPropertyInteger('VarGrid'), $dbgGrid);
$hasData = ($dbgProd['available'] ?? false) || ($dbgFeed['available'] ?? false) || ($dbgGrid['available'] ?? false);
} else {
$prod = $this->readDelta($this->ReadPropertyInteger('VarProduction'), $tStart, $tEnd, $dbgProd);
$feed = $this->readDelta($this->ReadPropertyInteger('VarFeedIn'), $tStart, $tEnd, $dbgFeed);
$grid = $this->readDelta($this->ReadPropertyInteger('VarGrid'), $tStart, $tEnd, $dbgGrid);
$hasData = (($dbgProd['inRange'] ?? 0) > 0) || (($dbgFeed['inRange'] ?? 0) > 0) || (($dbgGrid['inRange'] ?? 0) > 0);
}
$lastLogTs = 0;
if (!$hasData && $range !== 'total') {
$lastLogTs = max(
@@ -160,6 +167,19 @@ class Energy_Pie extends IPSModule
$this->RecalculateAndPush();
return $this->GetVisualizationTile();
}
private function readCurrentValue(int $varId, array &$dbg): float
{
$dbg = ['varId' => $varId, 'available' => false];
if ($varId <= 0 || !IPS_VariableExists($varId)) {
return 0.0;
}
$value = GetValue($varId);
if (!is_numeric($value)) {
return 0.0;
}
$dbg['available'] = true;
return max(0.0, (float)$value);
}
private function readDelta(int $varId, int $tStart, int $tEnd, array &$dbg): float
{
$dbg = [