pyg90alarm 1.17.1__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 +39 -27
- {pyg90alarm-1.17.1.dist-info → pyg90alarm-1.17.2.dist-info}/METADATA +1 -1
- {pyg90alarm-1.17.1.dist-info → pyg90alarm-1.17.2.dist-info}/RECORD +6 -6
- {pyg90alarm-1.17.1.dist-info → pyg90alarm-1.17.2.dist-info}/LICENSE +0 -0
- {pyg90alarm-1.17.1.dist-info → pyg90alarm-1.17.2.dist-info}/WHEEL +0 -0
- {pyg90alarm-1.17.1.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:
|
|
@@ -1,5 +1,5 @@
|
|
|
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
|
|
@@ -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
|