no message
This commit is contained in:
@@ -195,70 +195,94 @@ private function CalculateAllPowerCosts($powerMeters, $tariffs, $from, $to)
|
||||
// 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) {
|
||||
// 2a. Deltas je Zähler des Users
|
||||
IPS_LogMessage("ABR", "---- BEGIN USER-METER DELTA BLOCK ----");
|
||||
IPS_LogMessage("ABR", "Intervall: " . date("d.m.Y H:i", $ts) . " - " . date("d.m.Y H:i", $slotEnd));
|
||||
|
||||
IPS_LogMessage("ABR", " Prüfe Zähler: $name");
|
||||
IPS_LogMessage("ABR", " ImportVar=" . ($mm['importVar'] ?? 'NULL'));
|
||||
IPS_LogMessage("ABR", " ExportVar=" . ($mm['exportVar'] ?? 'NULL'));
|
||||
foreach ($meters as $name => $mm) {
|
||||
|
||||
IPS_LogMessage("ABR", "Meter: $name");
|
||||
IPS_LogMessage("ABR", " RAW mm JSON: " . json_encode($mm));
|
||||
|
||||
$impDelta = 0.0;
|
||||
$expDelta = 0.0;
|
||||
|
||||
// --- IMPORT ---
|
||||
// --------------------
|
||||
// IMPORT
|
||||
// --------------------
|
||||
if (isset($mm['importVar'])) {
|
||||
IPS_LogMessage("ABR", " importVar found: " . $mm['importVar']);
|
||||
} else {
|
||||
IPS_LogMessage("ABR", " ⚠ importVar NOT FOUND IN ARRAY!");
|
||||
}
|
||||
|
||||
if (!empty($mm['importVar'])) {
|
||||
|
||||
$varId = (int)$mm['importVar'];
|
||||
IPS_LogMessage("ABR", " Checking IMPORT variable ID = $varId");
|
||||
|
||||
if (!IPS_VariableExists($varId)) {
|
||||
IPS_LogMessage("ABR", " ⚠ ImportVar $varId existiert NICHT!");
|
||||
} else {
|
||||
|
||||
IPS_LogMessage("ABR", " → ImportDelta: getDeltaFromArchive($varId, $ts, $slotEnd)");
|
||||
if (IPS_VariableExists($varId)) {
|
||||
IPS_LogMessage("ABR", " → IMPORT variable EXISTS");
|
||||
|
||||
$impDelta = $this->getDeltaFromArchive($varId, $ts, $slotEnd);
|
||||
|
||||
IPS_LogMessage("ABR", " Ergebnis ImportDelta=$impDelta");
|
||||
IPS_LogMessage("ABR", " → IMPORT DELTA = $impDelta");
|
||||
} else {
|
||||
IPS_LogMessage("ABR", " ⚠ IMPORT variable DOES NOT EXIST in IPS!");
|
||||
}
|
||||
} else {
|
||||
IPS_LogMessage("ABR", " ⚠ importVar IS EMPTY OR NULL");
|
||||
}
|
||||
|
||||
// --------------------
|
||||
// EXPORT
|
||||
// --------------------
|
||||
if (isset($mm['exportVar'])) {
|
||||
IPS_LogMessage("ABR", " exportVar found: " . $mm['exportVar']);
|
||||
} else {
|
||||
IPS_LogMessage("ABR", " ⚠ exportVar NOT FOUND IN ARRAY!");
|
||||
}
|
||||
|
||||
// --- EXPORT ---
|
||||
if (!empty($mm['exportVar'])) {
|
||||
|
||||
$varId = (int)$mm['exportVar'];
|
||||
IPS_LogMessage("ABR", " Checking EXPORT variable ID = $varId");
|
||||
|
||||
if (!IPS_VariableExists($varId)) {
|
||||
IPS_LogMessage("ABR", " ⚠ ExportVar $varId existiert NICHT!");
|
||||
} else {
|
||||
|
||||
IPS_LogMessage("ABR", " → ExportDelta: getDeltaFromArchive($varId, $ts, $slotEnd)");
|
||||
if (IPS_VariableExists($varId)) {
|
||||
IPS_LogMessage("ABR", " → EXPORT variable EXISTS");
|
||||
|
||||
$expDelta = $this->getDeltaFromArchive($varId, $ts, $slotEnd);
|
||||
|
||||
IPS_LogMessage("ABR", " Ergebnis ExportDelta=$expDelta");
|
||||
IPS_LogMessage("ABR", " → EXPORT DELTA = $expDelta");
|
||||
} else {
|
||||
IPS_LogMessage("ABR", " ⚠ EXPORT variable DOES NOT EXIST in IPS!");
|
||||
}
|
||||
} else {
|
||||
IPS_LogMessage("ABR", " ⚠ exportVar IS EMPTY OR NULL");
|
||||
}
|
||||
|
||||
// --- Ergebnis für diesen Zähler ---
|
||||
IPS_LogMessage("ABR", " → Zähler $name: impDelta=$impDelta | expDelta=$expDelta");
|
||||
|
||||
// --------------------
|
||||
// DELTAS WURDEN GEFUNDEN?
|
||||
// --------------------
|
||||
if ($impDelta > 0.0 || $expDelta > 0.0) {
|
||||
|
||||
IPS_LogMessage("ABR", " ✔ Delta > 0 → wird für Intervall übernommen");
|
||||
IPS_LogMessage("ABR", " ✔ VALID DELTAS → imp=$impDelta exp=$expDelta");
|
||||
|
||||
$slot[$name] = [
|
||||
'imp' => $impDelta,
|
||||
'exp' => $expDelta
|
||||
];
|
||||
$slot[$name] = ['imp' => $impDelta, 'exp' => $expDelta];
|
||||
|
||||
$impTotal += $impDelta;
|
||||
$expTotal += $expDelta;
|
||||
|
||||
} else {
|
||||
IPS_LogMessage("ABR", " ✘ Delta = 0 → wird ignoriert");
|
||||
}
|
||||
|
||||
IPS_LogMessage("ABR", " ⚠ NO DELTA FOUND FOR THIS METER (imp=0 exp=0)");
|
||||
}
|
||||
|
||||
IPS_LogMessage("ABR", "---- Ende DELTA-Berechnung: impTotal=$impTotal | expTotal=$expTotal ----");
|
||||
IPS_LogMessage("ABR", "-------------------------------------------");
|
||||
}
|
||||
|
||||
IPS_LogMessage("ABR", "---- END USER-METER DELTA BLOCK ----");
|
||||
IPS_LogMessage("ABR", "Intervall SUMME: impTotal=$impTotal | expTotal=$expTotal");
|
||||
|
||||
|
||||
if ($impTotal == 0.0 && $expTotal == 0.0) {
|
||||
|
||||
Reference in New Issue
Block a user