fix: update ProjectIdPortal default value to -1 and adjust SQL insert statement; increment build number in library.json

This commit is contained in:
jhartworks
2026-04-16 13:47:41 +02:00
parent 951fcd3a58
commit 1197702121
2 changed files with 7 additions and 3 deletions
+6 -2
View File
@@ -9,7 +9,7 @@ class CounterServer extends IPSModule
$this->RegisterPropertyInteger('Connector', 0);
$this->RegisterPropertyInteger('SourceJSON', 0);
$this->RegisterPropertyInteger('UpdateTime', 60);
$this->RegisterPropertyInteger('ProjectIdPortal', 0);
$this->RegisterPropertyInteger('ProjectIdPortal', -1);
$this->RegisterTimer('Update', 0, 'SECT_checkTable($_IPS[\'TARGET\']);');
}
@@ -61,15 +61,17 @@ class CounterServer extends IPSModule
$counterName = $c['name'] ?? $counterId;
$type = $c['type'] ?? 'other';
$unit = $c['unit'] ?? 'kWh';
$projectId = $this->ReadPropertyInteger('ProjectIdPortal');
if ($projectId !== -1) {
// ---------- UPSERT ----------
$sql = "
INSERT INTO meter_devices
(project_id, counter_id, meter_uuid, external_id, external_name, meter_type, billing_unit, is_active)
VALUES
(
" . ($projectId === 'NULL' ? 'NULL' : $projectId) . ",
" . $this->esc($projectId) . "',
'" . $this->esc($clientId . '_' . $counterId) . "',
'" . $this->esc($counterId) . "',
'" . $this->esc($clientId) . "',
@@ -85,7 +87,9 @@ class CounterServer extends IPSModule
is_active = 1
";
MySQL_ExecuteSimple($sqlId, $sql);
}
// ---------- GET meter_id ----------
$sqlGet = "
+1 -1
View File
@@ -8,6 +8,6 @@
"date": 1491343200
},
"version": "1.0",
"build": 7,
"build": 8,
"date": 0
}