uiprotect 1.10.0__tar.gz → 1.11.1__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.10.0 → uiprotect-1.11.1}/PKG-INFO +1 -1
  2. {uiprotect-1.10.0 → uiprotect-1.11.1}/pyproject.toml +1 -1
  3. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/data/bootstrap.py +22 -20
  4. {uiprotect-1.10.0 → uiprotect-1.11.1}/LICENSE +0 -0
  5. {uiprotect-1.10.0 → uiprotect-1.11.1}/README.md +0 -0
  6. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/__init__.py +0 -0
  7. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/__main__.py +0 -0
  8. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/api.py +0 -0
  9. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/cli/__init__.py +0 -0
  10. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/cli/backup.py +0 -0
  11. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/cli/base.py +0 -0
  12. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/cli/cameras.py +0 -0
  13. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/cli/chimes.py +0 -0
  14. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/cli/doorlocks.py +0 -0
  15. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/cli/events.py +0 -0
  16. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/cli/lights.py +0 -0
  17. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/cli/liveviews.py +0 -0
  18. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/cli/nvr.py +0 -0
  19. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/cli/sensors.py +0 -0
  20. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/cli/viewers.py +0 -0
  21. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/data/__init__.py +0 -0
  22. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/data/base.py +0 -0
  23. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/data/convert.py +0 -0
  24. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/data/devices.py +0 -0
  25. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/data/nvr.py +0 -0
  26. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/data/types.py +0 -0
  27. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/data/user.py +0 -0
  28. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/data/websocket.py +0 -0
  29. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/exceptions.py +0 -0
  30. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/py.typed +0 -0
  31. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/release_cache.json +0 -0
  32. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/stream.py +0 -0
  33. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/test_util/__init__.py +0 -0
  34. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/test_util/anonymize.py +0 -0
  35. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/utils.py +0 -0
  36. {uiprotect-1.10.0 → uiprotect-1.11.1}/src/uiprotect/websocket.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uiprotect
3
- Version: 1.10.0
3
+ Version: 1.11.1
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.10.0"
3
+ version = "1.11.1"
4
4
  description = "Python API for Unifi Protect (Unofficial)"
5
5
  authors = ["UI Protect Maintainers <ui@koston.org>"]
6
6
  license = "MIT"
@@ -8,6 +8,7 @@ from collections.abc import Iterable
8
8
  from copy import deepcopy
9
9
  from dataclasses import dataclass
10
10
  from datetime import datetime
11
+ from functools import cache
11
12
  from typing import TYPE_CHECKING, Any, cast
12
13
 
13
14
  from aiohttp.client_exceptions import ServerDisconnectedError
@@ -191,8 +192,11 @@ class Bootstrap(ProtectBaseObject):
191
192
  api: ProtectApiClient | None = data.get("api") or (
192
193
  cls._api if isinstance(cls, ProtectBaseObject) else None
193
194
  )
194
- data["macLookup"] = {}
195
- data["idLookup"] = {}
195
+ mac_lookup: dict[str, dict[str, str | ModelType]] = {}
196
+ id_lookup: dict[str, dict[str, str | ModelType]] = {}
197
+ data["idLookup"] = id_lookup
198
+ data["macLookup"] = mac_lookup
199
+
196
200
  for model_type in ModelType.bootstrap_models_types_set:
197
201
  key = model_type.devices_key # type: ignore[attr-defined]
198
202
  items: dict[str, ProtectModel] = {}
@@ -204,16 +208,22 @@ class Bootstrap(ProtectBaseObject):
204
208
  ):
205
209
  continue
206
210
 
207
- ref = {"model": model_type, "id": item["id"]}
208
- items[item["id"]] = item
209
- data["idLookup"][item["id"]] = ref
211
+ id_: str = item["id"]
212
+ ref = {"model": model_type, "id": id_}
213
+ items[id_] = item
214
+ id_lookup[id_] = ref
210
215
  if "mac" in item:
211
216
  cleaned_mac = normalize_mac(item["mac"])
212
- data["macLookup"][cleaned_mac] = ref
217
+ mac_lookup[cleaned_mac] = ref
213
218
  data[key] = items
214
219
 
215
220
  return super().unifi_dict_to_dict(data)
216
221
 
222
+ @classmethod
223
+ @cache
224
+ def _unifi_dict_remove_keys(cls) -> set[str]:
225
+ return {"events", "captureWsStats", "macLookup", "idLookup"}
226
+
217
227
  def unifi_dict(
218
228
  self,
219
229
  data: dict[str, Any] | None = None,
@@ -221,15 +231,9 @@ class Bootstrap(ProtectBaseObject):
221
231
  ) -> dict[str, Any]:
222
232
  data = super().unifi_dict(data=data, exclude=exclude)
223
233
 
224
- if "events" in data:
225
- del data["events"]
226
- if "captureWsStats" in data:
227
- del data["captureWsStats"]
228
- if "macLookup" in data:
229
- del data["macLookup"]
230
- if "idLookup" in data:
231
- del data["idLookup"]
232
-
234
+ for key in Bootstrap._unifi_dict_remove_keys():
235
+ if key in data:
236
+ del data[key]
233
237
  for model_type in ModelType.bootstrap_models_types_set:
234
238
  attr = model_type.devices_key # type: ignore[attr-defined]
235
239
  if attr in data and isinstance(data[attr], dict):
@@ -246,8 +250,7 @@ class Bootstrap(ProtectBaseObject):
246
250
 
247
251
  @property
248
252
  def auth_user(self) -> User:
249
- user: User = self._api.bootstrap.users[self.auth_user_id]
250
- return user
253
+ return self._api.bootstrap.users[self.auth_user_id]
251
254
 
252
255
  @property
253
256
  def has_doorbell(self) -> bool:
@@ -419,14 +422,13 @@ class Bootstrap(ProtectBaseObject):
419
422
  return None
420
423
 
421
424
  # for another NVR in stack
422
- nvr_id = packet.action_frame.data.get("id")
425
+ nvr_id: str | None = packet.action_frame.data.get("id")
423
426
  if nvr_id and nvr_id != self.nvr.id:
424
427
  self._create_stat(packet, None, True)
425
428
  return None
426
429
 
427
- data = self.nvr.unifi_dict_to_dict(data)
428
430
  # nothing left to process
429
- if not data:
431
+ if not (data := self.nvr.unifi_dict_to_dict(data)):
430
432
  self._create_stat(packet, None, True)
431
433
  return None
432
434
 
File without changes
File without changes