no message
This commit is contained in:
@@ -173,6 +173,52 @@ private function RecalculateAndPush(): void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function readDelta($varId, $tStart, $tEnd)
|
||||||
|
{
|
||||||
|
if (!is_int($tStart)) {
|
||||||
|
$tStart = strtotime($tStart);
|
||||||
|
}
|
||||||
|
if (!is_int($tEnd)) {
|
||||||
|
$tEnd = strtotime($tEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
$archiveID = @IPS_GetInstanceListByModuleID('{43192F0B-135B-4CE7-A0A7-1475603F3060}')[0];
|
||||||
|
if (!$archiveID || !IPS_VariableExists($varId)) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$values = @AC_GetLoggedValues($archiveID, $varId, $tStart - 86400, $tEnd + 86400, 0);
|
||||||
|
if (empty($values)) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
usort($values, fn($a, $b) => (int)$a['TimeStamp'] <=> (int)$b['TimeStamp']);
|
||||||
|
$vStart = null;
|
||||||
|
$vEnd = null;
|
||||||
|
|
||||||
|
foreach ($values as $v) {
|
||||||
|
if ($v['TimeStamp'] <= $tStart) {
|
||||||
|
$vStart = $v['Value'];
|
||||||
|
}
|
||||||
|
if ($v['TimeStamp'] <= $tEnd) {
|
||||||
|
$vEnd = $v['Value'];
|
||||||
|
}
|
||||||
|
if ($v['TimeStamp'] > $tEnd) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($vStart === null) {
|
||||||
|
$vStart = (float)GetValue($varId);
|
||||||
|
}
|
||||||
|
if ($vEnd === null) {
|
||||||
|
$vEnd = (float)GetValue($varId);
|
||||||
|
}
|
||||||
|
|
||||||
|
$diff = $vEnd - $vStart;
|
||||||
|
return ($diff < 0) ? 0.0 : $diff;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Buttons for quick navigation.
|
* Buttons for quick navigation.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user