qolsys-controller 0.0.2__py3-none-any.whl → 0.0.5__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.
- qolsys_controller/controller.py +6 -8
- qolsys_controller/database/db.py +62 -58
- qolsys_controller/database/table.py +24 -25
- qolsys_controller/database/table_alarmedsensor.py +15 -14
- qolsys_controller/database/table_automation.py +32 -28
- qolsys_controller/database/table_country_locale.py +23 -20
- qolsys_controller/database/table_dashboard_msgs.py +6 -5
- qolsys_controller/database/table_dimmerlight.py +22 -20
- qolsys_controller/database/table_doorlock.py +22 -20
- qolsys_controller/database/table_eu_event.py +5 -5
- qolsys_controller/database/table_heat_map.py +14 -13
- qolsys_controller/database/table_history.py +16 -15
- qolsys_controller/database/table_iqremotesettings.py +13 -12
- qolsys_controller/database/table_iqrouter_network_config.py +5 -5
- qolsys_controller/database/table_iqrouter_user_device.py +5 -5
- qolsys_controller/database/table_master_slave.py +28 -25
- qolsys_controller/database/table_partition.py +10 -10
- qolsys_controller/database/table_powerg_device.py +5 -5
- qolsys_controller/database/table_qolsyssettings.py +10 -10
- qolsys_controller/database/table_scene.py +20 -17
- qolsys_controller/database/table_sensor.py +56 -47
- qolsys_controller/database/table_smartsocket.py +5 -5
- qolsys_controller/database/table_state.py +12 -11
- qolsys_controller/database/table_tcc.py +6 -5
- qolsys_controller/database/table_thermostat.py +41 -34
- qolsys_controller/database/table_trouble_conditions.py +14 -13
- qolsys_controller/database/table_user.py +17 -16
- qolsys_controller/database/table_virtual_device.py +5 -5
- qolsys_controller/database/table_weather.py +16 -15
- qolsys_controller/database/table_zigbee_device.py +5 -5
- qolsys_controller/database/table_zwave_association_group.py +19 -17
- qolsys_controller/database/table_zwave_history.py +22 -20
- qolsys_controller/database/table_zwave_node.py +73 -68
- qolsys_controller/database/table_zwave_other.py +5 -5
- qolsys_controller/enum.py +44 -41
- qolsys_controller/errors.py +13 -13
- qolsys_controller/mdns.py +3 -3
- qolsys_controller/mqtt_command_queue.py +2 -3
- qolsys_controller/observable.py +3 -2
- qolsys_controller/panel.py +163 -161
- qolsys_controller/partition.py +46 -43
- qolsys_controller/pki.py +72 -65
- qolsys_controller/plugin.py +5 -4
- qolsys_controller/plugin_c4.py +8 -9
- qolsys_controller/plugin_remote.py +237 -228
- qolsys_controller/settings.py +104 -8
- qolsys_controller/state.py +68 -65
- qolsys_controller/task_manager.py +3 -3
- qolsys_controller/utils_mqtt.py +14 -11
- qolsys_controller/zone.py +69 -68
- qolsys_controller/zwave_device.py +46 -43
- qolsys_controller/zwave_dimmer.py +28 -26
- qolsys_controller/zwave_garagedoor.py +1 -0
- qolsys_controller/zwave_generic.py +2 -1
- qolsys_controller/zwave_lock.py +28 -30
- qolsys_controller/zwave_outlet.py +1 -0
- qolsys_controller/zwave_thermostat.py +58 -55
- {qolsys_controller-0.0.2.dist-info → qolsys_controller-0.0.5.dist-info}/METADATA +7 -3
- qolsys_controller-0.0.5.dist-info/RECORD +62 -0
- qolsys_controller-0.0.2.dist-info/RECORD +0 -62
- {qolsys_controller-0.0.2.dist-info → qolsys_controller-0.0.5.dist-info}/WHEEL +0 -0
- {qolsys_controller-0.0.2.dist-info → qolsys_controller-0.0.5.dist-info}/licenses/LICENSE +0 -0
qolsys_controller/controller.py
CHANGED
@@ -9,16 +9,16 @@ from .state import QolsysState
|
|
9
9
|
|
10
10
|
LOGGER = logging.getLogger(__name__)
|
11
11
|
|
12
|
+
|
12
13
|
class QolsysController:
|
13
14
|
|
14
|
-
def __init__(self
|
15
|
+
def __init__(self) -> None:
|
15
16
|
|
16
17
|
# QolsysController Information
|
17
18
|
self.plugin = None
|
18
|
-
self._config_directory = config_directory
|
19
19
|
self._state = QolsysState()
|
20
|
-
self._panel = QolsysPanel(settings_directory=config_directory,state=self.state)
|
21
20
|
self._settings = QolsysSettings()
|
21
|
+
self._panel = QolsysPanel(settings=self.settings, state=self.state)
|
22
22
|
|
23
23
|
@property
|
24
24
|
def state(self) -> QolsysState:
|
@@ -32,21 +32,19 @@ class QolsysController:
|
|
32
32
|
def settings(self) -> QolsysSettings:
|
33
33
|
return self._settings
|
34
34
|
|
35
|
-
def select_plugin(self,plugin: str) -> None:
|
35
|
+
def select_plugin(self, plugin: str) -> None:
|
36
36
|
|
37
37
|
match plugin:
|
38
38
|
|
39
39
|
case "c4":
|
40
40
|
LOGGER.debug("C4 Plugin Selected")
|
41
|
-
self.plugin = QolsysPluginC4(self.state,self.panel,self.settings)
|
41
|
+
self.plugin = QolsysPluginC4(self.state, self.panel, self.settings)
|
42
42
|
return
|
43
43
|
|
44
44
|
case "remote":
|
45
45
|
LOGGER.debug("Remote Plugin Selected")
|
46
|
-
self.plugin = QolsysPluginRemote(self.state,self.panel,self.settings
|
46
|
+
self.plugin = QolsysPluginRemote(self.state, self.panel, self.settings)
|
47
47
|
return
|
48
48
|
|
49
49
|
case _:
|
50
50
|
LOGGER.debug("Unknow Plugin Selected")
|
51
|
-
|
52
|
-
|
qolsys_controller/database/db.py
CHANGED
@@ -36,44 +36,45 @@ from .table_zwave_other import QolsysTableZwaveOther
|
|
36
36
|
|
37
37
|
LOGGER = logging.getLogger(__name__)
|
38
38
|
|
39
|
+
|
39
40
|
class QolsysDB:
|
40
41
|
|
41
42
|
def __init__(self) -> None: # noqa: PLR0915
|
42
43
|
|
43
|
-
self._db:sqlite3.Connection = sqlite3.connect(":memory:")
|
44
|
-
self._cursor:sqlite3.Cursor = self._db.cursor()
|
45
|
-
|
46
|
-
self.table_alarmedsensor = QolsysTableAlarmedSensor(self.db,self.cursor)
|
47
|
-
self.table_automation = QolsysTableAutomation(self.db,self.cursor)
|
48
|
-
self.table_country_locale = QolsysTableCountryLocale(self.db,self.cursor)
|
49
|
-
self.table_dashboard_msgs = QolsysTableDashboardMsgs(self.db,self.cursor)
|
50
|
-
self.table_dimmer = QolsysTableDimmerLight(self.db,self.cursor)
|
51
|
-
self.table_doorlock = QolsysTableDoorLock(self.db,self.cursor)
|
52
|
-
self.table_eu_event = QolsysTableEuEvent(self.db,self.cursor)
|
53
|
-
self.table_heat_map = QolsysTableHeatMap(self.db,self.cursor)
|
54
|
-
self.table_history = QolsysTableHistory(self.db,self.cursor)
|
55
|
-
self.table_iqremotesettings = QolsysTableIqRemoteSettings(self.db,self.cursor)
|
56
|
-
self.table_iqrouter_network_config = QolsysTableIqRouterNetworkConfig(self.db,self.cursor)
|
57
|
-
self.table_iqrouter_user_device = QolsysTableIqRouterUserDevice(self.db,self.cursor)
|
58
|
-
self.table_master_slave = QolsysTableMasterSlave(self.db,self.cursor)
|
59
|
-
self.table_partition = QolsysTablePartition(self.db,self.cursor)
|
60
|
-
self.table_powerg_device = QolsysTablePowerGDevice(self.db,self.cursor)
|
61
|
-
self.table_sensor = QolsysTableSensor(self.db,self.cursor)
|
62
|
-
self.table_smartsocket = QolsysTableSmartSocket(self.db,self.cursor)
|
63
|
-
self.table_qolsyssettings = QolsysTableQolsysSettings(self.db,self.cursor)
|
64
|
-
self.table_scene = QolsysTableScene(self.db,self.cursor)
|
65
|
-
self.table_state = QolsysTableState(self.db,self.cursor)
|
66
|
-
self.table_tcc = QolsysTableTcc(self.db,self.cursor)
|
67
|
-
self.table_thermostat = QolsysTableThermostat(self.db,self.cursor)
|
68
|
-
self.table_trouble_conditions = QolsysTableTroubleConditions(self.db,self.cursor)
|
69
|
-
self.table_user = QolsysTableUser(self.db,self.cursor)
|
70
|
-
self.table_virtual_device = QolsysTableVirtualDevice(self.db,self.cursor)
|
71
|
-
self.table_weather = QolsysTableWeather(self.db,self.cursor)
|
72
|
-
self.table_zigbee_device = QolsysTableZigbeeDevice(self.db,self.cursor)
|
73
|
-
self.table_zwave_association_goup = QolsysTableZwaveAssociationGroup(self.db,self.cursor)
|
74
|
-
self.table_zwave_history = QolsysTableZwaveHistory(self.db,self.cursor)
|
75
|
-
self.table_zwave_node = QolsysTableZwaveNode(self.db,self.cursor)
|
76
|
-
self.table_zwave_other = QolsysTableZwaveOther(self.db,self.cursor)
|
44
|
+
self._db: sqlite3.Connection = sqlite3.connect(":memory:")
|
45
|
+
self._cursor: sqlite3.Cursor = self._db.cursor()
|
46
|
+
|
47
|
+
self.table_alarmedsensor = QolsysTableAlarmedSensor(self.db, self.cursor)
|
48
|
+
self.table_automation = QolsysTableAutomation(self.db, self.cursor)
|
49
|
+
self.table_country_locale = QolsysTableCountryLocale(self.db, self.cursor)
|
50
|
+
self.table_dashboard_msgs = QolsysTableDashboardMsgs(self.db, self.cursor)
|
51
|
+
self.table_dimmer = QolsysTableDimmerLight(self.db, self.cursor)
|
52
|
+
self.table_doorlock = QolsysTableDoorLock(self.db, self.cursor)
|
53
|
+
self.table_eu_event = QolsysTableEuEvent(self.db, self.cursor)
|
54
|
+
self.table_heat_map = QolsysTableHeatMap(self.db, self.cursor)
|
55
|
+
self.table_history = QolsysTableHistory(self.db, self.cursor)
|
56
|
+
self.table_iqremotesettings = QolsysTableIqRemoteSettings(self.db, self.cursor)
|
57
|
+
self.table_iqrouter_network_config = QolsysTableIqRouterNetworkConfig(self.db, self.cursor)
|
58
|
+
self.table_iqrouter_user_device = QolsysTableIqRouterUserDevice(self.db, self.cursor)
|
59
|
+
self.table_master_slave = QolsysTableMasterSlave(self.db, self.cursor)
|
60
|
+
self.table_partition = QolsysTablePartition(self.db, self.cursor)
|
61
|
+
self.table_powerg_device = QolsysTablePowerGDevice(self.db, self.cursor)
|
62
|
+
self.table_sensor = QolsysTableSensor(self.db, self.cursor)
|
63
|
+
self.table_smartsocket = QolsysTableSmartSocket(self.db, self.cursor)
|
64
|
+
self.table_qolsyssettings = QolsysTableQolsysSettings(self.db, self.cursor)
|
65
|
+
self.table_scene = QolsysTableScene(self.db, self.cursor)
|
66
|
+
self.table_state = QolsysTableState(self.db, self.cursor)
|
67
|
+
self.table_tcc = QolsysTableTcc(self.db, self.cursor)
|
68
|
+
self.table_thermostat = QolsysTableThermostat(self.db, self.cursor)
|
69
|
+
self.table_trouble_conditions = QolsysTableTroubleConditions(self.db, self.cursor)
|
70
|
+
self.table_user = QolsysTableUser(self.db, self.cursor)
|
71
|
+
self.table_virtual_device = QolsysTableVirtualDevice(self.db, self.cursor)
|
72
|
+
self.table_weather = QolsysTableWeather(self.db, self.cursor)
|
73
|
+
self.table_zigbee_device = QolsysTableZigbeeDevice(self.db, self.cursor)
|
74
|
+
self.table_zwave_association_goup = QolsysTableZwaveAssociationGroup(self.db, self.cursor)
|
75
|
+
self.table_zwave_history = QolsysTableZwaveHistory(self.db, self.cursor)
|
76
|
+
self.table_zwave_node = QolsysTableZwaveNode(self.db, self.cursor)
|
77
|
+
self.table_zwave_other = QolsysTableZwaveOther(self.db, self.cursor)
|
77
78
|
|
78
79
|
self._table_array = []
|
79
80
|
self._table_array.append(self.table_sensor)
|
@@ -143,108 +144,111 @@ class QolsysDB:
|
|
143
144
|
return self._cursor
|
144
145
|
|
145
146
|
def get_partitions(self) -> list[dict]:
|
146
|
-
self.cursor.execute(f"SELECT * FROM {self.table_partition.table} ORDER BY partition_id"
|
147
|
+
self.cursor.execute(f"SELECT * FROM {self.table_partition.table} ORDER BY partition_id")
|
147
148
|
self.db.commit()
|
148
149
|
|
149
150
|
partitions = []
|
150
151
|
columns = [description[0] for description in self.cursor.description]
|
151
|
-
for row in
|
152
|
+
for row in self.cursor.fetchall():
|
152
153
|
row_dict = dict(zip(columns, row, strict=True))
|
153
154
|
partitions.append(row_dict)
|
154
155
|
|
155
156
|
return partitions
|
156
157
|
|
157
158
|
def get_zwave_devices(self) -> list[dict]:
|
158
|
-
self.cursor.execute(f"SELECT * FROM {self.table_zwave_node.table} ORDER BY node_id"
|
159
|
+
self.cursor.execute(f"SELECT * FROM {self.table_zwave_node.table} ORDER BY node_id")
|
159
160
|
self.db.commit()
|
160
161
|
|
161
162
|
devices = []
|
162
163
|
columns = [description[0] for description in self.cursor.description]
|
163
|
-
for row in
|
164
|
+
for row in self.cursor.fetchall():
|
164
165
|
row_dict = dict(zip(columns, row, strict=True))
|
165
166
|
devices.append(row_dict)
|
166
167
|
|
167
168
|
return devices
|
168
169
|
|
169
170
|
def get_locks(self) -> list[dict]:
|
170
|
-
self.cursor.execute(f"SELECT * FROM {self.table_doorlock.table} ORDER BY node_id"
|
171
|
+
self.cursor.execute(f"SELECT * FROM {self.table_doorlock.table} ORDER BY node_id")
|
171
172
|
self.db.commit()
|
172
173
|
|
173
174
|
locks = []
|
174
175
|
columns = [description[0] for description in self.cursor.description]
|
175
|
-
for row in
|
176
|
+
for row in self.cursor.fetchall():
|
176
177
|
row_dict = dict(zip(columns, row, strict=True))
|
177
178
|
locks.append(row_dict)
|
178
179
|
|
179
180
|
return locks
|
180
181
|
|
181
182
|
def get_thermostats(self) -> list[dict]:
|
182
|
-
self.cursor.execute(f"SELECT * FROM {self.table_thermostat.table} ORDER BY node_id"
|
183
|
+
self.cursor.execute(f"SELECT * FROM {self.table_thermostat.table} ORDER BY node_id")
|
183
184
|
self.db.commit()
|
184
185
|
|
185
186
|
thermostats = []
|
186
187
|
columns = [description[0] for description in self.cursor.description]
|
187
|
-
for row in
|
188
|
+
for row in self.cursor.fetchall():
|
188
189
|
row_dict = dict(zip(columns, row, strict=True))
|
189
190
|
thermostats.append(row_dict)
|
190
191
|
|
191
192
|
return thermostats
|
192
193
|
|
193
194
|
def get_dimmers(self) -> list[dict]:
|
194
|
-
self.cursor.execute(f"SELECT * FROM {self.table_dimmer.table} ORDER BY node_id"
|
195
|
+
self.cursor.execute(f"SELECT * FROM {self.table_dimmer.table} ORDER BY node_id")
|
195
196
|
self.db.commit()
|
196
197
|
|
197
198
|
dimmers = []
|
198
199
|
columns = [description[0] for description in self.cursor.description]
|
199
|
-
for row in
|
200
|
+
for row in self.cursor.fetchall():
|
200
201
|
row_dict = dict(zip(columns, row, strict=True))
|
201
202
|
dimmers.append(row_dict)
|
202
203
|
|
203
204
|
return dimmers
|
204
205
|
|
205
206
|
def get_zones(self) -> list[dict]:
|
206
|
-
self.cursor.execute(f"SELECT * FROM {self.table_sensor.table} ORDER BY zoneid"
|
207
|
+
self.cursor.execute(f"SELECT * FROM {self.table_sensor.table} ORDER BY zoneid")
|
207
208
|
self.db.commit()
|
208
209
|
|
209
210
|
zones = []
|
210
211
|
columns = [description[0] for description in self.cursor.description]
|
211
|
-
for row in
|
212
|
+
for row in self.cursor.fetchall():
|
212
213
|
row_dict = dict(zip(columns, row, strict=True))
|
213
214
|
zones.append(row_dict)
|
214
215
|
|
215
216
|
return zones
|
216
217
|
|
217
|
-
def get_setting_panel(self,setting:str) -> str:
|
218
|
-
self.cursor.execute(f"SELECT value FROM {self.table_qolsyssettings.table}
|
218
|
+
def get_setting_panel(self, setting: str) -> str:
|
219
|
+
self.cursor.execute(f"""SELECT value FROM {self.table_qolsyssettings.table}
|
220
|
+
WHERE name = ? and partition_id = ? """, (setting, "0"))
|
219
221
|
row = self.cursor.fetchone()
|
220
222
|
|
221
223
|
if row is None:
|
222
|
-
LOGGER.debug("%s value not found",setting)
|
224
|
+
LOGGER.debug("%s value not found", setting)
|
223
225
|
return None
|
224
226
|
|
225
227
|
return row[0]
|
226
228
|
|
227
|
-
def get_setting_partition(self,setting:str,partition_id:str) -> str | None:
|
228
|
-
self.cursor.execute(f"SELECT value FROM {self.table_qolsyssettings.table}
|
229
|
+
def get_setting_partition(self, setting: str, partition_id: str) -> str | None:
|
230
|
+
self.cursor.execute(f"""SELECT value FROM {self.table_qolsyssettings.table}
|
231
|
+
WHERE name = ? and partition_id = ? """, (setting, partition_id))
|
229
232
|
row = self.cursor.fetchone()
|
230
233
|
|
231
234
|
if row is None:
|
232
|
-
LOGGER.debug("%s value not found",setting)
|
235
|
+
LOGGER.debug("%s value not found", setting)
|
233
236
|
return None
|
234
237
|
|
235
238
|
return row[0]
|
236
239
|
|
237
|
-
def get_state_partition(self,state:str,partition_id:str) -> str | None:
|
238
|
-
self.cursor.execute(
|
240
|
+
def get_state_partition(self, state: str, partition_id: str) -> str | None:
|
241
|
+
self.cursor.execute(
|
242
|
+
f"""SELECT value FROM {self.table_state.table} WHERE name = ? and partition_id = ? """, (state, partition_id))
|
239
243
|
row = self.cursor.fetchone()
|
240
244
|
|
241
245
|
if row is None:
|
242
|
-
LOGGER.debug("%s value not found",state)
|
246
|
+
LOGGER.debug("%s value not found", state)
|
243
247
|
return None
|
244
248
|
|
245
249
|
return row[0]
|
246
250
|
|
247
|
-
def get_alarm_type(self,partition_id:str) -> list[str]:
|
251
|
+
def get_alarm_type(self, partition_id: str) -> list[str]:
|
248
252
|
alarm_type = []
|
249
253
|
self.cursor.execute(f"SELECT sgroup FROM {self.table_alarmedsensor.table} WHERE partition_id = ? ", (partition_id))
|
250
254
|
rows = self.cursor.fetchall()
|
@@ -258,14 +262,14 @@ class QolsysDB:
|
|
258
262
|
for table in self._table_array:
|
259
263
|
table.clear()
|
260
264
|
|
261
|
-
def get_table(self,uri:str) -> QolsysTable | None:
|
265
|
+
def get_table(self, uri: str) -> QolsysTable | None:
|
262
266
|
for table in self._table_array:
|
263
267
|
if uri == table.uri:
|
264
268
|
return table
|
265
269
|
|
266
270
|
return None
|
267
271
|
|
268
|
-
def load_db(self,database:dict) -> None:
|
272
|
+
def load_db(self, database: dict) -> None:
|
269
273
|
|
270
274
|
self.clear_db()
|
271
275
|
|
@@ -5,19 +5,21 @@ from qolsys_controller.errors import QolsysSqlError
|
|
5
5
|
|
6
6
|
LOGGER = logging.getLogger(__name__)
|
7
7
|
|
8
|
+
|
8
9
|
class QolsysTable:
|
9
10
|
|
10
|
-
def __init__(self,db:sqlite3.Connection,cursor:sqlite3.Cursor) -> None:
|
11
|
-
self._db:sqlite3.Connection = db
|
12
|
-
self._cursor:sqlite3.Cursor = cursor
|
13
|
-
self._uri:str = ""
|
14
|
-
self._table:str = ""
|
15
|
-
self._columns:list[str] = []
|
16
|
-
self._abort_on_error:bool = False
|
11
|
+
def __init__(self, db: sqlite3.Connection, cursor: sqlite3.Cursor) -> None:
|
12
|
+
self._db: sqlite3.Connection = db
|
13
|
+
self._cursor: sqlite3.Cursor = cursor
|
14
|
+
self._uri: str = ""
|
15
|
+
self._table: str = ""
|
16
|
+
self._columns: list[str] = []
|
17
|
+
self._abort_on_error: bool = False
|
17
18
|
|
18
19
|
@property
|
19
20
|
def uri(self) -> str:
|
20
21
|
return self._uri
|
22
|
+
|
21
23
|
@property
|
22
24
|
def table(self) -> str:
|
23
25
|
return self._table
|
@@ -62,21 +64,20 @@ class QolsysTable:
|
|
62
64
|
})
|
63
65
|
|
64
66
|
if self._abort_on_error:
|
65
|
-
|
67
|
+
raise error from err
|
66
68
|
|
67
|
-
def update(self,selection:str,selection_argument:str,content_value:str) -> None:
|
68
|
-
# selection: 'zone_id=?, parition_id=?'
|
69
|
-
# selection_argument: '[3,1]'
|
69
|
+
def update(self, selection: str, selection_argument: str, content_value: str) -> None:
|
70
|
+
# selection: 'zone_id=?, parition_id=?'
|
71
|
+
# selection_argument: '[3,1]'
|
70
72
|
# "contentValues":{"partition_id":"0","sensorgroup":"safetymotion","sensorstatus":"Idle"}"
|
71
73
|
|
72
74
|
# Panel is sending query parameter for db update in text string
|
73
75
|
# Have not found a way to make it work with parametrized query yet
|
74
76
|
# Using f string concat for moment ...
|
75
77
|
|
76
|
-
|
77
78
|
# New Values to update in table
|
78
|
-
# To change for parametrized
|
79
|
-
db_value = ",".join([f"{key}='{value}'" for key,value in content_value.items()])
|
79
|
+
# To change for parametrized
|
80
|
+
db_value = ",".join([f"{key}='{value}'" for key, value in content_value.items()])
|
80
81
|
|
81
82
|
# Selection Argument
|
82
83
|
selection_argument = selection_argument.strip("[]")
|
@@ -84,7 +85,7 @@ class QolsysTable:
|
|
84
85
|
|
85
86
|
try:
|
86
87
|
query = f"UPDATE {self.table} SET {db_value} WHERE {selection}"
|
87
|
-
self._cursor.execute(query,selection_argument)
|
88
|
+
self._cursor.execute(query, selection_argument)
|
88
89
|
self._db.commit()
|
89
90
|
|
90
91
|
except sqlite3.Error as err:
|
@@ -98,25 +99,25 @@ class QolsysTable:
|
|
98
99
|
})
|
99
100
|
|
100
101
|
if self._abort_on_error:
|
101
|
-
|
102
|
+
raise error from err
|
102
103
|
|
103
104
|
def insert(self) -> None:
|
104
105
|
pass
|
105
106
|
|
106
|
-
def delete(self,selection:str,selection_argument:str) -> None:
|
107
|
-
# selection: 'zone_id=?, parition_id=?'
|
108
|
-
# selection_argument: '[3,1]'
|
107
|
+
def delete(self, selection: str, selection_argument: str) -> None:
|
108
|
+
# selection: 'zone_id=?, parition_id=?'
|
109
|
+
# selection_argument: '[3,1]'
|
109
110
|
|
110
111
|
selection_argument = selection_argument.strip("[]")
|
111
112
|
selection_argument = [item.strip() for item in selection_argument.split(",")]
|
112
113
|
|
113
114
|
# Replace '?' in selection string with selection_argument
|
114
|
-
#for i in selection_argument:
|
115
|
-
# selection = selection.replace("?",f"'{i}'",1)
|
115
|
+
# for i in selection_argument:
|
116
|
+
# selection = selection.replace("?",f"'{i}'",1)
|
116
117
|
|
117
118
|
try:
|
118
119
|
query = f"DELETE FROM {self.table} WHERE {selection}"
|
119
|
-
self._cursor.execute(query,selection_argument)
|
120
|
+
self._cursor.execute(query, selection_argument)
|
120
121
|
self._db.commit()
|
121
122
|
|
122
123
|
except sqlite3.Error as err:
|
@@ -129,6 +130,4 @@ class QolsysTable:
|
|
129
130
|
})
|
130
131
|
|
131
132
|
if self._abort_on_error:
|
132
|
-
|
133
|
-
|
134
|
-
|
133
|
+
raise error from err
|
@@ -5,10 +5,11 @@ from .table import QolsysTable
|
|
5
5
|
|
6
6
|
LOGGER = logging.getLogger(__name__)
|
7
7
|
|
8
|
+
|
8
9
|
class QolsysTableAlarmedSensor(QolsysTable):
|
9
10
|
|
10
|
-
def __init__(self,db:sqlite3.Connection,cursor:sqlite3.Cursor) -> None:
|
11
|
-
super().__init__(db,cursor)
|
11
|
+
def __init__(self, db: sqlite3.Connection, cursor: sqlite3.Cursor) -> None:
|
12
|
+
super().__init__(db, cursor)
|
12
13
|
self._uri = "content://com.qolsys.qolsysprovider.AlarmedSensorProvider/alarmedsensor"
|
13
14
|
self._table = "alarmedsensor"
|
14
15
|
self._abort_on_error = True
|
@@ -28,18 +29,18 @@ class QolsysTableAlarmedSensor(QolsysTable):
|
|
28
29
|
|
29
30
|
self._create_table()
|
30
31
|
|
31
|
-
def insert(self, data:dict) -> None:
|
32
|
-
self._cursor.execute(f"INSERT INTO {self.table} (_id,partition_id,silenced,zone_id,sgroup,action,timed_out,type,
|
32
|
+
def insert(self, data: dict) -> None:
|
33
|
+
self._cursor.execute(f"""INSERT INTO {self.table} (_id,partition_id,silenced,zone_id,sgroup,action,timed_out,type,
|
34
|
+
priority,aseb_type) VALUES (?,?,?,?,?,?,?,?,?,?)""", (
|
33
35
|
data.get("_id"),
|
34
|
-
data.get("partition_id",""),
|
35
|
-
data.get("silenced",""),
|
36
|
-
data.get("zone_id",""),
|
37
|
-
data.get("sgroup",""),
|
38
|
-
data.get("action",""),
|
39
|
-
data.get("timed_out",""),
|
40
|
-
data.get("type",""),
|
41
|
-
data.get("priority",""),
|
42
|
-
data.get("aseb_type","")))
|
36
|
+
data.get("partition_id", ""),
|
37
|
+
data.get("silenced", ""),
|
38
|
+
data.get("zone_id", ""),
|
39
|
+
data.get("sgroup", ""),
|
40
|
+
data.get("action", ""),
|
41
|
+
data.get("timed_out", ""),
|
42
|
+
data.get("type", ""),
|
43
|
+
data.get("priority", ""),
|
44
|
+
data.get("aseb_type", "")))
|
43
45
|
|
44
46
|
self._db.commit()
|
45
|
-
|
@@ -5,10 +5,11 @@ from .table import QolsysTable
|
|
5
5
|
|
6
6
|
LOGGER = logging.getLogger(__name__)
|
7
7
|
|
8
|
+
|
8
9
|
class QolsysTableAutomation(QolsysTable):
|
9
10
|
|
10
|
-
def __init__(self,db:sqlite3.Connection,cursor:sqlite3.Cursor) -> None:
|
11
|
-
super().__init__(db,cursor)
|
11
|
+
def __init__(self, db: sqlite3.Connection, cursor: sqlite3.Cursor) -> None:
|
12
|
+
super().__init__(db, cursor)
|
12
13
|
self._uri = "content://com.qolsys.qolsysprovider.AutomationDeviceContentProvider/automation"
|
13
14
|
self._table = "automation"
|
14
15
|
self._abort_on_error = False
|
@@ -42,32 +43,35 @@ class QolsysTableAutomation(QolsysTable):
|
|
42
43
|
|
43
44
|
self._create_table()
|
44
45
|
|
45
|
-
def insert(self, data:dict) -> None:
|
46
|
-
self._cursor.execute(f"INSERT INTO {self.table} (_id,virtual_node_id,version,opr,partition_id,end_point,extras,
|
46
|
+
def insert(self, data: dict) -> None:
|
47
|
+
self._cursor.execute(f"""INSERT INTO {self.table} (_id,virtual_node_id,version,opr,partition_id,end_point,extras,
|
48
|
+
is_autolocking_enabled,device_type,endpoint_secure_cmd_classes,automation_id,device_name,
|
49
|
+
protocol,node_battery_level_value,state,last_updated_date,manufacturer_id,
|
50
|
+
endpoint_cmd_classes,device_id,nodeid_cmd_classes,is_device_hidden,nodeid_secure_cmd_classes,
|
51
|
+
created_date,status) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)""", (
|
47
52
|
data.get("_id"),
|
48
|
-
data.get("virtual_node_id",""),
|
49
|
-
data.get("version",""),
|
50
|
-
data.get("opr",""),
|
51
|
-
data.get("partition_id",""),
|
52
|
-
data.get("end_point",""),
|
53
|
-
data.get("extras",""),
|
54
|
-
data.get("is_autolocking_enabled",""),
|
55
|
-
data.get("device_type",""),
|
56
|
-
data.get("endpoint_secure_cmd_classes",""),
|
57
|
-
data.get("automation_id",""),
|
58
|
-
data.get("device_name",""),
|
59
|
-
data.get("protocol",""),
|
60
|
-
data.get("node_battery_level_value",""),
|
61
|
-
data.get("state",""),
|
62
|
-
data.get("last_updated_date",""),
|
63
|
-
data.get("manufacturer_id",""),
|
64
|
-
data.get("endpoint_cmd_classes",""),
|
65
|
-
data.get("device_id",""),
|
66
|
-
data.get("nodeid_cmd_classes",""),
|
67
|
-
data.get("is_device_hidden",""),
|
68
|
-
data.get("nodeid_secure_cmd_classes",""),
|
69
|
-
data.get("created_date",""),
|
70
|
-
data.get("status","")))
|
53
|
+
data.get("virtual_node_id", ""),
|
54
|
+
data.get("version", ""),
|
55
|
+
data.get("opr", ""),
|
56
|
+
data.get("partition_id", ""),
|
57
|
+
data.get("end_point", ""),
|
58
|
+
data.get("extras", ""),
|
59
|
+
data.get("is_autolocking_enabled", ""),
|
60
|
+
data.get("device_type", ""),
|
61
|
+
data.get("endpoint_secure_cmd_classes", ""),
|
62
|
+
data.get("automation_id", ""),
|
63
|
+
data.get("device_name", ""),
|
64
|
+
data.get("protocol", ""),
|
65
|
+
data.get("node_battery_level_value", ""),
|
66
|
+
data.get("state", ""),
|
67
|
+
data.get("last_updated_date", ""),
|
68
|
+
data.get("manufacturer_id", ""),
|
69
|
+
data.get("endpoint_cmd_classes", ""),
|
70
|
+
data.get("device_id", ""),
|
71
|
+
data.get("nodeid_cmd_classes", ""),
|
72
|
+
data.get("is_device_hidden", ""),
|
73
|
+
data.get("nodeid_secure_cmd_classes", ""),
|
74
|
+
data.get("created_date", ""),
|
75
|
+
data.get("status", "")))
|
71
76
|
|
72
77
|
self._db.commit()
|
73
|
-
|
@@ -5,10 +5,11 @@ from .table import QolsysTable
|
|
5
5
|
|
6
6
|
LOGGER = logging.getLogger(__name__)
|
7
7
|
|
8
|
+
|
8
9
|
class QolsysTableCountryLocale(QolsysTable):
|
9
10
|
|
10
|
-
def __init__(self,db:sqlite3.Connection,cursor:sqlite3.Cursor) -> None:
|
11
|
-
super().__init__(db,cursor)
|
11
|
+
def __init__(self, db: sqlite3.Connection, cursor: sqlite3.Cursor) -> None:
|
12
|
+
super().__init__(db, cursor)
|
12
13
|
self._uri = "content://com.qolsys.qolsysprovider.CountryLocaleContentProvider/country_locale"
|
13
14
|
self._table = "country_locale"
|
14
15
|
self._abort_on_error = False
|
@@ -34,24 +35,26 @@ class QolsysTableCountryLocale(QolsysTable):
|
|
34
35
|
|
35
36
|
self._create_table()
|
36
37
|
|
37
|
-
def insert(self, data:dict) -> None:
|
38
|
-
self._cursor.execute(f"INSERT INTO {self.table} (_id,version,opr,partition_id,country,language,alpha2_code,
|
38
|
+
def insert(self, data: dict) -> None:
|
39
|
+
self._cursor.execute(f"""INSERT INTO {self.table} (_id,version,opr,partition_id,country,language,alpha2_code,
|
40
|
+
language_code,date_format_enum,hour_format,temp_format,is_active,date_separator,
|
41
|
+
zwave_region_frequency_code,zwave_region_frequency,zwave_region_prop_values)
|
42
|
+
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)""", (
|
39
43
|
data.get("_id"),
|
40
|
-
data.get("version",""),
|
41
|
-
data.get("opr",""),
|
42
|
-
data.get("partition_id",""),
|
43
|
-
data.get("country",""),
|
44
|
-
data.get("language",""),
|
45
|
-
data.get("alpha2_code",""),
|
46
|
-
data.get("language_code",""),
|
47
|
-
data.get("date_format_enum",""),
|
48
|
-
data.get("hour_format",""),
|
49
|
-
data.get("temp_format",""),
|
50
|
-
data.get("is_active",""),
|
51
|
-
data.get("date_separator",""),
|
52
|
-
data.get("zwave_region_frequency_code",""),
|
53
|
-
data.get("zwave_region_frequency",""),
|
54
|
-
data.get("zwave_region_prop_values","")))
|
44
|
+
data.get("version", ""),
|
45
|
+
data.get("opr", ""),
|
46
|
+
data.get("partition_id", ""),
|
47
|
+
data.get("country", ""),
|
48
|
+
data.get("language", ""),
|
49
|
+
data.get("alpha2_code", ""),
|
50
|
+
data.get("language_code", ""),
|
51
|
+
data.get("date_format_enum", ""),
|
52
|
+
data.get("hour_format", ""),
|
53
|
+
data.get("temp_format", ""),
|
54
|
+
data.get("is_active", ""),
|
55
|
+
data.get("date_separator", ""),
|
56
|
+
data.get("zwave_region_frequency_code", ""),
|
57
|
+
data.get("zwave_region_frequency", ""),
|
58
|
+
data.get("zwave_region_prop_values", "")))
|
55
59
|
|
56
60
|
self._db.commit()
|
57
|
-
|
@@ -5,10 +5,11 @@ from .table import QolsysTable
|
|
5
5
|
|
6
6
|
LOGGER = logging.getLogger(__name__)
|
7
7
|
|
8
|
+
|
8
9
|
class QolsysTableDashboardMsgs(QolsysTable):
|
9
10
|
|
10
|
-
def __init__(self,db:sqlite3.Connection,cursor:sqlite3.Cursor) -> None:
|
11
|
-
super().__init__(db,cursor)
|
11
|
+
def __init__(self, db: sqlite3.Connection, cursor: sqlite3.Cursor) -> None:
|
12
|
+
super().__init__(db, cursor)
|
12
13
|
self._uri = "content://com.qolsys.qolsysprovider.DashboardMessagesContentProvider/dashboard_msgs"
|
13
14
|
self._table = "dashboard_msgs"
|
14
15
|
self._abort_on_error = False
|
@@ -30,8 +31,9 @@ class QolsysTableDashboardMsgs(QolsysTable):
|
|
30
31
|
|
31
32
|
self._create_table()
|
32
33
|
|
33
|
-
def insert(self, data:dict) -> None:
|
34
|
-
self._cursor.execute(f"INSERT INTO {self.table} (_id,version,opr,partition_id,msg_id,title,description,
|
34
|
+
def insert(self, data: dict) -> None:
|
35
|
+
self._cursor.execute(f"""INSERT INTO {self.table} (_id,version,opr,partition_id,msg_id,title,description,
|
36
|
+
received_time,start_time,end_time,read,mime_type) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)""", (
|
35
37
|
data.get("_id"),
|
36
38
|
data.get("version"),
|
37
39
|
data.get("opr"),
|
@@ -46,4 +48,3 @@ class QolsysTableDashboardMsgs(QolsysTable):
|
|
46
48
|
data.get("mime_type")))
|
47
49
|
|
48
50
|
self._db.commit()
|
49
|
-
|