qolsys-controller 0.0.2__py3-none-any.whl → 0.0.4__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 +147 -146
- 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 +75 -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.4.dist-info}/METADATA +1 -1
- qolsys_controller-0.0.4.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.4.dist-info}/WHEEL +0 -0
- {qolsys_controller-0.0.2.dist-info → qolsys_controller-0.0.4.dist-info}/licenses/LICENSE +0 -0
qolsys_controller/settings.py
CHANGED
@@ -1,21 +1,37 @@
|
|
1
1
|
import logging
|
2
|
+
from pathlib import Path
|
2
3
|
|
3
4
|
LOGGER = logging.getLogger(__name__)
|
4
5
|
|
6
|
+
|
5
7
|
class QolsysSettings:
|
6
8
|
|
7
9
|
def __init__(self) -> None:
|
10
|
+
|
11
|
+
# Plugin
|
8
12
|
self._plugin_ip = ""
|
9
13
|
self._random_mac = ""
|
10
14
|
self._panel_mac = ""
|
11
15
|
self._panel_ip = ""
|
12
16
|
|
17
|
+
self._config_directory: Path = Path()
|
18
|
+
self._pki_directory: Path = Path()
|
19
|
+
self._media_directory: Path = Path()
|
20
|
+
self._users_file_path: Path = Path()
|
21
|
+
|
22
|
+
# Pki
|
23
|
+
self._key_size: int = 2048
|
24
|
+
|
25
|
+
# MQTT
|
26
|
+
self._mqtt_timeout: int = 30
|
27
|
+
self._mqtt_ping: int = 600
|
28
|
+
|
13
29
|
@property
|
14
30
|
def random_mac(self) -> str:
|
15
31
|
return self._random_mac
|
16
32
|
|
17
33
|
@random_mac.setter
|
18
|
-
def random_mac(self,random_mac:str) -> None:
|
34
|
+
def random_mac(self, random_mac: str) -> None:
|
19
35
|
self._random_mac = random_mac
|
20
36
|
|
21
37
|
@property
|
@@ -27,7 +43,7 @@ class QolsysSettings:
|
|
27
43
|
return self._panel_mac
|
28
44
|
|
29
45
|
@panel_mac.setter
|
30
|
-
def panel_mac(self,panel_mac:str) -> None:
|
46
|
+
def panel_mac(self, panel_mac: str) -> None:
|
31
47
|
self._panel_mac = panel_mac
|
32
48
|
|
33
49
|
@property
|
@@ -35,25 +51,76 @@ class QolsysSettings:
|
|
35
51
|
return self._panel_ip
|
36
52
|
|
37
53
|
@panel_ip.setter
|
38
|
-
def panel_ip(self, panel_ip:str) -> None:
|
54
|
+
def panel_ip(self, panel_ip: str) -> None:
|
39
55
|
self._panel_ip = panel_ip
|
40
56
|
|
41
57
|
@plugin_ip.setter
|
42
|
-
def plugin_ip(self,plugin_ip:str) -> None:
|
58
|
+
def plugin_ip(self, plugin_ip: str) -> None:
|
43
59
|
self._plugin_ip = plugin_ip
|
44
60
|
|
61
|
+
@property
|
62
|
+
def config_directory(self) -> str:
|
63
|
+
return self._config_directory
|
64
|
+
|
65
|
+
@config_directory.setter
|
66
|
+
def config_directory(self, config_directory: str) -> None:
|
67
|
+
self._config_directory = Path(config_directory)
|
68
|
+
self._pki_directory = self._config_directory.joinpath("pki")
|
69
|
+
self._media_directory = self._config_directory.joinpath("media")
|
70
|
+
self._users_file_path = self._config_directory.joinpath("users.conf")
|
71
|
+
|
72
|
+
@property
|
73
|
+
def pki_directory(self) -> Path:
|
74
|
+
return self._pki_directory
|
75
|
+
|
76
|
+
@property
|
77
|
+
def users_file_path(self) -> Path:
|
78
|
+
return self._users_file_path
|
79
|
+
|
80
|
+
@property
|
81
|
+
def key_size(self) -> int:
|
82
|
+
return self._key_size
|
83
|
+
|
84
|
+
@property
|
85
|
+
def mqtt_timeout(self) -> int:
|
86
|
+
return self._mqtt_timeout
|
87
|
+
|
88
|
+
@property
|
89
|
+
def mqtt_ping(self) -> int:
|
90
|
+
return self._mqtt_ping
|
91
|
+
|
45
92
|
def check_panel_ip(self) -> bool:
|
46
93
|
if self._panel_ip == "":
|
47
|
-
LOGGER.debug("Invalid Panel IP: %s",self._panel_ip)
|
94
|
+
LOGGER.debug("Invalid Panel IP: %s", self._panel_ip)
|
48
95
|
return False
|
49
96
|
|
50
|
-
LOGGER.debug("Found Panel IP: %s",self._panel_ip)
|
97
|
+
LOGGER.debug("Found Panel IP: %s", self._panel_ip)
|
51
98
|
return True
|
52
99
|
|
53
100
|
def check_plugin_ip(self) -> bool:
|
54
101
|
if self._plugin_ip == "":
|
55
|
-
LOGGER.debug("Invalid Plugin IP: %s",self._plugin_ip)
|
102
|
+
LOGGER.debug("Invalid Plugin IP: %s", self._plugin_ip)
|
56
103
|
return False
|
57
104
|
|
58
|
-
LOGGER.debug("Found Plugin IP: %s",self._plugin_ip)
|
105
|
+
LOGGER.debug("Found Plugin IP: %s", self._plugin_ip)
|
106
|
+
return True
|
107
|
+
|
108
|
+
def check_config_directory(self, create: bool = True) -> bool:
|
109
|
+
if not self.config_directory.is_dir():
|
110
|
+
if not create:
|
111
|
+
LOGGER.debug("config_directory not found: %s", self.config_directory)
|
112
|
+
return False
|
113
|
+
|
114
|
+
# Create config directory if not found
|
115
|
+
LOGGER.debug("Creating config_directory: %s", self.config_directory)
|
116
|
+
try:
|
117
|
+
self.config_directory.mkdir(parents=True)
|
118
|
+
except PermissionError:
|
119
|
+
LOGGER.exception("Permission denied: Unable to create: %s", self.config_directory)
|
120
|
+
return False
|
121
|
+
except Exception:
|
122
|
+
LOGGER.exception("Error creating config_directory: %s", self.config_directory)
|
123
|
+
return False
|
124
|
+
|
125
|
+
LOGGER.debug("Using config_directory: %s", self.config_directory.resolve())
|
59
126
|
return True
|
qolsys_controller/state.py
CHANGED
@@ -11,6 +11,7 @@ from .zwave_thermostat import QolsysThermostat
|
|
11
11
|
|
12
12
|
LOGGER = logging.getLogger(__name__)
|
13
13
|
|
14
|
+
|
14
15
|
class QolsysState(QolsysObservable):
|
15
16
|
|
16
17
|
def __init__(self) -> None:
|
@@ -40,7 +41,7 @@ class QolsysState(QolsysObservable):
|
|
40
41
|
def zwave_dimmers(self) -> list[QolsysDimmer]:
|
41
42
|
dimmers = []
|
42
43
|
for device in self.zwave_devices:
|
43
|
-
if isinstance(device,QolsysDimmer):
|
44
|
+
if isinstance(device, QolsysDimmer):
|
44
45
|
dimmers.append(device)
|
45
46
|
|
46
47
|
return dimmers
|
@@ -49,7 +50,7 @@ class QolsysState(QolsysObservable):
|
|
49
50
|
def zwave_locks(self) -> list[QolsysLock]:
|
50
51
|
locks = []
|
51
52
|
for device in self.zwave_devices:
|
52
|
-
if isinstance(device,QolsysLock):
|
53
|
+
if isinstance(device, QolsysLock):
|
53
54
|
locks.append(device)
|
54
55
|
|
55
56
|
return locks
|
@@ -58,7 +59,7 @@ class QolsysState(QolsysObservable):
|
|
58
59
|
def zwave_thermostats(self) -> list[QolsysThermostat]:
|
59
60
|
thermostats = []
|
60
61
|
for device in self.zwave_devices:
|
61
|
-
if isinstance(device,QolsysThermostat):
|
62
|
+
if isinstance(device, QolsysThermostat):
|
62
63
|
thermostats.append(device)
|
63
64
|
|
64
65
|
return thermostats
|
@@ -75,85 +76,87 @@ class QolsysState(QolsysObservable):
|
|
75
76
|
def state_zwave_observer(self) -> QolsysObservable:
|
76
77
|
return self._state_zwave_observer
|
77
78
|
|
78
|
-
def partition(self, partition_id:str) -> QolsysPartition:
|
79
|
+
def partition(self, partition_id: str) -> QolsysPartition:
|
79
80
|
for partition in self.partitions:
|
80
81
|
if partition.id == partition_id:
|
81
82
|
return partition
|
82
83
|
|
83
84
|
return None
|
84
85
|
|
85
|
-
def partition_add(self,new_partition:QolsysPartition) -> None:
|
86
|
+
def partition_add(self, new_partition: QolsysPartition) -> None:
|
86
87
|
for partition in self.partitions:
|
87
88
|
if new_partition.id == partition.id:
|
88
|
-
LOGGER.debug("Adding Partition to State, Partition%s (%s) - Allready in Partitions List",
|
89
|
+
LOGGER.debug("Adding Partition to State, Partition%s (%s) - Allready in Partitions List",
|
90
|
+
new_partition.id, partition.name)
|
89
91
|
return
|
90
92
|
|
91
93
|
self.partitions.append(new_partition)
|
92
94
|
self.state_partition_observer.notify()
|
93
95
|
|
94
|
-
def partition_delete(self,partition_id:str) -> None:
|
96
|
+
def partition_delete(self, partition_id: str) -> None:
|
95
97
|
partition = self.partition(partition_id)
|
96
98
|
|
97
99
|
if partition is None:
|
98
|
-
LOGGER.debug("Deleting Partition from State, Partition%s not found",partition_id)
|
100
|
+
LOGGER.debug("Deleting Partition from State, Partition%s not found", partition_id)
|
99
101
|
return
|
100
102
|
|
101
103
|
self.partitions.remove(partition)
|
102
104
|
self.state_partition_observer.notify()
|
103
105
|
|
104
|
-
def zone(self,zone_id:str) -> QolsysZone:
|
106
|
+
def zone(self, zone_id: str) -> QolsysZone:
|
105
107
|
for zone in self.zones:
|
106
108
|
if zone.zone_id == zone_id:
|
107
109
|
return zone
|
108
110
|
|
109
111
|
return None
|
110
112
|
|
111
|
-
def zone_add(self, new_zone:QolsysZone) -> None:
|
113
|
+
def zone_add(self, new_zone: QolsysZone) -> None:
|
112
114
|
for zone in self.zones:
|
113
115
|
if new_zone.zone_id == zone.zone_id:
|
114
|
-
LOGGER.debug("Adding Zone to State, zone%s (%s) - Allready in Zone List",new_zone.zone_id,self.sensorname)
|
116
|
+
LOGGER.debug("Adding Zone to State, zone%s (%s) - Allready in Zone List", new_zone.zone_id, self.sensorname)
|
115
117
|
return
|
116
118
|
|
117
119
|
self.zones.append(new_zone)
|
118
120
|
self.state_zone_observer.notify()
|
119
121
|
|
120
|
-
def zone_delete(self,zone_id:str) -> None:
|
122
|
+
def zone_delete(self, zone_id: str) -> None:
|
121
123
|
zone = self.zone(zone_id)
|
122
124
|
|
123
125
|
if zone is None:
|
124
|
-
LOGGER.debug("Deleting Zone from State, Zone%s not found",zone_id)
|
126
|
+
LOGGER.debug("Deleting Zone from State, Zone%s not found", zone_id)
|
125
127
|
return
|
126
128
|
|
127
129
|
self.zones.remove(zone)
|
128
130
|
self.state_zone_observer.notify()
|
129
131
|
|
130
|
-
def zwave_device(self,node_id:str) -> QolsysZWaveDevice:
|
132
|
+
def zwave_device(self, node_id: str) -> QolsysZWaveDevice:
|
131
133
|
for zwave_device in self.zwave_devices:
|
132
134
|
if zwave_device.node_id == node_id:
|
133
135
|
return zwave_device
|
134
136
|
|
135
137
|
return None
|
136
138
|
|
137
|
-
def zwave_add(self, new_zwave:QolsysZWaveDevice) -> None:
|
139
|
+
def zwave_add(self, new_zwave: QolsysZWaveDevice) -> None:
|
138
140
|
for zwave_device in self.zwave_devices:
|
139
141
|
if new_zwave.node_id == zwave_device.node_id:
|
140
|
-
LOGGER.debug("Adding ZWave to State, ZWave%s (%s) - Allready in ZWave List",
|
142
|
+
LOGGER.debug("Adding ZWave to State, ZWave%s (%s) - Allready in ZWave List",
|
143
|
+
new_zwave.node_id, zwave_device.node_name)
|
141
144
|
return
|
142
145
|
|
143
146
|
self.zwave_devices.append(new_zwave)
|
144
147
|
self.state_zwave_observer.notify()
|
145
148
|
|
146
|
-
def zwave_delete(self,node_id:str) -> None:
|
149
|
+
def zwave_delete(self, node_id: str) -> None:
|
147
150
|
zwave = self.zwave_device(node_id)
|
148
151
|
|
149
152
|
if zwave is None:
|
150
|
-
LOGGER.debug("Deleting ZWave from State, ZWave%s not found",node_id)
|
153
|
+
LOGGER.debug("Deleting ZWave from State, ZWave%s not found", node_id)
|
151
154
|
return
|
152
155
|
|
153
156
|
self.zwave_devices.remove(zwave)
|
154
157
|
self.state_zwave_observer.notify()
|
155
158
|
|
156
|
-
def sync_zwave_devices_data(self,db_zwaves:list[QolsysZWaveDevice]) -> None: # noqa: C901, PLR0912
|
159
|
+
def sync_zwave_devices_data(self, db_zwaves: list[QolsysZWaveDevice]) -> None: # noqa: C901, PLR0912
|
157
160
|
|
158
161
|
db_zwave_list = []
|
159
162
|
for db_zwave in db_zwaves:
|
@@ -168,28 +171,28 @@ class QolsysState(QolsysObservable):
|
|
168
171
|
if state_zwave.node_id in db_zwave_list:
|
169
172
|
for db_zwave in db_zwaves:
|
170
173
|
if state_zwave.node_id == db_zwave.node_id:
|
171
|
-
LOGGER.debug("sync_data - update ZWave%s",state_zwave.node_id)
|
174
|
+
LOGGER.debug("sync_data - update ZWave%s", state_zwave.node_id)
|
172
175
|
|
173
176
|
# Update Dimmer
|
174
|
-
if isinstance(state_zwave, QolsysDimmer) and isinstance(db_zwave,QolsysDimmer):
|
177
|
+
if isinstance(state_zwave, QolsysDimmer) and isinstance(db_zwave, QolsysDimmer):
|
175
178
|
state_zwave.update_base(db_zwave.to_dict_base())
|
176
179
|
state_zwave.update_dimmer(db_zwave.to_dict_dimmer())
|
177
180
|
break
|
178
181
|
|
179
182
|
# Update Thermostat
|
180
|
-
if isinstance(state_zwave,QolsysThermostat) and isinstance(db_zwave,QolsysThermostat):
|
183
|
+
if isinstance(state_zwave, QolsysThermostat) and isinstance(db_zwave, QolsysThermostat):
|
181
184
|
state_zwave.update_base(db_zwave.to_dict_base())
|
182
185
|
state_zwave.update_thermostat(db_zwave.to_dict_base())
|
183
186
|
break
|
184
187
|
|
185
188
|
# Update Lock
|
186
|
-
if isinstance(state_zwave,QolsysLock) and isinstance(db_zwave,QolsysLock):
|
189
|
+
if isinstance(state_zwave, QolsysLock) and isinstance(db_zwave, QolsysLock):
|
187
190
|
state_zwave.update_base(db_zwave.to_dict_base())
|
188
191
|
state_zwave.update_lock(db_zwave.to_dict_base())
|
189
192
|
break
|
190
193
|
|
191
194
|
# Generic Z-Wave Device
|
192
|
-
if isinstance(state_zwave,QolsysGeneric) and isinstance(db_zwave,QolsysGeneric):
|
195
|
+
if isinstance(state_zwave, QolsysGeneric) and isinstance(db_zwave, QolsysGeneric):
|
193
196
|
state_zwave.update_base(db_zwave.to_dict_base())
|
194
197
|
break
|
195
198
|
|
@@ -200,16 +203,16 @@ class QolsysState(QolsysObservable):
|
|
200
203
|
# Add new zwave device
|
201
204
|
for db_zwave in db_zwaves:
|
202
205
|
if db_zwave.node_id not in state_zwave_list:
|
203
|
-
LOGGER.debug("sync_data - add ZWave%s",db_zwave.node_id)
|
206
|
+
LOGGER.debug("sync_data - add ZWave%s", db_zwave.node_id)
|
204
207
|
self.zwave_add(db_zwave)
|
205
208
|
|
206
209
|
# Delete zwave device
|
207
210
|
for state_zwave in self.zwave_devices:
|
208
211
|
if state_zwave.node_id not in db_zwave_list:
|
209
|
-
LOGGER.debug("sync_data - delete ZWave%s",state_zwave.none_id)
|
212
|
+
LOGGER.debug("sync_data - delete ZWave%s", state_zwave.none_id)
|
210
213
|
self.zwave_delete(int(state_zwave.node_id))
|
211
214
|
|
212
|
-
def sync_zones_data(self, db_zones:list[QolsysZone]) -> None: # noqa: C901
|
215
|
+
def sync_zones_data(self, db_zones: list[QolsysZone]) -> None: # noqa: C901
|
213
216
|
db_zone_list = []
|
214
217
|
for db_zone in db_zones:
|
215
218
|
db_zone_list.append(db_zone.zone_id)
|
@@ -223,22 +226,22 @@ class QolsysState(QolsysObservable):
|
|
223
226
|
if state_zone.zone_id in db_zone_list:
|
224
227
|
for db_zone in db_zones:
|
225
228
|
if state_zone.zone_id == db_zone.zone_id:
|
226
|
-
LOGGER.debug("sync_data - update Zone%s",state_zone.zone_id)
|
229
|
+
LOGGER.debug("sync_data - update Zone%s", state_zone.zone_id)
|
227
230
|
state_zone.update(db_zone.to_dict())
|
228
231
|
|
229
232
|
# Delete zones
|
230
233
|
for state_zone in self.zones:
|
231
234
|
if state_zone.zone_id not in db_zone_list:
|
232
|
-
LOGGER.debug("sync_data - delete Zone%s",state_zone.zone_id)
|
235
|
+
LOGGER.debug("sync_data - delete Zone%s", state_zone.zone_id)
|
233
236
|
self.zone_delete(int(state_zone.zone_id))
|
234
237
|
|
235
238
|
# Add new zone
|
236
239
|
for db_zone in db_zones:
|
237
240
|
if db_zone.zone_id not in state_zone_list:
|
238
|
-
LOGGER.debug("sync_data - add Zone%s",db_zone.zone_id)
|
241
|
+
LOGGER.debug("sync_data - add Zone%s", db_zone.zone_id)
|
239
242
|
self.zone_add(db_zone)
|
240
243
|
|
241
|
-
def sync_partitions_data(self,db_partitions:list[QolsysPartition]) -> None: # noqa: C901
|
244
|
+
def sync_partitions_data(self, db_partitions: list[QolsysPartition]) -> None: # noqa: C901
|
242
245
|
db_partition_list = []
|
243
246
|
for db_partition in db_partitions:
|
244
247
|
db_partition_list.append(db_partition.id)
|
@@ -247,12 +250,12 @@ class QolsysState(QolsysObservable):
|
|
247
250
|
for state_partition in self.partitions:
|
248
251
|
state_partition_list.append(state_partition.id)
|
249
252
|
|
250
|
-
|
253
|
+
# Update existing partitions
|
251
254
|
for state_partition in self.partitions:
|
252
255
|
if state_partition.id in db_partition_list:
|
253
256
|
for db_partition in db_partitions:
|
254
257
|
if state_partition.id == db_partition.id:
|
255
|
-
LOGGER.debug("sync_data - update Partition%s",state_partition.id)
|
258
|
+
LOGGER.debug("sync_data - update Partition%s", state_partition.id)
|
256
259
|
state_partition.update_partition(db_partition.to_dict_partition())
|
257
260
|
state_partition.update_settings(db_partition.to_dict_settings())
|
258
261
|
state_partition.alarm_type_array = db_partition.alarm_type_array
|
@@ -261,13 +264,13 @@ class QolsysState(QolsysObservable):
|
|
261
264
|
# Delete partitions
|
262
265
|
for state_partition in self.partitions:
|
263
266
|
if state_partition.id not in db_partition_list:
|
264
|
-
LOGGER.debug("sync_data - delete Partition%s",state_partition.id)
|
267
|
+
LOGGER.debug("sync_data - delete Partition%s", state_partition.id)
|
265
268
|
self.partition_delete(state_partition.id)
|
266
269
|
|
267
270
|
# Add new partition
|
268
271
|
for db_partition in db_partitions:
|
269
272
|
if db_partition.id not in state_partition_list:
|
270
|
-
LOGGER.debug("sync_data - Add Partition%s",db_partition.id)
|
273
|
+
LOGGER.debug("sync_data - Add Partition%s", db_partition.id)
|
271
274
|
self.partition_add(db_partition)
|
272
275
|
|
273
276
|
def dump(self) -> None: # noqa: PLR0915
|
@@ -276,62 +279,62 @@ class QolsysState(QolsysObservable):
|
|
276
279
|
for partition in self.partitions:
|
277
280
|
pid = partition.id
|
278
281
|
name = partition.name
|
279
|
-
LOGGER.debug("Partition%s (%s) - system_status: %s",pid,name,partition.system_status)
|
280
|
-
LOGGER.debug("Partition%s (%s) - system_status_changed_time: %s",pid,name,partition.system_status_changed_time)
|
281
|
-
LOGGER.debug("Partition%s (%s) - alarm_state: %s",pid,name,partition.alarm_state)
|
282
|
+
LOGGER.debug("Partition%s (%s) - system_status: %s", pid, name, partition.system_status)
|
283
|
+
LOGGER.debug("Partition%s (%s) - system_status_changed_time: %s", pid, name, partition.system_status_changed_time)
|
284
|
+
LOGGER.debug("Partition%s (%s) - alarm_state: %s", pid, name, partition.alarm_state)
|
282
285
|
|
283
286
|
if partition.alarm_type_array == []:
|
284
|
-
LOGGER.debug("Partition%s (%s) - alarm_type: %s",pid,name,"None")
|
287
|
+
LOGGER.debug("Partition%s (%s) - alarm_type: %s", pid, name, "None")
|
285
288
|
else:
|
286
289
|
for alarm_type in partition.alarm_type_array:
|
287
|
-
LOGGER.debug("Partition%s (%s) - alarm_type: %s",pid,name,alarm_type)
|
290
|
+
LOGGER.debug("Partition%s (%s) - alarm_type: %s", pid, name, alarm_type)
|
288
291
|
|
289
|
-
LOGGER.debug("Partition%s (%s) - exit_sounds: %s",pid,name,partition.exit_sounds)
|
290
|
-
LOGGER.debug("Partition%s (%s) - entry_delays: %s",pid,name,partition.entry_delays)
|
292
|
+
LOGGER.debug("Partition%s (%s) - exit_sounds: %s", pid, name, partition.exit_sounds)
|
293
|
+
LOGGER.debug("Partition%s (%s) - entry_delays: %s", pid, name, partition.entry_delays)
|
291
294
|
|
292
295
|
for zone in self.zones:
|
293
296
|
zid = zone.zone_id
|
294
297
|
name = zone.sensorname
|
295
|
-
LOGGER.debug("Zone%s (%s) - status: %s",zid,name,zone.sensorstatus)
|
296
|
-
LOGGER.debug("Zone%s (%s) - battery_status: %s",zid,name,zone.battery_status)
|
297
|
-
LOGGER.debug("Zone%s (%s) - latestdBm: %s",zid,name,zone.latestdBm)
|
298
|
-
LOGGER.debug("Zone%s (%s) - averagedBm: %s",zid,name,zone.averagedBm)
|
298
|
+
LOGGER.debug("Zone%s (%s) - status: %s", zid, name, zone.sensorstatus)
|
299
|
+
LOGGER.debug("Zone%s (%s) - battery_status: %s", zid, name, zone.battery_status)
|
300
|
+
LOGGER.debug("Zone%s (%s) - latestdBm: %s", zid, name, zone.latestdBm)
|
301
|
+
LOGGER.debug("Zone%s (%s) - averagedBm: %s", zid, name, zone.averagedBm)
|
299
302
|
|
300
303
|
for zwave in self.zwave_devices:
|
301
|
-
if isinstance(zwave,QolsysDimmer):
|
304
|
+
if isinstance(zwave, QolsysDimmer):
|
302
305
|
nid = zwave.node_id
|
303
306
|
name = zwave.dimmer_name
|
304
|
-
LOGGER.debug("Dimmer%s (%s) - status: %s",nid,name,zwave.dimmer_status)
|
305
|
-
LOGGER.debug("Dimmer%s (%s) - level: %s",nid,name,zwave.dimmer_level)
|
306
|
-
LOGGER.debug("Dimmer%s (%s) - paired_status: %s",nid,name,zwave.paired_status)
|
307
|
-
LOGGER.debug("Dimmer%s (%s) - node_status: %s",nid,name,zwave.node_status)
|
308
|
-
LOGGER.debug("Dimmer%s (%s) - battery_level: %s",nid,name,zwave.node_battery_level)
|
309
|
-
LOGGER.debug("Dimmer%s (%s) - battery_level_value: %s",nid,name,zwave.node_battery_level_value)
|
307
|
+
LOGGER.debug("Dimmer%s (%s) - status: %s", nid, name, zwave.dimmer_status)
|
308
|
+
LOGGER.debug("Dimmer%s (%s) - level: %s", nid, name, zwave.dimmer_level)
|
309
|
+
LOGGER.debug("Dimmer%s (%s) - paired_status: %s", nid, name, zwave.paired_status)
|
310
|
+
LOGGER.debug("Dimmer%s (%s) - node_status: %s", nid, name, zwave.node_status)
|
311
|
+
LOGGER.debug("Dimmer%s (%s) - battery_level: %s", nid, name, zwave.node_battery_level)
|
312
|
+
LOGGER.debug("Dimmer%s (%s) - battery_level_value: %s", nid, name, zwave.node_battery_level_value)
|
310
313
|
continue
|
311
314
|
|
312
315
|
if isinstance(zwave, QolsysThermostat):
|
313
316
|
zid = zwave.thermostat_node_id
|
314
317
|
name = zwave.thermostat_name
|
315
|
-
LOGGER.debug("Thermostat%s (%s) - current_temp: %s",zid,name,zwave.thermostat_current_temp)
|
316
|
-
LOGGER.debug("Thermostat%s (%s) - mode: %s",zid,name,zwave.thermostat_mode)
|
317
|
-
LOGGER.debug("Thermostat%s (%s) - fan_mode: %s",zid,name,zwave.thermostat_fan_mode)
|
318
|
-
LOGGER.debug("Thermostat%s (%s) - target_temp: %s",zid,name,zwave.thermostat_target_temp)
|
319
|
-
LOGGER.debug("Thermostat%s (%s) - target_cool_temp: %s",zid,name,zwave.thermostat_target_cool_temp)
|
320
|
-
LOGGER.debug("Thermostat%s (%s) - target_heat_temp: %s",zid,name,zwave.thermostat_target_heat_temp)
|
321
|
-
LOGGER.debug("Thermostat%s (%s) - set_point_mode: %s",zid,name,zwave.thermostat_set_point_mode)
|
318
|
+
LOGGER.debug("Thermostat%s (%s) - current_temp: %s", zid, name, zwave.thermostat_current_temp)
|
319
|
+
LOGGER.debug("Thermostat%s (%s) - mode: %s", zid, name, zwave.thermostat_mode)
|
320
|
+
LOGGER.debug("Thermostat%s (%s) - fan_mode: %s", zid, name, zwave.thermostat_fan_mode)
|
321
|
+
LOGGER.debug("Thermostat%s (%s) - target_temp: %s", zid, name, zwave.thermostat_target_temp)
|
322
|
+
LOGGER.debug("Thermostat%s (%s) - target_cool_temp: %s", zid, name, zwave.thermostat_target_cool_temp)
|
323
|
+
LOGGER.debug("Thermostat%s (%s) - target_heat_temp: %s", zid, name, zwave.thermostat_target_heat_temp)
|
324
|
+
LOGGER.debug("Thermostat%s (%s) - set_point_mode: %s", zid, name, zwave.thermostat_set_point_mode)
|
322
325
|
continue
|
323
326
|
|
324
327
|
if isinstance(zwave, QolsysLock):
|
325
328
|
zid = zwave.lock_node_id
|
326
329
|
name = zwave.lock_name
|
327
|
-
LOGGER.debug("Lock%s (%s) - current_temp: %s",zid,name,zwave.lock_status)
|
330
|
+
LOGGER.debug("Lock%s (%s) - current_temp: %s", zid, name, zwave.lock_status)
|
328
331
|
continue
|
329
332
|
|
330
333
|
if isinstance(zwave, QolsysGeneric):
|
331
334
|
zid = zwave.node_id
|
332
335
|
name = zwave.node_name
|
333
|
-
LOGGER.debug("Generic%s (%s) - node_type: %s",zid,name,zwave.node_type)
|
334
|
-
LOGGER.debug("Generic%s (%s) - status: %s",zid,name,zwave.node_status)
|
335
|
-
LOGGER.debug("Generic%s (%s) - battery_level: %s",zid,name,zwave.node_battery_level)
|
336
|
-
LOGGER.debug("Generic%s (%s) - battery_level_vale: %s",zid,name,zwave.node_battery_level_value)
|
336
|
+
LOGGER.debug("Generic%s (%s) - node_type: %s", zid, name, zwave.node_type)
|
337
|
+
LOGGER.debug("Generic%s (%s) - status: %s", zid, name, zwave.node_status)
|
338
|
+
LOGGER.debug("Generic%s (%s) - battery_level: %s", zid, name, zwave.node_battery_level)
|
339
|
+
LOGGER.debug("Generic%s (%s) - battery_level_vale: %s", zid, name, zwave.node_battery_level_value)
|
337
340
|
continue
|
@@ -4,6 +4,7 @@ from collections.abc import Coroutine
|
|
4
4
|
|
5
5
|
LOGGER = logging.getLogger(__name__)
|
6
6
|
|
7
|
+
|
7
8
|
class QolsysTaskManager:
|
8
9
|
def __init__(self) -> None:
|
9
10
|
self._tasks = set()
|
@@ -18,7 +19,7 @@ class QolsysTaskManager:
|
|
18
19
|
task.add_done_callback(_done_callback)
|
19
20
|
return task
|
20
21
|
|
21
|
-
def cancel(self,label:str) -> None:
|
22
|
+
def cancel(self, label: str) -> None:
|
22
23
|
for task in self._tasks:
|
23
24
|
if task.get_name() == label:
|
24
25
|
task.cancel()
|
@@ -36,5 +37,4 @@ class QolsysTaskManager:
|
|
36
37
|
|
37
38
|
def dump(self) -> None:
|
38
39
|
for task in self._tasks:
|
39
|
-
LOGGER.debug("Task: %s, Done: %s, Cancelled: %s",task.get_name(),task.done(),task.cancelled())
|
40
|
-
|
40
|
+
LOGGER.debug("Task: %s, Done: %s, Cancelled: %s", task.get_name(), task.done(), task.cancelled())
|
qolsys_controller/utils_mqtt.py
CHANGED
@@ -4,18 +4,21 @@ import re
|
|
4
4
|
|
5
5
|
LOGGER = logging.getLogger(__name__)
|
6
6
|
|
7
|
+
|
7
8
|
def fix_json_string(json_string):
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
def replace_escape(match):
|
10
|
+
hex_value = match.group(1)
|
11
|
+
decimal_value = int(hex_value, 16)
|
12
|
+
return f"\\u{decimal_value:04x}"
|
13
|
+
|
14
|
+
return re.sub(r"\\x([0-9a-fA-F]{2})", replace_escape, json_string)
|
12
15
|
|
13
|
-
return re.sub(r"\\x([0-9a-fA-F]{2})", replace_escape, json_string)
|
14
16
|
|
15
17
|
def generate_random_mac() -> str:
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
mac = [
|
19
|
+
0xf2, 0x16, 0x3e,
|
20
|
+
random.randint(0x00, 0x7f),
|
21
|
+
random.randint(0x00, 0xff),
|
22
|
+
random.randint(0x00, 0xff),
|
23
|
+
]
|
24
|
+
return ":".join(map(lambda x: "%02x" % x, mac))
|