no message
This commit is contained in:
+24
-4
@@ -87,10 +87,17 @@ class Energy_Pie extends IPSModule
|
|||||||
$dbgProd = [];
|
$dbgProd = [];
|
||||||
$dbgFeed = [];
|
$dbgFeed = [];
|
||||||
$dbgGrid = [];
|
$dbgGrid = [];
|
||||||
$prod = $this->readDelta($this->ReadPropertyInteger('VarProduction'), $tStart, $tEnd, $dbgProd);
|
if ($range === 'total') {
|
||||||
$feed = $this->readDelta($this->ReadPropertyInteger('VarFeedIn'), $tStart, $tEnd, $dbgFeed);
|
$prod = $this->readCurrentValue($this->ReadPropertyInteger('VarProduction'), $dbgProd);
|
||||||
$grid = $this->readDelta($this->ReadPropertyInteger('VarGrid'), $tStart, $tEnd, $dbgGrid);
|
$feed = $this->readCurrentValue($this->ReadPropertyInteger('VarFeedIn'), $dbgFeed);
|
||||||
$hasData = (($dbgProd['inRange'] ?? 0) > 0) || (($dbgFeed['inRange'] ?? 0) > 0) || (($dbgGrid['inRange'] ?? 0) > 0);
|
$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;
|
$lastLogTs = 0;
|
||||||
if (!$hasData && $range !== 'total') {
|
if (!$hasData && $range !== 'total') {
|
||||||
$lastLogTs = max(
|
$lastLogTs = max(
|
||||||
@@ -160,6 +167,19 @@ class Energy_Pie extends IPSModule
|
|||||||
$this->RecalculateAndPush();
|
$this->RecalculateAndPush();
|
||||||
return $this->GetVisualizationTile();
|
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
|
private function readDelta(int $varId, int $tStart, int $tEnd, array &$dbg): float
|
||||||
{
|
{
|
||||||
$dbg = [
|
$dbg = [
|
||||||
|
|||||||
Reference in New Issue
Block a user