fix: update ProjectIdPortal handling in CounterServer module; increment version to 1.1 and reset build number in library.json
This commit is contained in:
@@ -52,7 +52,9 @@ class CounterServer extends IPSModule
|
|||||||
|
|
||||||
$timestamp = $payload['timestamp'] ?? date('Y-m-d H:i:s');
|
$timestamp = $payload['timestamp'] ?? date('Y-m-d H:i:s');
|
||||||
$counters = $payload['counters'] ?? [];
|
$counters = $payload['counters'] ?? [];
|
||||||
|
$projectId = $this->ReadPropertyInteger('ProjectIdPortal');
|
||||||
|
|
||||||
|
if ($projectId !== -1) {
|
||||||
foreach ($counters as $c) {
|
foreach ($counters as $c) {
|
||||||
|
|
||||||
$counterId = $c['id'] ?? '';
|
$counterId = $c['id'] ?? '';
|
||||||
@@ -62,9 +64,7 @@ class CounterServer extends IPSModule
|
|||||||
$type = $c['type'] ?? 'other';
|
$type = $c['type'] ?? 'other';
|
||||||
$unit = $c['unit'] ?? 'kWh';
|
$unit = $c['unit'] ?? 'kWh';
|
||||||
|
|
||||||
$projectId = $this->ReadPropertyInteger('ProjectIdPortal');
|
|
||||||
|
|
||||||
if ($projectId !== -1) {
|
|
||||||
// ---------- UPSERT ----------
|
// ---------- UPSERT ----------
|
||||||
$sql = "
|
$sql = "
|
||||||
INSERT INTO meter_devices
|
INSERT INTO meter_devices
|
||||||
@@ -72,7 +72,7 @@ class CounterServer extends IPSModule
|
|||||||
VALUES
|
VALUES
|
||||||
(
|
(
|
||||||
" . $this->esc($projectId) . "',
|
" . $this->esc($projectId) . "',
|
||||||
'" . $this->esc($clientId . '_' . $counterId) . "',
|
'" . $this->esc(base64_encode($projectId.$clientId . '_' . $counterId)) . "',
|
||||||
'" . $this->esc($counterId) . "',
|
'" . $this->esc($counterId) . "',
|
||||||
'" . $this->esc($clientId) . "',
|
'" . $this->esc($clientId) . "',
|
||||||
'" . $this->esc($clientName) . "',
|
'" . $this->esc($clientName) . "',
|
||||||
@@ -89,13 +89,12 @@ class CounterServer extends IPSModule
|
|||||||
|
|
||||||
|
|
||||||
MySQL_ExecuteSimple($sqlId, $sql);
|
MySQL_ExecuteSimple($sqlId, $sql);
|
||||||
}
|
|
||||||
|
|
||||||
// ---------- GET meter_id ----------
|
// ---------- GET meter_id ----------
|
||||||
$sqlGet = "
|
$sqlGet = "
|
||||||
SELECT id FROM meter_devices
|
SELECT id FROM meter_devices
|
||||||
WHERE client_id = '" . $this->esc($clientId) . "'
|
WHERE meter_uuid = '" . $this->esc(base64_encode($projectId.$clientId . '_' . $counterId)) . "'
|
||||||
AND counter_id = '" . $this->esc($counterId) . "'
|
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
";
|
";
|
||||||
|
|
||||||
@@ -141,6 +140,9 @@ class CounterServer extends IPSModule
|
|||||||
|
|
||||||
MySQL_ExecuteSimple($sqlId, $sqlInsert);
|
MySQL_ExecuteSimple($sqlId, $sqlInsert);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
IPS_LogMessage('CounterTable', 'Keine Project-ID für Portal angegeben.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function f($arr, $key)
|
private function f($arr, $key)
|
||||||
|
|||||||
+2
-2
@@ -7,7 +7,7 @@
|
|||||||
"version": "6.0",
|
"version": "6.0",
|
||||||
"date": 1491343200
|
"date": 1491343200
|
||||||
},
|
},
|
||||||
"version": "1.0",
|
"version": "1.1",
|
||||||
"build": 8,
|
"build": 0,
|
||||||
"date": 0
|
"date": 0
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user