qolsys-controller 0.0.38__py3-none-any.whl → 0.0.62__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of qolsys-controller might be problematic. Click here for more details.
- qolsys_controller/controller.py +829 -20
- qolsys_controller/database/db.py +63 -25
- qolsys_controller/database/table.py +89 -60
- qolsys_controller/database/table_alarmedsensor.py +0 -2
- qolsys_controller/database/table_automation.py +0 -1
- qolsys_controller/database/table_country_locale.py +0 -1
- qolsys_controller/database/table_dashboard_msgs.py +1 -2
- qolsys_controller/database/table_dimmerlight.py +0 -1
- qolsys_controller/database/table_doorlock.py +1 -1
- qolsys_controller/database/table_eu_event.py +12 -4
- qolsys_controller/database/table_heat_map.py +0 -2
- qolsys_controller/database/table_history.py +4 -1
- qolsys_controller/database/table_iqremotesettings.py +0 -2
- qolsys_controller/database/table_iqrouter_network_config.py +0 -1
- qolsys_controller/database/table_iqrouter_user_device.py +0 -2
- qolsys_controller/database/table_master_slave.py +0 -1
- qolsys_controller/database/table_nest_device.py +0 -1
- qolsys_controller/database/table_output_rules.py +0 -1
- qolsys_controller/database/table_partition.py +0 -1
- qolsys_controller/database/table_pgm_outputs.py +0 -2
- qolsys_controller/database/table_powerg_device.py +25 -3
- qolsys_controller/database/table_qolsyssettings.py +0 -2
- qolsys_controller/database/table_scene.py +0 -2
- qolsys_controller/database/table_sensor.py +3 -2
- qolsys_controller/database/table_sensor_group.py +23 -0
- qolsys_controller/database/table_shades.py +0 -2
- qolsys_controller/database/table_smartsocket.py +0 -2
- qolsys_controller/database/table_state.py +0 -1
- qolsys_controller/database/table_tcc.py +0 -1
- qolsys_controller/database/table_thermostat.py +0 -1
- qolsys_controller/database/table_trouble_conditions.py +0 -2
- qolsys_controller/database/table_user.py +1 -2
- qolsys_controller/database/table_virtual_device.py +0 -2
- qolsys_controller/database/table_weather.py +0 -2
- qolsys_controller/database/table_zigbee_device.py +0 -1
- qolsys_controller/database/table_zwave_association_group.py +0 -1
- qolsys_controller/database/table_zwave_history.py +0 -1
- qolsys_controller/database/table_zwave_node.py +1 -1
- qolsys_controller/database/table_zwave_other.py +14 -2
- qolsys_controller/enum.py +44 -16
- qolsys_controller/enum_zwave.py +81 -36
- qolsys_controller/errors.py +9 -12
- qolsys_controller/mdns.py +7 -4
- qolsys_controller/mqtt_command.py +119 -0
- qolsys_controller/mqtt_command_queue.py +5 -4
- qolsys_controller/observable.py +2 -2
- qolsys_controller/panel.py +224 -143
- qolsys_controller/partition.py +129 -127
- qolsys_controller/pki.py +69 -97
- qolsys_controller/scene.py +30 -28
- qolsys_controller/settings.py +96 -50
- qolsys_controller/state.py +71 -33
- qolsys_controller/task_manager.py +8 -12
- qolsys_controller/users.py +25 -0
- qolsys_controller/utils_mqtt.py +8 -16
- qolsys_controller/weather.py +71 -0
- qolsys_controller/zone.py +307 -169
- qolsys_controller/zwave_device.py +108 -95
- qolsys_controller/zwave_dimmer.py +53 -50
- qolsys_controller/zwave_garagedoor.py +0 -1
- qolsys_controller/zwave_generic.py +2 -3
- qolsys_controller/zwave_lock.py +47 -44
- qolsys_controller/zwave_outlet.py +0 -1
- qolsys_controller/zwave_thermostat.py +112 -118
- qolsys_controller-0.0.62.dist-info/METADATA +89 -0
- qolsys_controller-0.0.62.dist-info/RECORD +69 -0
- {qolsys_controller-0.0.38.dist-info → qolsys_controller-0.0.62.dist-info}/WHEEL +1 -1
- qolsys_controller/plugin.py +0 -34
- qolsys_controller/plugin_c4.py +0 -17
- qolsys_controller/plugin_remote.py +0 -1298
- qolsys_controller-0.0.38.dist-info/METADATA +0 -93
- qolsys_controller-0.0.38.dist-info/RECORD +0 -68
- {qolsys_controller-0.0.38.dist-info → qolsys_controller-0.0.62.dist-info}/licenses/LICENSE +0 -0
qolsys_controller/database/db.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import logging # noqa: INP001
|
|
2
2
|
import sqlite3
|
|
3
|
+
from typing import Any
|
|
3
4
|
|
|
4
5
|
from .table import QolsysTable
|
|
5
6
|
from .table_alarmedsensor import QolsysTableAlarmedSensor
|
|
@@ -23,6 +24,7 @@ from .table_powerg_device import QolsysTablePowerGDevice
|
|
|
23
24
|
from .table_qolsyssettings import QolsysTableQolsysSettings
|
|
24
25
|
from .table_scene import QolsysTableScene
|
|
25
26
|
from .table_sensor import QolsysTableSensor
|
|
27
|
+
from .table_sensor_group import QolsysTableSensorGroup
|
|
26
28
|
from .table_shades import QolsysTableShades
|
|
27
29
|
from .table_smartsocket import QolsysTableSmartSocket
|
|
28
30
|
from .table_state import QolsysTableState
|
|
@@ -42,9 +44,7 @@ LOGGER = logging.getLogger(__name__)
|
|
|
42
44
|
|
|
43
45
|
|
|
44
46
|
class QolsysDB:
|
|
45
|
-
|
|
46
47
|
def __init__(self) -> None: # noqa: PLR0915
|
|
47
|
-
|
|
48
48
|
self._db: sqlite3.Connection = sqlite3.connect(":memory:")
|
|
49
49
|
self._cursor: sqlite3.Cursor = self._db.cursor()
|
|
50
50
|
|
|
@@ -64,6 +64,7 @@ class QolsysDB:
|
|
|
64
64
|
self.table_partition = QolsysTablePartition(self.db, self.cursor)
|
|
65
65
|
self.table_powerg_device = QolsysTablePowerGDevice(self.db, self.cursor)
|
|
66
66
|
self.table_sensor = QolsysTableSensor(self.db, self.cursor)
|
|
67
|
+
self.table_sensor_group = QolsysTableSensorGroup(self.db, self.cursor)
|
|
67
68
|
self.table_smartsocket = QolsysTableSmartSocket(self.db, self.cursor)
|
|
68
69
|
self.table_qolsyssettings = QolsysTableQolsysSettings(self.db, self.cursor)
|
|
69
70
|
self.table_scene = QolsysTableScene(self.db, self.cursor)
|
|
@@ -84,8 +85,9 @@ class QolsysDB:
|
|
|
84
85
|
self.table_shades = QolsysTableShades(self.db, self.cursor)
|
|
85
86
|
self.table_nest_device = QolsysTableNestDevice(self.db, self.cursor)
|
|
86
87
|
|
|
87
|
-
self._table_array = []
|
|
88
|
+
self._table_array: list[QolsysTable] = []
|
|
88
89
|
self._table_array.append(self.table_sensor)
|
|
90
|
+
self._table_array.append(self.table_sensor_group)
|
|
89
91
|
self._table_array.append(self.table_partition)
|
|
90
92
|
self._table_array.append(self.table_qolsyssettings)
|
|
91
93
|
self._table_array.append(self.table_alarmedsensor)
|
|
@@ -153,7 +155,7 @@ class QolsysDB:
|
|
|
153
155
|
def cursor(self) -> sqlite3.Cursor:
|
|
154
156
|
return self._cursor
|
|
155
157
|
|
|
156
|
-
def get_scenes(self) -> list[dict]:
|
|
158
|
+
def get_scenes(self) -> list[dict[str, str]]:
|
|
157
159
|
self.cursor.execute(f"SELECT * FROM {self.table_scene.table} ORDER BY scene_id")
|
|
158
160
|
self.db.commit()
|
|
159
161
|
|
|
@@ -165,7 +167,7 @@ class QolsysDB:
|
|
|
165
167
|
|
|
166
168
|
return scenes
|
|
167
169
|
|
|
168
|
-
def get_partitions(self) -> list[dict]:
|
|
170
|
+
def get_partitions(self) -> list[dict[str, str]]:
|
|
169
171
|
self.cursor.execute(f"SELECT * FROM {self.table_partition.table} ORDER BY partition_id")
|
|
170
172
|
self.db.commit()
|
|
171
173
|
|
|
@@ -177,7 +179,7 @@ class QolsysDB:
|
|
|
177
179
|
|
|
178
180
|
return partitions
|
|
179
181
|
|
|
180
|
-
def get_zwave_devices(self) -> list[dict]:
|
|
182
|
+
def get_zwave_devices(self) -> list[dict[str, str]]:
|
|
181
183
|
self.cursor.execute(f"SELECT * FROM {self.table_zwave_node.table} ORDER BY node_id")
|
|
182
184
|
self.db.commit()
|
|
183
185
|
|
|
@@ -189,7 +191,7 @@ class QolsysDB:
|
|
|
189
191
|
|
|
190
192
|
return devices
|
|
191
193
|
|
|
192
|
-
def get_locks(self) -> list[dict]:
|
|
194
|
+
def get_locks(self) -> list[dict[str, str]]:
|
|
193
195
|
self.cursor.execute(f"SELECT * FROM {self.table_doorlock.table} ORDER BY node_id")
|
|
194
196
|
self.db.commit()
|
|
195
197
|
|
|
@@ -201,7 +203,7 @@ class QolsysDB:
|
|
|
201
203
|
|
|
202
204
|
return locks
|
|
203
205
|
|
|
204
|
-
def get_thermostats(self) -> list[dict]:
|
|
206
|
+
def get_thermostats(self) -> list[dict[str, str]]:
|
|
205
207
|
self.cursor.execute(f"SELECT * FROM {self.table_thermostat.table} ORDER BY node_id")
|
|
206
208
|
self.db.commit()
|
|
207
209
|
|
|
@@ -213,7 +215,7 @@ class QolsysDB:
|
|
|
213
215
|
|
|
214
216
|
return thermostats
|
|
215
217
|
|
|
216
|
-
def get_dimmers(self) -> list[dict]:
|
|
218
|
+
def get_dimmers(self) -> list[dict[str, str]]:
|
|
217
219
|
self.cursor.execute(f"SELECT * FROM {self.table_dimmer.table} ORDER BY node_id")
|
|
218
220
|
self.db.commit()
|
|
219
221
|
|
|
@@ -225,7 +227,7 @@ class QolsysDB:
|
|
|
225
227
|
|
|
226
228
|
return dimmers
|
|
227
229
|
|
|
228
|
-
def get_zones(self) -> list[dict]:
|
|
230
|
+
def get_zones(self) -> list[dict[str, str]]:
|
|
229
231
|
self.cursor.execute(f"SELECT * FROM {self.table_sensor.table} ORDER BY zoneid")
|
|
230
232
|
self.db.commit()
|
|
231
233
|
|
|
@@ -237,38 +239,75 @@ class QolsysDB:
|
|
|
237
239
|
|
|
238
240
|
return zones
|
|
239
241
|
|
|
242
|
+
def get_weather(self) -> list[dict[str, str]]:
|
|
243
|
+
self.cursor.execute(f"SELECT * FROM {self.table_weather.table} ORDER BY _id")
|
|
244
|
+
self.db.commit()
|
|
245
|
+
|
|
246
|
+
weather_list = []
|
|
247
|
+
columns = [description[0] for description in self.cursor.description]
|
|
248
|
+
for row in self.cursor.fetchall():
|
|
249
|
+
row_dict = dict(zip(columns, row, strict=True))
|
|
250
|
+
weather_list.append(row_dict)
|
|
251
|
+
|
|
252
|
+
return weather_list
|
|
253
|
+
|
|
254
|
+
def get_powerg(self, short_id: str) -> dict[str, str] | None:
|
|
255
|
+
try:
|
|
256
|
+
self.cursor.execute(f"SELECT * FROM {self.table_powerg_device.table} WHERE shortID = ?", (short_id,))
|
|
257
|
+
self.db.commit()
|
|
258
|
+
|
|
259
|
+
row = self.cursor.fetchone()
|
|
260
|
+
|
|
261
|
+
if row is None:
|
|
262
|
+
LOGGER.debug("%s value not found", short_id)
|
|
263
|
+
return None
|
|
264
|
+
|
|
265
|
+
columns = [description[0] for description in self.cursor.description]
|
|
266
|
+
return dict(zip(columns, row, strict=True))
|
|
267
|
+
|
|
268
|
+
except sqlite3.Error:
|
|
269
|
+
LOGGER.exception("Error getting PowerG device info for shortID %s", short_id)
|
|
270
|
+
return None
|
|
271
|
+
|
|
240
272
|
def get_setting_panel(self, setting: str) -> str:
|
|
241
|
-
self.cursor.execute(
|
|
242
|
-
|
|
273
|
+
self.cursor.execute(
|
|
274
|
+
f"""SELECT value FROM {self.table_qolsyssettings.table}
|
|
275
|
+
WHERE name = ? and partition_id = ? """,
|
|
276
|
+
(setting, "0"),
|
|
277
|
+
)
|
|
243
278
|
row = self.cursor.fetchone()
|
|
244
279
|
|
|
245
280
|
if row is None:
|
|
246
281
|
LOGGER.debug("%s value not found", setting)
|
|
247
|
-
return
|
|
282
|
+
return ""
|
|
248
283
|
|
|
249
|
-
return row[0]
|
|
284
|
+
return str(row[0])
|
|
250
285
|
|
|
251
|
-
def get_setting_partition(self, setting: str, partition_id: str) -> str
|
|
252
|
-
self.cursor.execute(
|
|
253
|
-
|
|
286
|
+
def get_setting_partition(self, setting: str, partition_id: str) -> str:
|
|
287
|
+
self.cursor.execute(
|
|
288
|
+
f"""SELECT value FROM {self.table_qolsyssettings.table}
|
|
289
|
+
WHERE name = ? and partition_id = ? """,
|
|
290
|
+
(setting, partition_id),
|
|
291
|
+
)
|
|
254
292
|
row = self.cursor.fetchone()
|
|
255
293
|
|
|
256
294
|
if row is None:
|
|
257
295
|
LOGGER.debug("%s value not found", setting)
|
|
258
|
-
return
|
|
296
|
+
return ""
|
|
259
297
|
|
|
260
|
-
return row[0]
|
|
298
|
+
return str(row[0])
|
|
261
299
|
|
|
262
300
|
def get_state_partition(self, state: str, partition_id: str) -> str | None:
|
|
263
301
|
self.cursor.execute(
|
|
264
|
-
f"""SELECT value FROM {self.table_state.table} WHERE name = ? and partition_id = ? """, (state, partition_id)
|
|
302
|
+
f"""SELECT value FROM {self.table_state.table} WHERE name = ? and partition_id = ? """, (state, partition_id)
|
|
303
|
+
)
|
|
265
304
|
row = self.cursor.fetchone()
|
|
266
305
|
|
|
267
306
|
if row is None:
|
|
268
307
|
LOGGER.debug("%s value not found", state)
|
|
269
308
|
return None
|
|
270
309
|
|
|
271
|
-
return row[0]
|
|
310
|
+
return str(row[0])
|
|
272
311
|
|
|
273
312
|
def get_alarm_type(self, partition_id: str) -> list[str]:
|
|
274
313
|
alarm_type = []
|
|
@@ -291,8 +330,7 @@ class QolsysDB:
|
|
|
291
330
|
|
|
292
331
|
return None
|
|
293
332
|
|
|
294
|
-
def load_db(self, database: dict) -> None:
|
|
295
|
-
|
|
333
|
+
def load_db(self, database: list[dict[str, Any]]) -> None:
|
|
296
334
|
self.clear_db()
|
|
297
335
|
|
|
298
336
|
if not database:
|
|
@@ -300,7 +338,7 @@ class QolsysDB:
|
|
|
300
338
|
return
|
|
301
339
|
|
|
302
340
|
for uri in database:
|
|
303
|
-
table = self.get_table(uri.get("uri"))
|
|
341
|
+
table = self.get_table(uri.get("uri", ""))
|
|
304
342
|
|
|
305
343
|
if table is None:
|
|
306
344
|
LOGGER.error("Please Report")
|
|
@@ -308,5 +346,5 @@ class QolsysDB:
|
|
|
308
346
|
LOGGER.error(uri)
|
|
309
347
|
continue
|
|
310
348
|
|
|
311
|
-
for u in uri.get("resultSet"):
|
|
349
|
+
for u in uri.get("resultSet", ""):
|
|
312
350
|
table.insert(data=u)
|
|
@@ -7,7 +7,6 @@ LOGGER = logging.getLogger(__name__)
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class QolsysTable:
|
|
10
|
-
|
|
11
10
|
def __init__(self, db: sqlite3.Connection, cursor: sqlite3.Cursor) -> None:
|
|
12
11
|
self._db: sqlite3.Connection = db
|
|
13
12
|
self._cursor: sqlite3.Cursor = cursor
|
|
@@ -15,7 +14,7 @@ class QolsysTable:
|
|
|
15
14
|
self._table: str = ""
|
|
16
15
|
self._columns: list[str] = []
|
|
17
16
|
self._abort_on_error: bool = False
|
|
18
|
-
self._implemented:bool = False
|
|
17
|
+
self._implemented: bool = False
|
|
19
18
|
|
|
20
19
|
@property
|
|
21
20
|
def uri(self) -> str:
|
|
@@ -37,16 +36,18 @@ class QolsysTable:
|
|
|
37
36
|
column_defs += [f"{col} TEXT" for col in other_columns]
|
|
38
37
|
|
|
39
38
|
try:
|
|
40
|
-
query = f"CREATE TABLE {self._table} ({', '.join(column_defs)})"
|
|
39
|
+
query: str = f"CREATE TABLE {self._table} ({', '.join(column_defs)})"
|
|
41
40
|
self._cursor.execute(query)
|
|
42
41
|
self._db.commit()
|
|
43
42
|
|
|
44
43
|
except sqlite3.Error as err:
|
|
45
|
-
error = QolsysSqlError(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
error = QolsysSqlError(
|
|
45
|
+
{
|
|
46
|
+
"table": self.table,
|
|
47
|
+
"query": query,
|
|
48
|
+
"columns": self._columns,
|
|
49
|
+
}
|
|
50
|
+
)
|
|
50
51
|
|
|
51
52
|
if self._abort_on_error:
|
|
52
53
|
raise error from err
|
|
@@ -58,16 +59,18 @@ class QolsysTable:
|
|
|
58
59
|
self._db.commit()
|
|
59
60
|
|
|
60
61
|
except sqlite3.Error as err:
|
|
61
|
-
error = QolsysSqlError(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
error = QolsysSqlError(
|
|
63
|
+
{
|
|
64
|
+
"table": self.table,
|
|
65
|
+
"query": query,
|
|
66
|
+
"columns": self._columns,
|
|
67
|
+
}
|
|
68
|
+
)
|
|
66
69
|
|
|
67
70
|
if self._abort_on_error:
|
|
68
71
|
raise error from err
|
|
69
72
|
|
|
70
|
-
def insert(self, data: dict) -> None:
|
|
73
|
+
def insert(self, data: dict[str, str]) -> None:
|
|
71
74
|
try:
|
|
72
75
|
if not self._implemented and data is not None:
|
|
73
76
|
LOGGER.warning("New Table format: %s", self.uri)
|
|
@@ -92,97 +95,123 @@ class QolsysTable:
|
|
|
92
95
|
|
|
93
96
|
col_str = ", ".join(full_data.keys())
|
|
94
97
|
placeholder_str = ", ".join([f":{key}" for key in full_data])
|
|
98
|
+
|
|
95
99
|
query = f"INSERT OR IGNORE INTO {self.table} ({col_str}) VALUES ({placeholder_str})"
|
|
96
100
|
self._cursor.execute(query, full_data)
|
|
97
101
|
self._db.commit()
|
|
98
102
|
|
|
99
103
|
except sqlite3.Error as err:
|
|
100
|
-
error = QolsysSqlError(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
error = QolsysSqlError(
|
|
105
|
+
{
|
|
106
|
+
"table": self.table,
|
|
107
|
+
"query": query,
|
|
108
|
+
"columns": self._columns,
|
|
109
|
+
}
|
|
110
|
+
)
|
|
105
111
|
|
|
106
112
|
if self._abort_on_error:
|
|
107
113
|
raise error from err
|
|
108
114
|
|
|
109
|
-
def update(
|
|
115
|
+
def update(
|
|
116
|
+
self, selection: str | None, selection_argument: list[str] | str | None, content_value: dict[str, str] | None
|
|
117
|
+
) -> None:
|
|
110
118
|
# selection: 'zone_id=?, parition_id=?'
|
|
111
|
-
|
|
112
|
-
# selection_argument:
|
|
113
119
|
# Firmware 4.4.1: selection_argument: '[3,1]'
|
|
114
120
|
# Firmware 4.6.1: selection_argument: ['3','1']
|
|
115
121
|
|
|
116
|
-
#
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
# Selection Argument
|
|
120
|
-
# Panel send selection_argument as list in Firmware 4.6.1
|
|
121
|
-
if(type(selection_argument) is not list):
|
|
122
|
-
#Firmware 4.4.1, seletion_argument is sent as a string
|
|
122
|
+
# Firmware 4.4.1: seletion_argument is sent as a string and needs to be converted to an array
|
|
123
|
+
if isinstance(selection_argument, str):
|
|
123
124
|
selection_argument = selection_argument.strip("[]")
|
|
124
125
|
selection_argument = [item.strip() for item in selection_argument.split(",")]
|
|
125
126
|
|
|
127
|
+
if selection_argument is None:
|
|
128
|
+
selection_argument = []
|
|
129
|
+
|
|
126
130
|
try:
|
|
127
131
|
full_data = {}
|
|
128
132
|
new_columns = []
|
|
129
133
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
# Separate valid and unknown columns
|
|
135
|
+
if content_value is not None:
|
|
136
|
+
for key, value in content_value.items():
|
|
137
|
+
if key in self._columns:
|
|
138
|
+
full_data[key] = value
|
|
139
|
+
else:
|
|
140
|
+
new_columns.append(key)
|
|
137
141
|
|
|
138
|
-
# Warn
|
|
142
|
+
# Warn for unknown columns
|
|
139
143
|
if new_columns:
|
|
140
144
|
LOGGER.warning("New column found in iq2meid database")
|
|
141
145
|
LOGGER.warning("Table: %s", self.table)
|
|
142
146
|
LOGGER.warning("New Columns: %s", new_columns)
|
|
143
147
|
LOGGER.warning("Please Report")
|
|
144
148
|
|
|
145
|
-
|
|
146
|
-
|
|
149
|
+
set_clause = ", ".join([f"{key} = ?" for key in full_data])
|
|
150
|
+
set_values = list(full_data.values())
|
|
151
|
+
|
|
152
|
+
if selection:
|
|
153
|
+
query = f"UPDATE {self.table} SET {set_clause} WHERE {selection}"
|
|
154
|
+
params = set_values + selection_argument
|
|
155
|
+
else:
|
|
156
|
+
query = f"UPDATE {self.table} SET {set_clause}"
|
|
157
|
+
params = set_values
|
|
158
|
+
|
|
159
|
+
self._cursor.execute(query, params)
|
|
147
160
|
self._db.commit()
|
|
148
161
|
|
|
149
162
|
except sqlite3.Error as err:
|
|
150
|
-
error = QolsysSqlError(
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
163
|
+
error = QolsysSqlError(
|
|
164
|
+
{
|
|
165
|
+
"table": self.table,
|
|
166
|
+
"query": query,
|
|
167
|
+
"columns": self._columns,
|
|
168
|
+
"content_value": content_value,
|
|
169
|
+
"selection": selection,
|
|
170
|
+
"selection_argument": selection_argument,
|
|
171
|
+
}
|
|
172
|
+
)
|
|
158
173
|
|
|
159
174
|
if self._abort_on_error:
|
|
160
175
|
raise error from err
|
|
161
176
|
|
|
162
|
-
def delete(self, selection: str, selection_argument: str) -> None:
|
|
177
|
+
def delete(self, selection: str | None, selection_argument: list[str] | str | None) -> None:
|
|
163
178
|
# selection: 'zone_id=?, parition_id=?'
|
|
164
179
|
# Firmware 4.4.1: selection_argument: '[3,1]'
|
|
165
180
|
# Firmware 4.6.1: selection_argument: ['3','1']
|
|
166
181
|
|
|
167
|
-
#
|
|
168
|
-
if
|
|
169
|
-
#Firmware 4.4.1, seletion_argument is sent as a string
|
|
182
|
+
# Firmware 4.4.1: seletion_argument is sent as a string and needs to be converted to an array
|
|
183
|
+
if type(selection_argument) is str:
|
|
170
184
|
selection_argument = selection_argument.strip("[]")
|
|
171
185
|
selection_argument = [item.strip() for item in selection_argument.split(",")]
|
|
172
186
|
|
|
187
|
+
if selection_argument is None:
|
|
188
|
+
selection_argument = []
|
|
189
|
+
|
|
173
190
|
try:
|
|
174
|
-
|
|
175
|
-
|
|
191
|
+
if selection:
|
|
192
|
+
query = f"DELETE FROM {self.table} WHERE {selection}"
|
|
193
|
+
|
|
194
|
+
if "?" in selection:
|
|
195
|
+
# Query expects parameters → must pass the list
|
|
196
|
+
self._cursor.execute(query, selection_argument)
|
|
197
|
+
else:
|
|
198
|
+
# Query has no ? , do not pass arguments
|
|
199
|
+
self._cursor.execute(query)
|
|
200
|
+
else:
|
|
201
|
+
self.clear()
|
|
202
|
+
|
|
176
203
|
self._db.commit()
|
|
177
204
|
|
|
178
205
|
except sqlite3.Error as err:
|
|
179
|
-
error = QolsysSqlError(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
206
|
+
error = QolsysSqlError(
|
|
207
|
+
{
|
|
208
|
+
"table": self.table,
|
|
209
|
+
"query": query,
|
|
210
|
+
"columns": self._columns,
|
|
211
|
+
"selection": selection,
|
|
212
|
+
"selection_argument": selection_argument,
|
|
213
|
+
}
|
|
214
|
+
)
|
|
186
215
|
|
|
187
216
|
if self._abort_on_error:
|
|
188
217
|
raise error from err
|
|
@@ -7,7 +7,6 @@ LOGGER = logging.getLogger(__name__)
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class QolsysTableAlarmedSensor(QolsysTable):
|
|
10
|
-
|
|
11
10
|
def __init__(self, db: sqlite3.Connection, cursor: sqlite3.Cursor) -> None:
|
|
12
11
|
super().__init__(db, cursor)
|
|
13
12
|
self._uri = "content://com.qolsys.qolsysprovider.AlarmedSensorProvider/alarmedsensor"
|
|
@@ -15,7 +14,6 @@ class QolsysTableAlarmedSensor(QolsysTable):
|
|
|
15
14
|
self._abort_on_error = True
|
|
16
15
|
self._implemented = True
|
|
17
16
|
|
|
18
|
-
|
|
19
17
|
self._columns = [
|
|
20
18
|
"_id",
|
|
21
19
|
"partition_id",
|
|
@@ -7,7 +7,6 @@ LOGGER = logging.getLogger(__name__)
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class QolsysTableAutomation(QolsysTable):
|
|
10
|
-
|
|
11
10
|
def __init__(self, db: sqlite3.Connection, cursor: sqlite3.Cursor) -> None:
|
|
12
11
|
super().__init__(db, cursor)
|
|
13
12
|
self._uri = "content://com.qolsys.qolsysprovider.AutomationDeviceContentProvider/automation"
|
|
@@ -7,7 +7,6 @@ LOGGER = logging.getLogger(__name__)
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class QolsysTableCountryLocale(QolsysTable):
|
|
10
|
-
|
|
11
10
|
def __init__(self, db: sqlite3.Connection, cursor: sqlite3.Cursor) -> None:
|
|
12
11
|
super().__init__(db, cursor)
|
|
13
12
|
self._uri = "content://com.qolsys.qolsysprovider.CountryLocaleContentProvider/country_locale"
|
|
@@ -7,7 +7,6 @@ LOGGER = logging.getLogger(__name__)
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class QolsysTableDashboardMsgs(QolsysTable):
|
|
10
|
-
|
|
11
10
|
def __init__(self, db: sqlite3.Connection, cursor: sqlite3.Cursor) -> None:
|
|
12
11
|
super().__init__(db, cursor)
|
|
13
12
|
self._uri = "content://com.qolsys.qolsysprovider.DashboardMessagesContentProvider/dashboard_msgs"
|
|
@@ -15,7 +14,6 @@ class QolsysTableDashboardMsgs(QolsysTable):
|
|
|
15
14
|
self._abort_on_error = False
|
|
16
15
|
self._implemented = True
|
|
17
16
|
|
|
18
|
-
|
|
19
17
|
self._columns = [
|
|
20
18
|
"_id",
|
|
21
19
|
"version",
|
|
@@ -29,6 +27,7 @@ class QolsysTableDashboardMsgs(QolsysTable):
|
|
|
29
27
|
"end_time",
|
|
30
28
|
"read",
|
|
31
29
|
"mime_type",
|
|
30
|
+
"type",
|
|
32
31
|
]
|
|
33
32
|
|
|
34
33
|
self._create_table()
|
|
@@ -7,7 +7,6 @@ LOGGER = logging.getLogger(__name__)
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class QolsysTableDimmerLight(QolsysTable):
|
|
10
|
-
|
|
11
10
|
def __init__(self, db: sqlite3.Connection, cursor: sqlite3.Cursor) -> None:
|
|
12
11
|
super().__init__(db, cursor)
|
|
13
12
|
self._uri = "content://com.qolsys.qolsysprovider.DimmerLightsContentProvider/dimmerlight"
|
|
@@ -7,7 +7,6 @@ LOGGER = logging.getLogger(__name__)
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class QolsysTableDoorLock(QolsysTable):
|
|
10
|
-
|
|
11
10
|
def __init__(self, db: sqlite3.Connection, cursor: sqlite3.Cursor) -> None:
|
|
12
11
|
super().__init__(db, cursor)
|
|
13
12
|
self._uri = "content://com.qolsys.qolsysprovider.DoorLocksContentProvider/doorlock"
|
|
@@ -17,6 +16,7 @@ class QolsysTableDoorLock(QolsysTable):
|
|
|
17
16
|
|
|
18
17
|
self._columns = [
|
|
19
18
|
"_id",
|
|
19
|
+
"capabilities",
|
|
20
20
|
"version",
|
|
21
21
|
"opr",
|
|
22
22
|
"partition_id",
|
|
@@ -7,18 +7,26 @@ LOGGER = logging.getLogger(__name__)
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class QolsysTableEuEvent(QolsysTable):
|
|
10
|
-
|
|
11
10
|
def __init__(self, db: sqlite3.Connection, cursor: sqlite3.Cursor) -> None:
|
|
12
11
|
super().__init__(db, cursor)
|
|
13
12
|
self._uri = "content://com.qolsys.qolsysprovider.EUEventContentProvider/eu_event"
|
|
14
13
|
self._table = "eu_event"
|
|
15
14
|
self._abort_on_error = False
|
|
16
|
-
self._implemented =
|
|
17
|
-
|
|
15
|
+
self._implemented = True
|
|
18
16
|
|
|
19
17
|
self._columns = [
|
|
20
18
|
"_id",
|
|
19
|
+
"version",
|
|
20
|
+
"opr",
|
|
21
|
+
"partition_id",
|
|
22
|
+
"history_id",
|
|
23
|
+
"device_id",
|
|
24
|
+
"device",
|
|
25
|
+
"events",
|
|
26
|
+
"time",
|
|
27
|
+
"ack",
|
|
28
|
+
"type",
|
|
29
|
+
"feature2",
|
|
21
30
|
]
|
|
22
31
|
|
|
23
32
|
self._create_table()
|
|
24
|
-
|
|
@@ -7,7 +7,6 @@ LOGGER = logging.getLogger(__name__)
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class QolsysTableHeatMap(QolsysTable):
|
|
10
|
-
|
|
11
10
|
def __init__(self, db: sqlite3.Connection, cursor: sqlite3.Cursor) -> None:
|
|
12
11
|
super().__init__(db, cursor)
|
|
13
12
|
self._uri = "content://com.qolsys.qolsysprovider.HeatMapContentProvider/heat_map"
|
|
@@ -28,4 +27,3 @@ class QolsysTableHeatMap(QolsysTable):
|
|
|
28
27
|
]
|
|
29
28
|
|
|
30
29
|
self._create_table()
|
|
31
|
-
|
|
@@ -7,7 +7,6 @@ LOGGER = logging.getLogger(__name__)
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class QolsysTableHistory(QolsysTable):
|
|
10
|
-
|
|
11
10
|
def __init__(self, db: sqlite3.Connection, cursor: sqlite3.Cursor) -> None:
|
|
12
11
|
super().__init__(db, cursor)
|
|
13
12
|
self._uri = "content://com.qolsys.qolsysprovider.HistoryContentProvider/history"
|
|
@@ -28,6 +27,10 @@ class QolsysTableHistory(QolsysTable):
|
|
|
28
27
|
"feature1",
|
|
29
28
|
"feature2",
|
|
30
29
|
"device_id",
|
|
30
|
+
# "History Bulk Insert",
|
|
31
|
+
"Partition",
|
|
32
|
+
# "History Device Names List",
|
|
33
|
+
# "History Bypass Event",
|
|
31
34
|
]
|
|
32
35
|
|
|
33
36
|
self._create_table()
|
|
@@ -7,7 +7,6 @@ LOGGER = logging.getLogger(__name__)
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class QolsysTableIqRemoteSettings(QolsysTable):
|
|
10
|
-
|
|
11
10
|
def __init__(self, db: sqlite3.Connection, cursor: sqlite3.Cursor) -> None:
|
|
12
11
|
super().__init__(db, cursor)
|
|
13
12
|
self._uri = "content://com.qolsys.qolsysprovider.IQRemoteSettingsContentProvider/iqremotesettings"
|
|
@@ -27,4 +26,3 @@ class QolsysTableIqRemoteSettings(QolsysTable):
|
|
|
27
26
|
]
|
|
28
27
|
|
|
29
28
|
self._create_table()
|
|
30
|
-
|
|
@@ -7,7 +7,6 @@ LOGGER = logging.getLogger(__name__)
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class QolsysTableIqRouterNetworkConfig(QolsysTable):
|
|
10
|
-
|
|
11
10
|
def __init__(self, db: sqlite3.Connection, cursor: sqlite3.Cursor) -> None:
|
|
12
11
|
super().__init__(db, cursor)
|
|
13
12
|
self._uri = "content://com.qolsys.qolsysprovider.IQRouterNetworkConfigContentProvider/iqrouter_network_config_table"
|
|
@@ -7,7 +7,6 @@ LOGGER = logging.getLogger(__name__)
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class QolsysTableIqRouterUserDevice(QolsysTable):
|
|
10
|
-
|
|
11
10
|
def __init__(self, db: sqlite3.Connection, cursor: sqlite3.Cursor) -> None:
|
|
12
11
|
super().__init__(db, cursor)
|
|
13
12
|
self._uri = "content://com.qolsys.qolsysprovider.IQRouterUserDeviceContentProvider/iqrouter_user_device_table"
|
|
@@ -15,7 +14,6 @@ class QolsysTableIqRouterUserDevice(QolsysTable):
|
|
|
15
14
|
self._abort_on_error = False
|
|
16
15
|
self._implemented = False
|
|
17
16
|
|
|
18
|
-
|
|
19
17
|
self._columns = [
|
|
20
18
|
"_id",
|
|
21
19
|
]
|
|
@@ -7,7 +7,6 @@ LOGGER = logging.getLogger(__name__)
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class QolsysTableMasterSlave(QolsysTable):
|
|
10
|
-
|
|
11
10
|
def __init__(self, db: sqlite3.Connection, cursor: sqlite3.Cursor) -> None:
|
|
12
11
|
super().__init__(db, cursor)
|
|
13
12
|
self._uri = "content://com.qolsys.qolsysprovider.MasterSlaveContentProvider/master_slave"
|
|
@@ -7,7 +7,6 @@ LOGGER = logging.getLogger(__name__)
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class QolsysTableNestDevice(QolsysTable):
|
|
10
|
-
|
|
11
10
|
def __init__(self, db: sqlite3.Connection, cursor: sqlite3.Cursor) -> None:
|
|
12
11
|
super().__init__(db, cursor)
|
|
13
12
|
self._uri = "content://com.qolsys.qolsysprovider.NestDeviceContentProvider/nest_device"
|
|
@@ -7,7 +7,6 @@ LOGGER = logging.getLogger(__name__)
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class QolsysTableOutputRules(QolsysTable):
|
|
10
|
-
|
|
11
10
|
def __init__(self, db: sqlite3.Connection, cursor: sqlite3.Cursor) -> None:
|
|
12
11
|
super().__init__(db, cursor)
|
|
13
12
|
self._uri = "content://com.qolsys.qolsysprovider.OutputRulesContentProvider/output_rules"
|