uiprotect 0.9.0__py3-none-any.whl → 0.10.1__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 uiprotect might be problematic. Click here for more details.

@@ -4,6 +4,7 @@ from __future__ import annotations
4
4
 
5
5
  import asyncio
6
6
  import logging
7
+ from collections.abc import Iterable
7
8
  from copy import deepcopy
8
9
  from dataclasses import dataclass
9
10
  from datetime import datetime
@@ -337,7 +338,7 @@ class Bootstrap(ProtectBaseObject):
337
338
  def _create_stat(
338
339
  self,
339
340
  packet: WSPacket,
340
- keys_set: list[str],
341
+ keys_set: Iterable[str] | None,
341
342
  filtered: bool,
342
343
  ) -> None:
343
344
  if self.capture_ws_stats:
@@ -346,7 +347,7 @@ class Bootstrap(ProtectBaseObject):
346
347
  model=packet.action_frame.data["modelKey"],
347
348
  action=packet.action_frame.data["action"],
348
349
  keys=list(packet.data_frame.data),
349
- keys_set=keys_set,
350
+ keys_set=[] if keys_set is None else list(keys_set),
350
351
  size=len(packet.raw),
351
352
  filtered=filtered,
352
353
  ),
@@ -389,7 +390,9 @@ class Bootstrap(ProtectBaseObject):
389
390
  return None
390
391
 
391
392
  updated = obj.dict()
