uiprotect 5.2.1__tar.gz → 5.2.2__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-5.2.1 → uiprotect-5.2.2}/PKG-INFO +1 -1
  2. {uiprotect-5.2.1 → uiprotect-5.2.2}/pyproject.toml +1 -1
  3. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/data/devices.py +18 -6
  4. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/utils.py +5 -0
  5. {uiprotect-5.2.1 → uiprotect-5.2.2}/LICENSE +0 -0
  6. {uiprotect-5.2.1 → uiprotect-5.2.2}/README.md +0 -0
  7. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/__init__.py +0 -0
  8. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/__main__.py +0 -0
  9. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/api.py +0 -0
  10. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/cli/__init__.py +0 -0
  11. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/cli/backup.py +0 -0
  12. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/cli/base.py +0 -0
  13. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/cli/cameras.py +0 -0
  14. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/cli/chimes.py +0 -0
  15. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/cli/doorlocks.py +0 -0
  16. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/cli/events.py +0 -0
  17. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/cli/lights.py +0 -0
  18. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/cli/liveviews.py +0 -0
  19. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/cli/nvr.py +0 -0
  20. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/cli/sensors.py +0 -0
  21. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/cli/viewers.py +0 -0
  22. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/data/__init__.py +0 -0
  23. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/data/base.py +0 -0
  24. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/data/bootstrap.py +0 -0
  25. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/data/convert.py +0 -0
  26. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/data/nvr.py +0 -0
  27. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/data/types.py +0 -0
  28. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/data/user.py +0 -0
  29. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/data/websocket.py +0 -0
  30. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/exceptions.py +0 -0
  31. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/py.typed +0 -0
  32. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/release_cache.json +0 -0
  33. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/stream.py +0 -0
  34. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/test_util/__init__.py +0 -0
  35. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/test_util/anonymize.py +0 -0
  36. {uiprotect-5.2.1 → uiprotect-5.2.2}/src/uiprotect/websocket.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uiprotect
3
- Version: 5.2.1
3
+ Version: 5.2.2
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
  [tool.poetry]
2
2
  name = "uiprotect"
3
- version = "5.2.1"
3
+ version = "5.2.2"
4
4
  description = "Python API for Unifi Protect (Unofficial)"
5
5
  authors = ["UI Protect Maintainers <ui@koston.org>"]
6
6
  readme = "README.md"
@@ -7,7 +7,7 @@ import logging
7
7
  import warnings
8
8
  from collections.abc import Callable
9
9
  from datetime import datetime, timedelta
10
- from functools import cache
10
+ from functools import cache, lru_cache
11
11
  from ipaddress import IPv4Address
12
12
  from pathlib import Path
13
13
  from typing import TYPE_CHECKING, Any, Literal, cast
@@ -25,6 +25,7 @@ from ..utils import (
25
25
  convert_video_modes,
26
26
  from_js_time,
27
27
  serialize_point,
28
+ timedelta_total_seconds,
28
29
  to_js_time,
29
30
  utc_now,
30
31
  )
@@ -900,6 +901,15 @@ class CameraAudioSettings(ProtectBaseObject):
900
901
  style: list[AudioStyle]
901
902
 
902
903
 
904
+ @lru_cache
905
+ def _chime_type_from_total_seconds(total_seconds: float) -> ChimeType:
906
+ if total_seconds == 0.3:
907
+ return ChimeType.MECHANICAL
908
+ if total_seconds > 0.3:
909
+ return ChimeType.DIGITAL
910
+ return ChimeType.NONE
911
+
912
+
903
913
  class Camera(ProtectMotionDeviceModel):
904
914
  is_deleting: bool
905
915
  # Microphone Sensitivity
@@ -1855,11 +1865,13 @@ class Camera(ProtectMotionDeviceModel):
1855
1865
 
1856
1866
  @property
1857
1867
  def chime_type(self) -> ChimeType:
1858
- if self.chime_duration.total_seconds() == 0.3:
1859
- return ChimeType.MECHANICAL
1860
- if self.chime_duration.total_seconds() > 0.3:
1861
- return ChimeType.DIGITAL
1862
- return ChimeType.NONE
1868
+ return _chime_type_from_total_seconds(
1869
+ timedelta_total_seconds(self.chime_duration)
1870
+ )
1871
+
1872
+ @property
1873
+ def chime_duration_seconds(self) -> float:
1874
+ return timedelta_total_seconds(self.chime_duration)
1863
1875
 
1864
1876
  @property
1865
1877
  def is_digital_chime(self) -> bool:
@@ -670,3 +670,8 @@ def make_required_getter(ufp_required_field: str) -> Callable[[T], bool]:
670
670
  if "." not in ufp_required_field:
671
671
  return partial(get_top_level_attr_as_bool, ufp_required_field)
672
672
  return partial(get_nested_attr_as_bool, tuple(ufp_required_field.split(".")))
673
+
674
+
675
+ @lru_cache
676
+ def timedelta_total_seconds(td: timedelta) -> float:
677
+ return td.total_seconds()
File without changes
File without changes