uiprotect 5.2.2__py3-none-any.whl → 5.3.0__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.

uiprotect/api.py CHANGED
@@ -1401,21 +1401,20 @@ class ProtectApiClient(BaseApiClient):
1401
1401
 
1402
1402
  Datetime of screenshot is approximate. It may be +/- a few seconds.
1403
1403
  """
1404
- params = {
1405
- "ts": to_js_time(dt or utc_now()),
1406
- "force": "true",
1407
- }
1404
+ params: dict[str, Any] = {}
1405
+ if dt is not None:
1406
+ path = "recording-snapshot"
1407
+ params["ts"] = to_js_time(dt)
1408
+ else:
1409
+ path = "snapshot"
1410
+ params["ts"] = int(time.time() * 1000)
1411
+ params["force"] = "true"
1408
1412
 
1409
1413
  if width is not None:
1410
- params.update({"w": width})
1414
+ params["w"] = width
1411
1415
 
1412
1416
  if height is not None:
1413
- params.update({"h": height})
1414
-
1415
- path = "snapshot"
1416
- if dt is not None:
1417
- path = "recording-snapshot"
1418
- del params["force"]
1417
+ params["h"] = height
1419
1418
 
1420
1419
  return await self.api_request_raw(
1421
1420
  f"cameras/{camera_id}/{path}",
@@ -1435,22 +1434,21 @@ class ProtectApiClient(BaseApiClient):
1435
1434
 
1436
1435
  Datetime of screenshot is approximate. It may be +/- a few seconds.
1437
1436
  """
1438
- params = {
1439
- "ts": to_js_time(dt or utc_now()),
1440
- "force": "true",
1441
- }
1437
+ params: dict[str, Any] = {}
1438
+ if dt is not None:
1439
+ path = "recording-snapshot"
1440
+ params["ts"] = to_js_time(dt)
1441
+ params["lens"] = 2
1442
+ else:
1443
+ path = "package-snapshot"
1444
+ params["ts"] = int(time.time() * 1000)
1445
+ params["force"] = "true"
1442
1446
 
1443
1447
  if width is not None:
1444
- params.update({"w": width})
1448
+ params["w"] = width
1445
1449
 
1446
1450
  if height is not None:
1447
- params.update({"h": height})
1448
-
1449
- path = "package-snapshot"
1450
- if dt is not None:
1451
- path = "recording-snapshot"
1452
- del params["force"]
1453
- params.update({"lens": 2})
1451
+ params["h"] = height
1454
1452
 
1455
1453
  return await self.api_request_raw(
1456
1454
  f"cameras/{camera_id}/{path}",
uiprotect/data/types.py CHANGED
@@ -111,6 +111,16 @@ class ModelType(str, UnknownValuesEnumMixin, enum.Enum):
111
111
  """Return the devices key."""
112
112
  return f"{self.value}s"
113
113
 
114
+ @cached_property
115
+ def name(self) -> str:
116
+ """Return the name."""
117
+ return self._name_
118
+
119
+ @cached_property
120
+ def value(self) -> str:
121
+ """Return the value."""
122
+ return self._value_
123
+
114
124
  @classmethod
115
125
  @cache
116
126
  def from_string(cls, value: str) -> ModelType:
@@ -575,6 +585,16 @@ class PermissionNode(str, UnknownValuesEnumMixin, enum.Enum):
575
585
  READ_LIVE = "readlive"
576
586
  UNKNOWN = "unknown"
577
587
 
588
+ @cached_property
589
+ def name(self) -> str:
590
+ """Return the name."""
591
+ return self._name_
592
+
593
+ @cached_property
594
+ def value(self) -> str:
595
+ """Return the value."""
596
+ return self._value_
597
+
578
598
 
579
599
  @enum.unique
580
600
  class HDRMode(str, UnknownValuesEnumMixin, enum.Enum):
uiprotect/data/user.py CHANGED
@@ -210,7 +210,7 @@ class User(ProtectModelWithId):
210
210
  ) -> bool:
211
211
  """Checks if a user can do a specific action"""
212
212
  check_self = False
213
- if model == self.model and obj is not None and obj.id == self.id:
213
+ if model is self.model and obj is not None and obj.id == self.id:
214
214
  perm_str = f"{model.value}:{node.value}:$"
215
215
  check_self = True
216
216
  else:
@@ -221,7 +221,7 @@ class User(ProtectModelWithId):
221
221
  return self._perm_cache[perm_str]
222
222
 
223
223
  for perm in self.all_permissions:
224
- if model != perm.model or node not in perm.nodes:
224
+ if model is not perm.model or node not in perm.nodes:
225
225
  continue
226
226
  if perm.obj_ids is None:
227
227
  self._perm_cache[perm_str] = True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uiprotect
3
- Version: 5.2.2
3
+ Version: 5.3.0
4
4
  Summary: Python API for Unifi Protect (Unofficial)
5
5
  Home-page: https://github.com/uilibs/uiprotect
