fix: update ProjectIdPortal default value to -1 and adjust SQL insert statement; increment build number in library.json
This commit is contained in:
@@ -9,7 +9,7 @@ class CounterServer extends IPSModule
|
|||||||
$this->RegisterPropertyInteger('Connector', 0);
|
$this->RegisterPropertyInteger('Connector', 0);
|
||||||
$this->RegisterPropertyInteger('SourceJSON', 0);
|
$this->RegisterPropertyInteger('SourceJSON', 0);
|
||||||
$this->RegisterPropertyInteger('UpdateTime', 60);
|
$this->RegisterPropertyInteger('UpdateTime', 60);
|
||||||
$this->RegisterPropertyInteger('ProjectIdPortal', 0);
|
$this->RegisterPropertyInteger('ProjectIdPortal', -1);
|
||||||
$this->RegisterTimer('Update', 0, 'SECT_checkTable($_IPS[\'TARGET\']);');
|
$this->RegisterTimer('Update', 0, 'SECT_checkTable($_IPS[\'TARGET\']);');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,15 +61,17 @@ class CounterServer extends IPSModule
|
|||||||
$counterName = $c['name'] ?? $counterId;
|
$counterName = $c['name'] ?? $counterId;
|
||||||
$type = $c['type'] ?? 'other';
|
$type = $c['type'] ?? 'other';
|
||||||
$unit = $c['unit'] ?? 'kWh';
|
$unit = $c['unit'] ?? 'kWh';
|
||||||
|
|
||||||
$projectId = $this->ReadPropertyInteger('ProjectIdPortal');
|
$projectId = $this->ReadPropertyInteger('ProjectIdPortal');
|
||||||
|
|
||||||
|
if ($projectId !== -1) {
|
||||||
// ---------- UPSERT ----------
|
// ---------- UPSERT ----------
|
||||||
$sql = "
|
$sql = "
|
||||||
INSERT INTO meter_devices
|
INSERT INTO meter_devices
|
||||||
(project_id, counter_id, meter_uuid, external_id, external_name, meter_type, billing_unit, is_active)
|
(project_id, counter_id, meter_uuid, external_id, external_name, meter_type, billing_unit, is_active)
|
||||||
VALUES
|
VALUES
|
||||||
(
|
(
|
||||||
" . ($projectId === 'NULL' ? 'NULL' : $projectId) . ",
|
" . $this->esc($projectId) . "',
|
||||||
'" . $this->esc($clientId . '_' . $counterId) . "',
|
'" . $this->esc($clientId . '_' . $counterId) . "',
|
||||||
'" . $this->esc($counterId) . "',
|
'" . $this->esc($counterId) . "',
|
||||||
'" . $this->esc($clientId) . "',
|
'" . $this->esc($clientId) . "',
|
||||||
@@ -85,7 +87,9 @@ class CounterServer extends IPSModule
|
|||||||
is_active = 1
|
is_active = 1
|
||||||
";
|
";
|
||||||
|
|
||||||
|
|
||||||
MySQL_ExecuteSimple($sqlId, $sql);
|
MySQL_ExecuteSimple($sqlId, $sql);
|
||||||
|
}
|
||||||
|
|
||||||
// ---------- GET meter_id ----------
|
// ---------- GET meter_id ----------
|
||||||
$sqlGet = "
|
$sqlGet = "
|
||||||
|
|||||||
+1
-1
@@ -8,6 +8,6 @@
|
|||||||
"date": 1491343200
|
"date": 1491343200
|
||||||
},
|
},
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
"build": 7,
|
"build": 8,
|
||||||
"date": 0
|
"date": 0
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user