uiprotect 1.14.0__tar.gz → 1.16.0__tar.gz

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.

Files changed (36) hide show
  1. {uiprotect-1.14.0 → uiprotect-1.16.0}/PKG-INFO +1 -1
  2. {uiprotect-1.14.0 → uiprotect-1.16.0}/pyproject.toml +1 -1
  3. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/data/base.py +10 -16
  4. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/data/bootstrap.py +14 -16
  5. {uiprotect-1.14.0 → uiprotect-1.16.0}/LICENSE +0 -0
  6. {uiprotect-1.14.0 → uiprotect-1.16.0}/README.md +0 -0
  7. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/__init__.py +0 -0
  8. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/__main__.py +0 -0
  9. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/api.py +0 -0
  10. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/cli/__init__.py +0 -0
  11. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/cli/backup.py +0 -0
  12. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/cli/base.py +0 -0
  13. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/cli/cameras.py +0 -0
  14. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/cli/chimes.py +0 -0
  15. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/cli/doorlocks.py +0 -0
  16. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/cli/events.py +0 -0
  17. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/cli/lights.py +0 -0
  18. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/cli/liveviews.py +0 -0
  19. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/cli/nvr.py +0 -0
  20. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/cli/sensors.py +0 -0
  21. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/cli/viewers.py +0 -0
  22. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/data/__init__.py +0 -0
  23. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/data/convert.py +0 -0
  24. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/data/devices.py +0 -0
  25. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/data/nvr.py +0 -0
  26. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/data/types.py +0 -0
  27. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/data/user.py +0 -0
  28. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/data/websocket.py +0 -0
  29. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/exceptions.py +0 -0
  30. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/py.typed +0 -0
  31. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/release_cache.json +0 -0
  32. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/stream.py +0 -0
  33. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/test_util/__init__.py +0 -0
  34. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/test_util/anonymize.py +0 -0
  35. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/utils.py +0 -0
  36. {uiprotect-1.14.0 → uiprotect-1.16.0}/src/uiprotect/websocket.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uiprotect
3
- Version: 1.14.0
3
+ Version: 1.16.0
4
4
  Summary: Python API for Unifi Protect (Unofficial)
5
5
  Home-page: https://github.com/uilibs/uiprotect
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "uiprotect"
3
- version = "1.14.0"
3
+ version = "1.16.0"
4
4
  description = "Python API for Unifi Protect (Unofficial)"
5
5
  authors = ["UI Protect Maintainers <ui@koston.org>"]
6
6
  license = "MIT"
@@ -401,15 +401,12 @@ class ProtectBaseObject(BaseModel):
401
401
  if not isinstance(value, list):
402
402
  return value
403
403
 
404
- items: list[Any] = []
405
- for item in value:
406
- if isinstance(item, ProtectBaseObject):
407
- new_item = item.unifi_dict()
408
- else:
409
- new_item = klass.construct({}).unifi_dict(data=item) # type: ignore[arg-type]
410
- items.append(new_item)
411
-
412
- return items
404
+ return [
405
+ item.unifi_dict()
406
+ if isinstance(item, ProtectBaseObject)
407
+ else klass.construct({}).unifi_dict(data=item) # type: ignore[arg-type]
408
+ for item in value
409
+ ]
413
410
 
414
411
  def _unifi_dict_protect_obj_dict(
415
412
  self,
@@ -424,13 +421,10 @@ class ProtectBaseObject(BaseModel):
424
421
  if not isinstance(value, dict):
425
422
  return value
426
423
 
427
- items: dict[Any, Any] = {}
428
- for obj_key, obj in value.items():
429
- if isinstance(obj, ProtectBaseObject):
430
- obj = obj.unifi_dict()
431
- items[obj_key] = obj
432
-
433
- return items
424
+ return {
425
+ obj_key: obj.unifi_dict() if isinstance(obj, ProtectBaseObject) else obj
426
+ for obj_key, obj in value.items()
427
+ }
434
428
 
435
429
  def unifi_dict(
436
430
  self,
@@ -9,7 +9,7 @@ from copy import deepcopy
9
9
  from dataclasses import dataclass
10
10
  from datetime import datetime
11
11
  from functools import cache
12
- from typing import TYPE_CHECKING, Any, cast
12
+ from typing import TYPE_CHECKING, Any
13
13
 
14
14
  from aiohttp.client_exceptions import ServerDisconnectedError
15
15
 
@@ -298,20 +298,20 @@ class Bootstrap(ProtectBaseObject):
298
298
 
299
299
  def get_device_from_mac(self, mac: str) -> ProtectAdoptableDeviceModel | None:
300
300
  """Retrieve a device from MAC address."""
301
- ref = self.mac_lookup.get(normalize_mac(mac))
302
- if ref is None:
303
- return None
304
-
305
- devices: dict[str, ProtectModelWithId] = getattr(self, ref.model.devices_key)
306
- return cast(ProtectAdoptableDeviceModel, devices.get(ref.id))
301
+ return self._get_device_from_ref(self.mac_lookup.get(normalize_mac(mac)))
307
302
 
308
303
  def get_device_from_id(self, device_id: str) -> ProtectAdoptableDeviceModel | None:
309
304
  """Retrieve a device from device ID (without knowing model type)."""
310
- ref = self.id_lookup.get(device_id)
305
+ return self._get_device_from_ref(self.id_lookup.get(device_id))
306
+
307
+ def _get_device_from_ref(
308
+ self, ref: ProtectDeviceRef | None
309
+ ) -> ProtectAdoptableDeviceModel | None:
311
310
  if ref is None:
312
311
  return None
313
- devices: dict[str, ProtectModelWithId] = getattr(self, ref.model.devices_key)
314
- return cast(ProtectAdoptableDeviceModel, devices.get(ref.id))
312
+ devices_key = ref.model.devices_key
313
+ devices: dict[str, ProtectAdoptableDeviceModel] = getattr(self, devices_key)
314
+ return devices[ref.id]
315
315
 
316
316
  def process_event(self, event: Event) -> None:
317
317
  event_type = event.type
@@ -386,9 +386,8 @@ class Bootstrap(ProtectBaseObject):
386
386
  def _process_remove_packet(
387
387
  self, model_type: ModelType, packet: WSPacket
388
388
  ) -> WSSubscriptionMessage | None:
389
- devices: dict[str, ProtectDeviceModel] | None = getattr(
390
- self, model_type.devices_key, None
391
- )
389
+ devices_key = model_type.devices_key
390
+ devices: dict[str, ProtectDeviceModel] | None = getattr(self, devices_key, None)
392
391
 
393
392
  if devices is None:
394
393
  return None
@@ -615,9 +614,8 @@ class Bootstrap(ProtectBaseObject):
615
614
  if isinstance(device, NVR):
616
615
  self.nvr = device
617
616
  else:
618
- devices: dict[str, ProtectModelWithId] = getattr(
619
- self, model_type.devices_key
620
- )
617
+ devices_key = model_type.devices_key
618
+ devices: dict[str, ProtectModelWithId] = getattr(self, devices_key)
621
619
  devices[device.id] = device
622
620
  _LOGGER.debug("Successfully refresh model: %s %s", model_type, device_id)
623
621
 
File without changes
File without changes