6
6
  Author: UI Protect Maintainers
@@ -1,6 +1,6 @@
1
1
  uiprotect/__init__.py,sha256=GDRM9WvWUBbOyBVgltq6Qv8i7LVdWEbG8q5EzYvOFbE,636
2
2
  uiprotect/__main__.py,sha256=C_bHCOkv5qj6WMy-6ELoY3Y6HDhLxOa1a30CzmbZhsg,462
3
- uiprotect/api.py,sha256=8zfSeqDKArG2pbvImqibQx4HrMi_y06fYXrgcwYztCc,67585
3
+ uiprotect/api.py,sha256=1gtyhk-MRFy6_wGR32Y520XJ2Ucxr1nevuBosod0r7w,67637
4
4
  uiprotect/cli/__init__.py,sha256=1MO8rJmjjAsfVx2x01gn5DJo8B64xdPGo6gRVJbWd18,8868
5
5
  uiprotect/cli/backup.py,sha256=ZiS7RZnJGKI8TJKLW2cOUzkRM8nyTvE5Ov_jZZGtvSM,36708
6
6
  uiprotect/cli/base.py,sha256=k-_qGuNT7br0iV0KE5F4wYXF75iyLLjBEckTqxC71xM,7591
@@ -19,8 +19,8 @@ uiprotect/data/bootstrap.py,sha256=OSPHu08p7Ys9KqEb8sq_LFufuECtF4lY7OnAYK27ngo,2
19
19
  uiprotect/data/convert.py,sha256=8h6Il_DhMkPRDPj9F_rA2UZIlTuchS3BQD24peKpk2A,2185
20
20
  uiprotect/data/devices.py,sha256=0l8eiTCwacdHCmOc7qNzeUMpHLxvd6FeB7DOqZKycdA,110880
21
21
  uiprotect/data/nvr.py,sha256=8M-62AG4q1k71eX-DaFcdO52QWG4zO9X5Voj0Tj9D5A,46598
22
- uiprotect/data/types.py,sha256=3CocULpkdTgF4is1nIEDYIlwf2EOkNNM7L4kJ7NkAwM,17654
23
- uiprotect/data/user.py,sha256=YvgXJKV4_y-bm0eySWz9f_ie9aR5lpVn17t9H0Pix8I,6998
22
+ uiprotect/data/types.py,sha256=nrTvvpI3Ja5IV-ixmOpsYwTXrggRK_vQth9InQn-FkI,18088
23
+ uiprotect/data/user.py,sha256=1o5gyPHafn4lHARpoSMD_NWbo5IbzGPfiSASwqqDvWs,7002
24
24
  uiprotect/data/websocket.py,sha256=5-yM6yr8NrxKJjBPQlGVXXQUTcksF-UavligKYjJQ3k,6770
25
25
  uiprotect/exceptions.py,sha256=kgn0cRM6lTtgLza09SDa3ZiX6ue1QqHCOogQ4qu6KTQ,965
26
26
  uiprotect/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -30,8 +30,8 @@ uiprotect/test_util/__init__.py,sha256=Ky8mTL61nhp5II2mxTKBAsSGvNqK8U_CfKC5AGwTo
30
30
  uiprotect/test_util/anonymize.py,sha256=f-8ijU-_y9r-uAbhIPn0f0I6hzJpAkvJzc8UpWihObI,8478
31
31
  uiprotect/utils.py,sha256=O2RIiUZX4kBHq5v3L598uYe7rbhOcKTeqyYQi6rITnQ,19865
32
32
  uiprotect/websocket.py,sha256=D5DZrMzo434ecp8toNxOB5HM193kVwYw42yEcg99yMw,8029
33
- uiprotect-5.2.2.dist-info/LICENSE,sha256=INx18jhdbVXMEiiBANeKEbrbz57ckgzxk5uutmmcxGk,1111
34
- uiprotect-5.2.2.dist-info/METADATA,sha256=QQDSk2kJVhI26UrCHznBCNmQHzfVXuxL4yuGAOK1fAI,11009
35
- uiprotect-5.2.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
36
- uiprotect-5.2.2.dist-info/entry_points.txt,sha256=J78AUTPrTTxgI3s7SVgrmGqDP7piX2wuuEORzhDdVRA,47
37
- uiprotect-5.2.2.dist-info/RECORD,,
33
+ uiprotect-5.3.0.dist-info/LICENSE,sha256=INx18jhdbVXMEiiBANeKEbrbz57ckgzxk5uutmmcxGk,1111
34
+ uiprotect-5.3.0.dist-info/METADATA,sha256=t-z36ZssCujkhRP7d_YGpeqiEufq2tIBEii5ThRopZ8,11009
35
+ uiprotect-5.3.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
36
+ uiprotect-5.3.0.dist-info/entry_points.txt,sha256=J78AUTPrTTxgI3s7SVgrmGqDP7piX2wuuEORzhDdVRA,47
37
+ uiprotect-5.3.0.dist-info/RECORD,,