uiprotect 7.5.1__py3-none-any.whl → 7.5.3__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/data/base.py CHANGED
@@ -8,7 +8,7 @@ from collections.abc import Callable
8
8
  from datetime import datetime, timedelta
9
9
  from functools import cache
10
10
  from ipaddress import IPv4Address
11
- from typing import TYPE_CHECKING, Any, NamedTuple, TypeVar
11
+ from typing import TYPE_CHECKING, Any, NamedTuple
12
12
  from uuid import UUID
13
13
 
14
14
  from convertertools import pop_dict_set_if_none, pop_dict_tuple
@@ -53,7 +53,6 @@ if TYPE_CHECKING:
53
53
  from ..data.user import User
54
54
 
55
55
 
56
- ProtectObject = TypeVar("ProtectObject", bound="ProtectBaseObject")
57
56
  RECENT_EVENT_MAX = timedelta(seconds=30)
58
57
  EVENT_PING_INTERVAL = timedelta(seconds=3)
59
58
  EVENT_PING_INTERVAL_SECONDS = EVENT_PING_INTERVAL.total_seconds()
@@ -478,7 +477,7 @@ class ProtectBaseObject(BaseModel):
478
477
 
479
478
  return new_data
480
479
 
481
- def update_from_dict(cls: ProtectObject, data: dict[str, Any]) -> ProtectObject:
480
+ def update_from_dict(self, data: dict[str, Any]) -> Self:
482
481
  """
483
482
  Updates current object from a cleaned UFP JSON dict.
484
483
 
@@ -492,15 +491,15 @@ class ProtectBaseObject(BaseModel):
492
491
  has_unifi_lists,
493
492
  unifi_dicts,
494
493
  has_unifi_dicts,
495
- ) = cls._get_protect_model()
496
- api = cls._api
497
- _fields = cls.model_fields
494
+ ) = self._get_protect_model()
495
+ api = self._api
496
+ _fields = self.__class__.model_fields
498
497
  unifi_obj: ProtectBaseObject | None
499
498
  value: Any
500
499
 
501
500
  for key, item in data.items():
502
501
  if has_unifi_objs and key in unifi_objs and isinstance(item, dict):
503
- if (unifi_obj := getattr(cls, key)) is not None:
502
+ if (unifi_obj := getattr(self, key)) is not None:
504
503
  value = unifi_obj.update_from_dict(item)
505
504
  else:
506
505
  value = unifi_objs[key](**item, api=api)
@@ -514,9 +513,9 @@ class ProtectBaseObject(BaseModel):
514
513
  else:
515
514
  value = convert_unifi_data(item, _fields[key])
516
515
 
517
- setattr(cls, key, value)
516
+ setattr(self, key, value)
518
517
 
519
- return cls
518
+ return self
520
519
 
521
520
  def dict_with_excludes(self) -> dict[str, Any]:
522
521
  """Returns a dict of the current object without any UFP objects converted to dicts."""
uiprotect/data/devices.py CHANGED
@@ -587,19 +587,22 @@ class VideoStats(ProtectBaseObject):
587
587
  @classmethod
588
588
  @cache
589
589
  def unifi_dict_conversions(cls) -> dict[str, object | Callable[[Any], Any]]:
590
- return {
591
- key: convert_to_datetime
592
- for key in (
593
- "recordingStart",
594
- "recordingEnd",
595
- "recordingStartLQ",
596
- "recordingEndLQ",
597
- "timelapseStart",
598
- "timelapseEnd",
599
- "timelapseStartLQ",
600
- "timelapseEndLQ",
590
+ return (
591
+ dict.fromkeys(
592
+ (
593
+ "recordingStart",
594
+ "recordingEnd",
595
+ "recordingStartLQ",
596
+ "recordingEndLQ",
597
+ "timelapseStart",
598
+ "timelapseEnd",
599
+ "timelapseStartLQ",
600
+ "timelapseEndLQ",
601
+ ),
602
+ convert_to_datetime,
601
603
  )
602
- } | super().unifi_dict_conversions()
604
+ | super().unifi_dict_conversions()
605
+ )
603
606
 
604
607
 
605
608
  class StorageStats(ProtectBaseObject):
uiprotect/data/nvr.py CHANGED
@@ -321,10 +321,12 @@ class Event(ProtectModelWithId):
321
321
  @classmethod
322
322
  @cache
323
323
  def unifi_dict_conversions(cls) -> dict[str, object | Callable[[Any], Any]]:
324
- return {
325
- key: convert_to_datetime
326
- for key in ("start", "end", "timestamp", "deletedAt")
327
- } | super().unifi_dict_conversions()
324
+ return (
325
+ dict.fromkeys(
326
+ ("start", "end", "timestamp", "deletedAt"), convert_to_datetime
327
+ )
328
+ | super().unifi_dict_conversions()
329
+ )
328
330
 
329
331
  def unifi_dict(
330
332
  self,
uiprotect/data/types.py CHANGED
@@ -679,7 +679,7 @@ RepeatTimes = Annotated[int, Field(ge=1, le=6)]
679
679
  class PTZPositionDegree(BaseModel):
680
680
  pan: float
681
681
  tilt: float
682
- zoom: int
682
+ zoom: float
683
683
 
684
684
 
685
685
  class PTZPositionSteps(BaseModel):
uiprotect/utils.py CHANGED
@@ -154,7 +154,7 @@ def to_ms(duration: timedelta | None) -> int | None:
154
154
  if duration is None:
155
155
  return None
156
156
 
157
- return int(round(duration.total_seconds() * 1000))
157
+ return round(duration.total_seconds() * 1000)
158
158
 
159
159
 
160
160
  def utc_now() -> datetime:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: uiprotect
3
- Version: 7.5.1
3
+ Version: 7.5.3
4
4
  Summary: Python API for Unifi Protect (Unofficial)
5
5
  Author: UI Protect Maintainers
6
6
  Author-email: ui@koston.org
@@ -16,12 +16,12 @@ uiprotect/cli/nvr.py,sha256=TwxEg2XT8jXAbOqv6gc7KFXELKadeItEDYweSL4_-e8,4260
16
16
  uiprotect/cli/sensors.py,sha256=fQtcDJCVxs4VbAqcavgBy2ABiVxAW3GXtna6_XFBp2k,8153
17
17
  uiprotect/cli/viewers.py,sha256=2cyrp104ffIvgT0wYGIO0G35QMkEbFe7fSVqLwDXQYQ,2171
18
18
  uiprotect/data/__init__.py,sha256=audwJBjxRiYdNPeYlP6iofFIOq3gyQzh6VpDsOCM2dQ,2964
19
- uiprotect/data/base.py,sha256=rXm08mA4W7VErgsjS_lqM9HBhFK5-he1L2N6zFMl5yY,35481
19
+ uiprotect/data/base.py,sha256=5DHHot9uHLBg2quXhf0Q2SdiIuQBnR7tLw_8PgODH6s,35397
20
20
  uiprotect/data/bootstrap.py,sha256=ddNaKrTprN7Zq0ZE3O_F5whepUh6z9GqyrUWxLyZ0HE,23570
21
21
  uiprotect/data/convert.py,sha256=xEN878_hm0HZZCVYGwJSxcSp2as9zpkvsemVIibReOA,2628
22
- uiprotect/data/devices.py,sha256=J7tmInERMmC7vUsdBfB83OAr97XYFnwnuvVbOAE90tY,114308
23
- uiprotect/data/nvr.py,sha256=E18DgE0nXl9VZ_ULotTPcXSi3M1u3mWQsuZbY1gIajs,47490
24
- uiprotect/data/types.py,sha256=XVNVCqyWJGTAo557sWD8yZ-kr_Z_35IpkUr-IuBjpO4,19218
22
+ uiprotect/data/devices.py,sha256=AuQK0vfs5J370TW7GDa6M8ylhaFZoxlAL-_SGyCOAUk,114391
23
+ uiprotect/data/nvr.py,sha256=fu6bWx2NpsUKhPUg7bZHshAnONp41zOL8tc39lypW4c,47520
24
+ uiprotect/data/types.py,sha256=TDZwSKELUN0smXLB8uQkyNsHlB61j2ByijeblEt2Css,19220
25
25
  uiprotect/data/user.py,sha256=Del5LUmt5uCfAQMI9-kl_GaKm085oTLjxmcCrlEKXxc,10526
26
26
  uiprotect/data/websocket.py,sha256=m4EV1Qfh08eKOihy70ycViYgEQpeNSGZQJWdtGIYJDA,6791
27
27
  uiprotect/exceptions.py,sha256=kgn0cRM6lTtgLza09SDa3ZiX6ue1QqHCOogQ4qu6KTQ,965
@@ -30,10 +30,10 @@ uiprotect/release_cache.json,sha256=NamnSFy78hOWY0DPO87J9ELFCAN6NnVquv8gQO75ZG4,
30
30
  uiprotect/stream.py,sha256=MWiTRFIhUfFLPA_csSrKl5-SkUbPZ2VhDu0XW2oVr-U,4800
31
31
  uiprotect/test_util/__init__.py,sha256=HlQBgIgdtrvT-gQ5OWP92LbgVr_YzsD5NFImLRonUZk,19320
32
32
  uiprotect/test_util/anonymize.py,sha256=f-8ijU-_y9r-uAbhIPn0f0I6hzJpAkvJzc8UpWihObI,8478
33
- uiprotect/utils.py,sha256=p2cnc6G_-MNAXpKxy95Mz0CwwZOMvB6Sat1X626n-gg,20564
33
+ uiprotect/utils.py,sha256=5Z30chqnQhQdtD1vabRtZXjBpeiJagL5KDuALQlWxk8,20559
34
34
  uiprotect/websocket.py,sha256=tEyenqblNXHcjWYuf4oRP1E7buNwx6zoECMwpBr-jig,8191
35
- uiprotect-7.5.1.dist-info/LICENSE,sha256=INx18jhdbVXMEiiBANeKEbrbz57ckgzxk5uutmmcxGk,1111
36
- uiprotect-7.5.1.dist-info/METADATA,sha256=XYRHc8TDS9BbbDIyelO8CuGEAB-MI3JF34xp9L63VNk,11095
37
- uiprotect-7.5.1.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
38
- uiprotect-7.5.1.dist-info/entry_points.txt,sha256=J78AUTPrTTxgI3s7SVgrmGqDP7piX2wuuEORzhDdVRA,47
39
- uiprotect-7.5.1.dist-info/RECORD,,
35
+ uiprotect-7.5.3.dist-info/LICENSE,sha256=INx18jhdbVXMEiiBANeKEbrbz57ckgzxk5uutmmcxGk,1111
36
+ uiprotect-7.5.3.dist-info/METADATA,sha256=S2b2APeP61Vf8K-pm3fiyaljfJsxXIUZu4enkt9pnQk,11095
37
+ uiprotect-7.5.3.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
38
+ uiprotect-7.5.3.dist-info/entry_points.txt,sha256=J78AUTPrTTxgI3s7SVgrmGqDP7piX2wuuEORzhDdVRA,47
39
+ uiprotect-7.5.3.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.0.1
2
+ Generator: poetry-core 2.1.2
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any