392
- self._create_stat(packet, list(updated), False)
393
+
394
+ self._create_stat(packet, updated, False)
395
+
393
396
  return WSSubscriptionMessage(
394
397
  action=WSAction.ADD,
395
398
  new_update_id=self.last_update_id,
@@ -415,7 +418,7 @@ class Bootstrap(ProtectBaseObject):
415
418
  return None
416
419
  self.mac_lookup.pop(device.mac.lower().replace(":", ""), None)
417
420
 
418
- self._create_stat(packet, [], False)
421
+ self._create_stat(packet, None, False)
419
422
  return WSSubscriptionMessage(
420
423
  action=WSAction.REMOVE,
421
424
  new_update_id=self.last_update_id,
@@ -433,25 +436,25 @@ class Bootstrap(ProtectBaseObject):
433
436
  _remove_stats_keys(data)
434
437
  # nothing left to process
435
438
  if not data:
436
- self._create_stat(packet, [], True)
439
+ self._create_stat(packet, None, True)
437
440
  return None
438
441
 
439
442
  # for another NVR in stack
440
443
  nvr_id = packet.action_frame.data.get("id")
441
444
  if nvr_id and nvr_id != self.nvr.id:
442
- self._create_stat(packet, [], True)
445
+ self._create_stat(packet, None, True)
443
446
  return None
444
447
 
445
448
  data = self.nvr.unifi_dict_to_dict(data)
446
449
  # nothing left to process
447
450
  if not data:
448
- self._create_stat(packet, [], True)
451
+ self._create_stat(packet, None, True)
449
452
  return None
450
453
 
451
454
  old_nvr = self.nvr.copy()
452
455
  self.nvr = self.nvr.update_from_dict(deepcopy(data))
453
456
 
454
- self._create_stat(packet, list(data), False)
457
+ self._create_stat(packet, data, False)
455
458
  return WSSubscriptionMessage(
456
459
  action=WSAction.UPDATE,
457
460
  new_update_id=self.last_update_id,
@@ -478,7 +481,7 @@ class Bootstrap(ProtectBaseObject):
478
481
  del data["lastMotion"]
479
482
  # nothing left to process
480
483
  if not data:
481
- self._create_stat(packet, [], True)
484
+ self._create_stat(packet, None, True)
482
485
  return None
483
486
 
484
487
  key = f"{model_type}s"
@@ -492,13 +495,12 @@ class Bootstrap(ProtectBaseObject):
492
495
  data = obj.unifi_dict_to_dict(data)
493
496
  old_obj = obj.copy()
494
497
  obj = obj.update_from_dict(deepcopy(data))
495
- now = utc_now()
496
498
 
497
499
  if isinstance(obj, Event):
498
500
  self.process_event(obj)
499
501
  elif isinstance(obj, Camera):
500
502
  if "last_ring" in data and obj.last_ring:
501
- is_recent = obj.last_ring + RECENT_EVENT_MAX >= now
503
+ is_recent = obj.last_ring + RECENT_EVENT_MAX >= utc_now()
502
504
  _LOGGER.debug("last_ring for %s (%s)", obj.id, is_recent)
503
505
  if is_recent:
504
506
  obj.set_ring_timeout()
@@ -507,14 +509,14 @@ class Bootstrap(ProtectBaseObject):
507
509
  and "alarm_triggered_at" in data
508
510
  and obj.alarm_triggered_at
509
511
  ):
510
- is_recent = obj.alarm_triggered_at + RECENT_EVENT_MAX >= now
512
+ is_recent = obj.alarm_triggered_at + RECENT_EVENT_MAX >= utc_now()
511
513
  _LOGGER.debug("alarm_triggered_at for %s (%s)", obj.id, is_recent)
512
514
  if is_recent:
513
515
  obj.set_alarm_timeout()
514
516
 
515
517
  devices[action["id"]] = obj
516
518
 
517
- self._create_stat(packet, list(data), False)
519
+ self._create_stat(packet, data, False)
518
520
  return WSSubscriptionMessage(
519
521
  action=WSAction.UPDATE,
520
522
  new_update_id=self.last_update_id,
@@ -555,18 +557,18 @@ class Bootstrap(ProtectBaseObject):
555
557
 
556
558
  if action["modelKey"] not in ModelType.values_set():
557
559
  _LOGGER.debug("Unknown model type: %s", action["modelKey"])
558
- self._create_stat(packet, [], True)
560
+ self._create_stat(packet, None, True)
559
561
  return None
560
562
 
561
563
  if len(models) > 0 and ModelType(action["modelKey"]) not in models:
562
- self._create_stat(packet, [], True)
564
+ self._create_stat(packet, None, True)
563
565
  return None
564
566
 
565
567
  if action["action"] == "remove":
566
568
  return self._process_remove_packet(packet, data)
567
569
 
568
570
  if data is None or len(data) == 0:
569
- self._create_stat(packet, [], True)
571
+ self._create_stat(packet, None, True)
570
572
  return None
571
573
 
572
574
  try:
@@ -593,7 +595,7 @@ class Bootstrap(ProtectBaseObject):
593
595
  except (ValidationError, ValueError) as err:
594
596
  self._handle_ws_error(action, err)
595
597
 
596
- self._create_stat(packet, [], True)
598
+ self._create_stat(packet, None, True)
597
599
  return None
598
600
 
599
601
  def _handle_ws_error(self, action: dict[str, Any], err: Exception) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uiprotect
3
- Version: 0.9.0
3
+ Version: 0.10.1
4
4
  Summary: Python API for Unifi Protect (Unofficial)
5
5
  Home-page: https://github.com/uilibs/uiprotect
6
6
  License: MIT
@@ -15,7 +15,7 @@ uiprotect/cli/sensors.py,sha256=fQtcDJCVxs4VbAqcavgBy2ABiVxAW3GXtna6_XFBp2k,8153
15
15
  uiprotect/cli/viewers.py,sha256=2cyrp104ffIvgT0wYGIO0G35QMkEbFe7fSVqLwDXQYQ,2171
16
16
  uiprotect/data/__init__.py,sha256=OcfuJl2qXfHcj_mdnrHhzZ5tEIZrw8auziX5IE7dn-I,2938
17
17
  uiprotect/data/base.py,sha256=ex-UC9CJUtzxMFqtYokSiXM8pNHVBqCzq7r8WrEf1Mw,37178
18
- uiprotect/data/bootstrap.py,sha256=atqHRlZVtRw24obwot7jkXxf_rDzgooPXKW7dMr_3Zo,21884
18
+ uiprotect/data/bootstrap.py,sha256=TzrwRfI4Jt0zDx_tKxGS6AM3xRixB8iHOVY7CgeM7Qg,21952
19
19
  uiprotect/data/convert.py,sha256=rOQplUMIdTMD2SbAx_iI9BNPDscnhDvyRVLEMDhtADg,2047
20
20
  uiprotect/data/devices.py,sha256=LHVBT8ihMAZen7gIlQNbiYxukRrBpi_TNKNmV_5R6Xc,111705
21
21
  uiprotect/data/nvr.py,sha256=OJso6oewA_jY7ovKbD2U2Onp1GqheT5bCW0F6dC53DQ,47570
@@ -30,8 +30,8 @@ uiprotect/test_util/__init__.py,sha256=d2g7afa0LSdixQ0kjEDYwafDFME_UlW2LzxpamZ2B
30
30
  uiprotect/test_util/anonymize.py,sha256=f-8ijU-_y9r-uAbhIPn0f0I6hzJpAkvJzc8UpWihObI,8478
31
31
  uiprotect/utils.py,sha256=kXEr1xEoPAwUYuVPd6QoVnTf8MQwzQXQQ4JLyJsiRfY,18219
32
32
  uiprotect/websocket.py,sha256=iMTdchymaCgVHsmY1bRbxkcymqt6WQircIHYNxCu178,7289
33
- uiprotect-0.9.0.dist-info/LICENSE,sha256=INx18jhdbVXMEiiBANeKEbrbz57ckgzxk5uutmmcxGk,1111
34
- uiprotect-0.9.0.dist-info/METADATA,sha256=vkY-rMmqWGZn2k1aMLMjwOykXB-GyPuW1VoOWr3JUeA,10984
35
- uiprotect-0.9.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
36
- uiprotect-0.9.0.dist-info/entry_points.txt,sha256=J78AUTPrTTxgI3s7SVgrmGqDP7piX2wuuEORzhDdVRA,47
37
- uiprotect-0.9.0.dist-info/RECORD,,
33
+ uiprotect-0.10.1.dist-info/LICENSE,sha256=INx18jhdbVXMEiiBANeKEbrbz57ckgzxk5uutmmcxGk,1111
34
+ uiprotect-0.10.1.dist-info/METADATA,sha256=XM-hvlQWsrZSuAVzlVtridjkbMY2Bh18YmSfrNhwiKc,10985
35
+ uiprotect-0.10.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
36
+ uiprotect-0.10.1.dist-info/entry_points.txt,sha256=J78AUTPrTTxgI3s7SVgrmGqDP7piX2wuuEORzhDdVRA,47
37
+ uiprotect-0.10.1.dist-info/RECORD,,