no message
This commit is contained in:
@@ -193,24 +193,74 @@ private function CalculateAllPowerCosts($powerMeters, $tariffs, $from, $to)
|
|||||||
$slot = [];
|
$slot = [];
|
||||||
|
|
||||||
// 2a. Deltas je Zähler des Users
|
// 2a. Deltas je Zähler des Users
|
||||||
|
IPS_LogMessage("ABR", "---- DELTA-Berechnung für Intervall " . date("H:i", $ts) . " - " . date("H:i", $slotEnd) . " ----");
|
||||||
|
|
||||||
foreach ($meters as $name => $mm) {
|
foreach ($meters as $name => $mm) {
|
||||||
|
|
||||||
|
IPS_LogMessage("ABR", " Prüfe Zähler: $name");
|
||||||
|
IPS_LogMessage("ABR", " ImportVar=" . ($mm['importVar'] ?? 'NULL'));
|
||||||
|
IPS_LogMessage("ABR", " ExportVar=" . ($mm['exportVar'] ?? 'NULL'));
|
||||||
|
|
||||||
$impDelta = 0.0;
|
$impDelta = 0.0;
|
||||||
$expDelta = 0.0;
|
$expDelta = 0.0;
|
||||||
|
|
||||||
if (!empty($mm['importVar']) && IPS_VariableExists((int)$mm['importVar'])) {
|
// --- IMPORT ---
|
||||||
$impDelta = $this->getDeltaFromArchive((int)$mm['importVar'], $ts, $slotEnd);
|
if (!empty($mm['importVar'])) {
|
||||||
|
|
||||||
|
$varId = (int)$mm['importVar'];
|
||||||
|
|
||||||
|
if (!IPS_VariableExists($varId)) {
|
||||||
|
IPS_LogMessage("ABR", " ⚠ ImportVar $varId existiert NICHT!");
|
||||||
|
} else {
|
||||||
|
|
||||||
|
IPS_LogMessage("ABR", " → ImportDelta: getDeltaFromArchive($varId, $ts, $slotEnd)");
|
||||||
|
|
||||||
|
$impDelta = $this->getDeltaFromArchive($varId, $ts, $slotEnd);
|
||||||
|
|
||||||
|
IPS_LogMessage("ABR", " Ergebnis ImportDelta=$impDelta");
|
||||||
}
|
}
|
||||||
if (!empty($mm['exportVar']) && IPS_VariableExists((int)$mm['exportVar'])) {
|
|
||||||
$expDelta = $this->getDeltaFromArchive((int)$mm['exportVar'], $ts, $slotEnd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- EXPORT ---
|
||||||
|
if (!empty($mm['exportVar'])) {
|
||||||
|
|
||||||
|
$varId = (int)$mm['exportVar'];
|
||||||
|
|
||||||
|
if (!IPS_VariableExists($varId)) {
|
||||||
|
IPS_LogMessage("ABR", " ⚠ ExportVar $varId existiert NICHT!");
|
||||||
|
} else {
|
||||||
|
|
||||||
|
IPS_LogMessage("ABR", " → ExportDelta: getDeltaFromArchive($varId, $ts, $slotEnd)");
|
||||||
|
|
||||||
|
$expDelta = $this->getDeltaFromArchive($varId, $ts, $slotEnd);
|
||||||
|
|
||||||
|
IPS_LogMessage("ABR", " Ergebnis ExportDelta=$expDelta");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Ergebnis für diesen Zähler ---
|
||||||
|
IPS_LogMessage("ABR", " → Zähler $name: impDelta=$impDelta | expDelta=$expDelta");
|
||||||
|
|
||||||
if ($impDelta > 0.0 || $expDelta > 0.0) {
|
if ($impDelta > 0.0 || $expDelta > 0.0) {
|
||||||
$slot[$name] = ['imp' => $impDelta, 'exp' => $expDelta];
|
|
||||||
|
IPS_LogMessage("ABR", " ✔ Delta > 0 → wird für Intervall übernommen");
|
||||||
|
|
||||||
|
$slot[$name] = [
|
||||||
|
'imp' => $impDelta,
|
||||||
|
'exp' => $expDelta
|
||||||
|
];
|
||||||
|
|
||||||
$impTotal += $impDelta;
|
$impTotal += $impDelta;
|
||||||
$expTotal += $expDelta;
|
$expTotal += $expDelta;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
IPS_LogMessage("ABR", " ✘ Delta = 0 → wird ignoriert");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IPS_LogMessage("ABR", "---- Ende DELTA-Berechnung: impTotal=$impTotal | expTotal=$expTotal ----");
|
||||||
|
|
||||||
|
|
||||||
if ($impTotal == 0.0 && $expTotal == 0.0) {
|
if ($impTotal == 0.0 && $expTotal == 0.0) {
|
||||||
continue; // für diesen User in diesem Intervall nichts passiert
|
continue; // für diesen User in diesem Intervall nichts passiert
|
||||||
}
|
}
|
||||||
@@ -460,6 +510,7 @@ private function GetCalculatedPowerCosts($userId)
|
|||||||
|
|
||||||
return $closest ?? floatval(GetValue($varId));
|
return $closest ?? floatval(GetValue($varId));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getDeltaFromArchive(int $varId, int $tStart, int $tEnd): float
|
private function getDeltaFromArchive(int $varId, int $tStart, int $tEnd): float
|
||||||
{
|
{
|
||||||
$startValue = $this->GetValueAt($varId, $tStart, false); // Wert davor/zu Beginn
|
$startValue = $this->GetValueAt($varId, $tStart, false); // Wert davor/zu Beginn
|
||||||
|
|||||||
Reference in New Issue
Block a user