Skip to content

Commit

Permalink
ruff formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ep1cman committed Oct 26, 2024
1 parent 78a2c30 commit 2c43149
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
18 changes: 4 additions & 14 deletions unifi_protect_backup/event_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ def __init__(
async def start(self):
"""Main Loop."""
logger.debug("Subscribed to websocket")
self._unsub_websocket_state = self._protect.subscribe_websocket_state(
self._websocket_state_callback
)
self._unsub_websocket_state = self._protect.subscribe_websocket_state(self._websocket_state_callback)
self._unsub = self._protect.subscribe_websocket(self._websocket_callback)

def _websocket_callback(self, msg: WSSubscriptionMessage) -> None:
Expand All @@ -71,19 +69,13 @@ def _websocket_callback(self, msg: WSSubscriptionMessage) -> None:
EventType.SMART_DETECT_LINE,
]:
return
if (
msg.new_obj.type is EventType.MOTION
and "motion" not in self.detection_types
):
if msg.new_obj.type is EventType.MOTION and "motion" not in self.detection_types:
logger.extra_debug(f"Skipping unwanted motion detection event: {msg.new_obj.id}") # type: ignore
return
if msg.new_obj.type is EventType.RING and "ring" not in self.detection_types:
logger.extra_debug(f"Skipping unwanted ring event: {msg.new_obj.id}") # type: ignore
return
if (
msg.new_obj.type is EventType.SMART_DETECT_LINE
and "line" not in self.detection_types
):
if msg.new_obj.type is EventType.SMART_DETECT_LINE and "line" not in self.detection_types:
logger.extra_debug(f"Skipping unwanted line event: {msg.new_obj.id}") # type: ignore
return
elif msg.new_obj.type is EventType.SMART_DETECT:
Expand All @@ -107,9 +99,7 @@ def _websocket_callback(self, msg: WSSubscriptionMessage) -> None:
if "-" in msg.new_obj.id:
msg.new_obj.id = msg.new_obj.id.split("-")[0]

logger.debug(
f"Adding event {msg.new_obj.id} to queue (Current download queue={self._event_queue.qsize()})"
)
logger.debug(f"Adding event {msg.new_obj.id} to queue (Current download queue={self._event_queue.qsize()})")

def _websocket_state_callback(self, state: WebsocketState) -> None:
"""Callback for websocket state messages.
Expand Down
7 changes: 6 additions & 1 deletion unifi_protect_backup/missing_event_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ async def _get_missing_events(self) -> AsyncIterator[Event]:
events_chunk = await self._protect.get_events(
start=start_time,
end=end_time,
types=[EventType.MOTION, EventType.SMART_DETECT, EventType.RING, EventType.SMART_DETECT_LINE],
types=[
EventType.MOTION,
EventType.SMART_DETECT,
EventType.RING,
EventType.SMART_DETECT_LINE,
],
limit=chunk_size,
)

Expand Down

0 comments on commit 2c43149

Please sign in to comment.