no message
This commit is contained in:
+31
-6
@@ -467,17 +467,42 @@ private function AddMeterToPDFRow($meter, $tariffs, $from, $to, $type)
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function readDelta($varId, $tStart, $tEnd)
|
private function readDelta($varId, $tStart, $tEnd)
|
||||||
{
|
{
|
||||||
// Start: erster Wert NACH/AB tStart
|
$archiveID = @IPS_GetInstanceListByModuleID('{43192F0B-135B-4CE7-A0A7-1475603F3060}')[0];
|
||||||
$vStart = $this->GetValueAt($varId, $tStart, true);
|
if (!$archiveID || !IPS_VariableExists($varId)) {
|
||||||
// Ende: letzter Wert VOR/ BIS tEnd
|
IPS_LogMessage('Abrechnung', "❌ Archiv oder Variable $varId nicht gefunden");
|
||||||
$vEnd = $this->GetValueAt($varId, $tEnd, false);
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$values = @AC_GetLoggedValues($archiveID, $varId, $tStart - 86400, $tEnd + 86400, 0);
|
||||||
|
if (empty($values)) {
|
||||||
|
IPS_LogMessage('Abrechnung', "⚠️ Keine Archivwerte für $varId im Zeitraum " . date('d.m.Y H:i', $tStart) . " – " . date('H:i', $tEnd));
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Startwert = letzter <= tStart
|
||||||
|
$vStart = null;
|
||||||
|
foreach ($values as $v) {
|
||||||
|
if ($v['TimeStamp'] <= $tStart) $vStart = $v['Value'];
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Endwert = letzter <= tEnd
|
||||||
|
$vEnd = null;
|
||||||
|
foreach ($values as $v) {
|
||||||
|
if ($v['TimeStamp'] <= $tEnd) $vEnd = $v['Value'];
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
|
||||||
if ($vStart === null || $vEnd === null) return 0.0;
|
if ($vStart === null || $vEnd === null) return 0.0;
|
||||||
return max(0.0, floatval($vEnd) - floatval($vStart));
|
|
||||||
|
$diff = max(0.0, floatval($vEnd) - floatval($vStart));
|
||||||
|
IPS_LogMessage('Abrechnung', sprintf(" ΔVar %d = %.4f (%.4f→%.4f)", $varId, $diff, $vStart, $vEnd));
|
||||||
|
return $diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function getTariffPriceAt($tariffs, $typeSynonyms, $ts)
|
private function getTariffPriceAt($tariffs, $typeSynonyms, $ts)
|
||||||
{
|
{
|
||||||
// passender unit_type
|
// passender unit_type
|
||||||
|
|||||||
Reference in New Issue
Block a user