uiprotect 1.6.0__tar.gz → 1.7.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.6.0 → uiprotect-1.7.1}/PKG-INFO +1 -1
  2. {uiprotect-1.6.0 → uiprotect-1.7.1}/pyproject.toml +1 -1
  3. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/data/base.py +8 -0
  4. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/data/bootstrap.py +2 -2
  5. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/data/nvr.py +19 -12
  6. {uiprotect-1.6.0 → uiprotect-1.7.1}/LICENSE +0 -0
  7. {uiprotect-1.6.0 → uiprotect-1.7.1}/README.md +0 -0
  8. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/__init__.py +0 -0
  9. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/__main__.py +0 -0
  10. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/api.py +0 -0
  11. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/cli/__init__.py +0 -0
  12. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/cli/backup.py +0 -0
  13. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/cli/base.py +0 -0
  14. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/cli/cameras.py +0 -0
  15. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/cli/chimes.py +0 -0
  16. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/cli/doorlocks.py +0 -0
  17. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/cli/events.py +0 -0
  18. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/cli/lights.py +0 -0
  19. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/cli/liveviews.py +0 -0
  20. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/cli/nvr.py +0 -0
  21. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/cli/sensors.py +0 -0
  22. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/cli/viewers.py +0 -0
  23. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/data/__init__.py +0 -0
  24. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/data/convert.py +0 -0
  25. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/data/devices.py +0 -0
  26. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/data/types.py +0 -0
  27. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/data/user.py +0 -0
  28. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/data/websocket.py +0 -0
  29. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/exceptions.py +0 -0
  30. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/py.typed +0 -0
  31. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/release_cache.json +0 -0
  32. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/stream.py +0 -0
  33. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/test_util/__init__.py +0 -0
  34. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/test_util/anonymize.py +0 -0
  35. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/utils.py +0 -0
  36. {uiprotect-1.6.0 → uiprotect-1.7.1}/src/uiprotect/websocket.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uiprotect
3
- Version: 1.6.0
3
+ Version: 1.7.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.6.0"
3
+ version = "1.7.1"
4
4
  description = "Python API for Unifi Protect (Unofficial)"
5
5
  authors = ["UI Protect Maintainers <ui@koston.org>"]
6
6
  license = "MIT"
@@ -745,6 +745,14 @@ class ProtectModelWithId(ProtectModel):
745
745
  revert_on_fail: bool = True,
746
746
  ) -> None:
747
747
  """Saves the current device changes to UFP."""
748
+ _LOGGER.debug(
749
+ "Saving device changes for %s (%s) data_before_changes=%s updated=%s",
750
+ self.id,
751
+ self.model,
752
+ data_before_changes,
753
+ updated,
754
+ )
755
+
748
756
  assert (
749
757
  self._update_lock.locked()
750
758
  ), "save_device_changes should only be called when the update lock is held"
@@ -353,7 +353,7 @@ class Bootstrap(ProtectBaseObject):
353
353
  if TYPE_CHECKING:
354
354
  assert isinstance(obj, Event)
355
355
  self.process_event(obj)
356
- if model_type is ModelType.NVR:
356
+ elif model_type is ModelType.NVR:
357
357
  if TYPE_CHECKING:
358
358
  assert isinstance(obj, NVR)
359
359
  self.nvr = obj
@@ -370,7 +370,7 @@ class Bootstrap(ProtectBaseObject):
370
370
  self.id_lookup[obj.id] = ref
371
371
  self.mac_lookup[normalize_mac(obj.mac)] = ref
372
372
  else:
373
- _LOGGER.debug("Unexpected bootstrap model type for add: %s", obj.model)
373
+ _LOGGER.debug("Unexpected bootstrap model type for add: %s", model_type)
374
374
  return None
375
375
 
376
376
  updated = obj.dict()
@@ -5,6 +5,7 @@ from __future__ import annotations
5
5
  import asyncio
6
6
  import logging
7
7
  import zoneinfo
8
+ from collections.abc import Callable
8
9
  from datetime import datetime, timedelta, tzinfo
9
10
  from functools import cache
10
11
  from ipaddress import IPv4Address, IPv6Address
@@ -1169,26 +1170,32 @@ class NVR(ProtectDeviceModel):
1169
1170
  if message in self.doorbell_settings.custom_messages:
1170
1171
  raise BadRequest("Custom doorbell message already exists")
1171
1172
 
1172
- async with self._update_lock:
1173
- await asyncio.sleep(
1174
- 0,
1175
- ) # yield to the event loop once we have the look to ensure websocket updates are processed
1176
- data_before_changes = self.dict_with_excludes()
1177
- self.doorbell_settings.custom_messages.append(DoorbellText(message))
1178
- await self.save_device(data_before_changes)
1179
- self.update_all_messages()
1173
+ await self._update_doorbell_messages(
1174
+ lambda: self.doorbell_settings.custom_messages.append(
1175
+ DoorbellText(message)
1176
+ ),
1177
+ )
1180
1178
 
1181
1179
  async def remove_custom_doorbell_message(self, message: str) -> None:
1182
1180
  """Removes custom doorbell message"""
1183
1181
  if message not in self.doorbell_settings.custom_messages:
1184
1182
  raise BadRequest("Custom doorbell message does not exists")
1185
1183
 
1184
+ await self._update_doorbell_messages(
1185
+ lambda: self.doorbell_settings.custom_messages.remove(
1186
+ DoorbellText(message)
1187
+ ),
1188
+ )
1189
+
1190
+ async def _update_doorbell_messages(
1191
+ self, update_callback: Callable[[], None]
1192
+ ) -> None:
1193
+ """Updates doorbell messages and saves to Protect."""
1186
1194
  async with self._update_lock:
1187
- await asyncio.sleep(
1188
- 0,
1189
- ) # yield to the event loop once we have the look to ensure websocket updates are processed
1195
+ # yield to the event loop once we have the lock to ensure websocket updates are processed
1196
+ await asyncio.sleep(0)
1190
1197
  data_before_changes = self.dict_with_excludes()
1191
- self.doorbell_settings.custom_messages.remove(DoorbellText(message))
1198
+ update_callback()
1192
1199
  await self.save_device(data_before_changes)
1193
1200
  self.update_all_messages()
1194
1201
 
File without changes
File without changes