From 2c43149c99aea7a3ac0f99c257870b347f4e718d Mon Sep 17 00:00:00 2001 From: Sebastian Goscik Date: Sat, 26 Oct 2024 22:11:42 +0100 Subject: [PATCH] ruff formatting --- unifi_protect_backup/event_listener.py | 18 ++++-------------- unifi_protect_backup/missing_event_checker.py | 7 ++++++- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/unifi_protect_backup/event_listener.py b/unifi_protect_backup/event_listener.py index f9664e5..83845f8 100644 --- a/unifi_protect_backup/event_listener.py +++ b/unifi_protect_backup/event_listener.py @@ -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: @@ -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: @@ -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. diff --git a/unifi_protect_backup/missing_event_checker.py b/unifi_protect_backup/missing_event_checker.py index e6acf2d..24b5f63 100644 --- a/unifi_protect_backup/missing_event_checker.py +++ b/unifi_protect_backup/missing_event_checker.py @@ -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, )