pyg90alarm 1.17.0__py3-none-any.whl → 1.17.2__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.
- pyg90alarm/alarm.py +43 -28
- pyg90alarm/device_notifications.py +7 -3
- {pyg90alarm-1.17.0.dist-info → pyg90alarm-1.17.2.dist-info}/METADATA +1 -1
- {pyg90alarm-1.17.0.dist-info → pyg90alarm-1.17.2.dist-info}/RECORD +7 -7
- {pyg90alarm-1.17.0.dist-info → pyg90alarm-1.17.2.dist-info}/LICENSE +0 -0
- {pyg90alarm-1.17.0.dist-info → pyg90alarm-1.17.2.dist-info}/WHEEL +0 -0
- {pyg90alarm-1.17.0.dist-info → pyg90alarm-1.17.2.dist-info}/top_level.txt +0 -0
pyg90alarm/alarm.py
CHANGED
|
@@ -161,7 +161,9 @@ class G90Alarm(G90DeviceNotifications):
|
|
|
161
161
|
self._host: str = host
|
|
162
162
|
self._port: int = port
|
|
163
163
|
self._sensors: List[G90Sensor] = []
|
|
164
|
+
self._sensors_lock = asyncio.Lock()
|
|
164
165
|
self._devices: List[G90Device] = []
|
|
166
|
+
self._devices_lock = asyncio.Lock()
|
|
165
167
|
self._notifications: Optional[G90DeviceNotifications] = None
|
|
166
168
|
self._sensor_cb: Optional[SensorCallback] = None
|
|
167
169
|
self._armdisarm_cb: Optional[ArmDisarmCallback] = None
|
|
@@ -258,20 +260,26 @@ class G90Alarm(G90DeviceNotifications):
|
|
|
258
260
|
|
|
259
261
|
:return: List of sensors
|
|
260
262
|
"""
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
proto_idx=sensor.proto_idx
|
|
263
|
+
# Use lock around the operation, to ensure no duplicated entries in the
|
|
264
|
+
# resulting list or redundant exchanges with panel are made when the
|
|
265
|
+
# method is called concurrently
|
|
266
|
+
async with self._sensors_lock:
|
|
267
|
+
if not self._sensors:
|
|
268
|
+
sensors = self.paginated_result(
|
|
269
|
+
G90Commands.GETSENSORLIST
|
|
269
270
|
)
|
|
270
|
-
|
|
271
|
+
async for sensor in sensors:
|
|
272
|
+
obj = G90Sensor(
|
|
273
|
+
*sensor.data, parent=self, subindex=0,
|
|
274
|
+
proto_idx=sensor.proto_idx
|
|
275
|
+
)
|
|
276
|
+
self._sensors.append(obj)
|
|
271
277
|
|
|
272
|
-
|
|
278
|
+
_LOGGER.debug(
|
|
279
|
+
'Total number of sensors: %s', len(self._sensors)
|
|
280
|
+
)
|
|
273
281
|
|
|
274
|
-
|
|
282
|
+
return self._sensors
|
|
275
283
|
|
|
276
284
|
async def find_sensor(self, idx: int, name: str) -> Optional[G90Sensor]:
|
|
277
285
|
"""
|
|
@@ -316,28 +324,32 @@ class G90Alarm(G90DeviceNotifications):
|
|
|
316
324
|
|
|
317
325
|
:return: List of devices
|
|
318
326
|
"""
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
obj = G90Device(
|
|
325
|
-
*device.data, parent=self, subindex=0,
|
|
326
|
-
proto_idx=device.proto_idx
|
|
327
|
+
# See `get_sensors` method for the rationale behind the lock usage
|
|
328
|
+
async with self._devices_lock:
|
|
329
|
+
if not self._devices:
|
|
330
|
+
devices = self.paginated_result(
|
|
331
|
+
G90Commands.GETDEVICELIST
|
|
327
332
|
)
|
|
328
|
-
|
|
329
|
-
# Multi-node devices (first node has already been added
|
|
330
|
-
# above
|
|
331
|
-
for node in range(1, obj.node_count):
|
|
333
|
+
async for device in devices:
|
|
332
334
|
obj = G90Device(
|
|
333
|
-
*device.data, parent=self,
|
|
334
|
-
|
|
335
|
+
*device.data, parent=self, subindex=0,
|
|
336
|
+
proto_idx=device.proto_idx
|
|
335
337
|
)
|
|
336
338
|
self._devices.append(obj)
|
|
339
|
+
# Multi-node devices (first node has already been added
|
|
340
|
+
# above
|
|
341
|
+
for node in range(1, obj.node_count):
|
|
342
|
+
obj = G90Device(
|
|
343
|
+
*device.data, parent=self,
|
|
344
|
+
subindex=node, proto_idx=device.proto_idx
|
|
345
|
+
)
|
|
346
|
+
self._devices.append(obj)
|
|
337
347
|
|
|
338
|
-
|
|
348
|
+
_LOGGER.debug(
|
|
349
|
+
'Total number of devices: %s', len(self._devices)
|
|
350
|
+
)
|
|
339
351
|
|
|
340
|
-
|
|
352
|
+
return self._devices
|
|
341
353
|
|
|
342
354
|
@property
|
|
343
355
|
async def host_info(self) -> G90HostInfo:
|
|
@@ -915,7 +927,10 @@ class G90Alarm(G90DeviceNotifications):
|
|
|
915
927
|
# notifications port
|
|
916
928
|
self._handle_alert(
|
|
917
929
|
(self._host, self._notifications_local_port),
|
|
918
|
-
item.as_device_alert()
|
|
930
|
+
item.as_device_alert(),
|
|
931
|
+
# Skip verifying device GUID, since history entry
|
|
932
|
+
# don't have it
|
|
933
|
+
verify_device_id=False
|
|
919
934
|
)
|
|
920
935
|
|
|
921
936
|
# Record the entry as most recent one
|
|
@@ -208,13 +208,17 @@ class G90DeviceNotifications(DatagramProtocol):
|
|
|
208
208
|
return False
|
|
209
209
|
|
|
210
210
|
def _handle_alert(
|
|
211
|
-
self, addr: Tuple[str, int], alert: G90DeviceAlert
|
|
211
|
+
self, addr: Tuple[str, int], alert: G90DeviceAlert,
|
|
212
|
+
verify_device_id: bool = True
|
|
212
213
|
) -> None:
|
|
213
214
|
handled = False
|
|
214
215
|
|
|
215
216
|
# Stop processing when alert is received from the device with different
|
|
216
|
-
# GUID
|
|
217
|
-
if
|
|
217
|
+
# GUID (if enabled)
|
|
218
|
+
if (
|
|
219
|
+
verify_device_id and self.device_id
|
|
220
|
+
and alert.device_id != self.device_id
|
|
221
|
+
):
|
|
218
222
|
_LOGGER.error(
|
|
219
223
|
"Received alert from wrong device: expected '%s', got '%s'",
|
|
220
224
|
self.device_id, alert.device_id
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
pyg90alarm/__init__.py,sha256=5AITRm5jZSzuQaL7PS8fZZMZb4-IuGRhSqyAdfTt0Cs,2236
|
|
2
|
-
pyg90alarm/alarm.py,sha256=
|
|
2
|
+
pyg90alarm/alarm.py,sha256=nTP0JrXQCqLz_lhA9F_AHK3CPNbYMt3gSeQVOL9QSpI,36589
|
|
3
3
|
pyg90alarm/base_cmd.py,sha256=Bz7yoZ0RpkcjWARya664DKAPo3goD6BeaKtuW-hA804,9902
|
|
4
4
|
pyg90alarm/callback.py,sha256=3JsD_JChmZD24OyjaCP-PxxuBDBX7myGYhkM4RN7bk4,3742
|
|
5
5
|
pyg90alarm/config.py,sha256=2YtIgdT7clQXmYvkdn_fhIdS05CY8E1Yc90R8_tAmRI,1961
|
|
6
6
|
pyg90alarm/const.py,sha256=0EkfCtySEPi6W0TO-j-F1y7_MVFaMOuKDY1Bx6QGDDQ,6617
|
|
7
|
-
pyg90alarm/device_notifications.py,sha256=
|
|
7
|
+
pyg90alarm/device_notifications.py,sha256=61oruR70snBRXNzOfj313TO7p2TmbEk-dH9AA1nkDkY,16687
|
|
8
8
|
pyg90alarm/discovery.py,sha256=fwyBHDCKGej06OwhpbVCHYTRU9WWkeYysAFgv3FiwqI,3575
|
|
9
9
|
pyg90alarm/exceptions.py,sha256=eiOcRe7D18EIPyPFDNU9DdFgbnkwPmkiLl8lGPOhBNw,1475
|
|
10
10
|
pyg90alarm/history.py,sha256=5NfgB0V-7TZlMNHEjtRbOA0ZtJfQTgh2ysZIg5RM7ck,9080
|
|
@@ -20,8 +20,8 @@ pyg90alarm/definitions/sensors.py,sha256=rKOu21ZpI44xk6aMh_vBjniFqnsNTc1CKwAvnv4
|
|
|
20
20
|
pyg90alarm/entities/__init__.py,sha256=hHb6AOiC4Tz--rOWiiICMdLaZDs1Tf_xpWk_HeS_gO4,66
|
|
21
21
|
pyg90alarm/entities/device.py,sha256=f_LHvKCAqTEebZ4mrRh3CpPUI7o-OvpvOfyTRCbftJs,2818
|
|
22
22
|
pyg90alarm/entities/sensor.py,sha256=4r8ouAYTZB8ih8I4ncWdQOaifYsRxaC-ukY9jvnrRvk,16139
|
|
23
|
-
pyg90alarm-1.17.
|
|
24
|
-
pyg90alarm-1.17.
|
|
25
|
-
pyg90alarm-1.17.
|
|
26
|
-
pyg90alarm-1.17.
|
|
27
|
-
pyg90alarm-1.17.
|
|
23
|
+
pyg90alarm-1.17.2.dist-info/LICENSE,sha256=f884inRbeNv-O-hbwz62Ro_1J8xiHRTnJ2cCx6A0WvU,1070
|
|
24
|
+
pyg90alarm-1.17.2.dist-info/METADATA,sha256=8PoCUW_lwXEsjV5MZUGOb362h7C2JL0PHIOlEWr8twk,7714
|
|
25
|
+
pyg90alarm-1.17.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
26
|
+
pyg90alarm-1.17.2.dist-info/top_level.txt,sha256=czHiGxYMyTk5QEDTDb0EpPiKqUMRa8zI4zx58Ii409M,11
|
|
27
|
+
pyg90alarm-1.17.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|