From 735dec8dde2be75363e1bf12bd5f5e1d0b3f0d5f Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Tue, 16 Aug 2022 15:53:16 +0200 Subject: [PATCH] Process UniFi Protect review comments (#76870) --- .../components/unifiprotect/media_source.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/unifiprotect/media_source.py b/homeassistant/components/unifiprotect/media_source.py index f9ea3620be3..7e66f783ee0 100644 --- a/homeassistant/components/unifiprotect/media_source.py +++ b/homeassistant/components/unifiprotect/media_source.py @@ -344,11 +344,11 @@ class ProtectMediaSource(MediaSource): return await self._build_event(data, event, thumbnail_only) - async def get_registry(self) -> er.EntityRegistry: + @callback + def async_get_registry(self) -> er.EntityRegistry: """Get or return Entity Registry.""" - if self._registry is None: - self._registry = await er.async_get_registry(self.hass) + self._registry = er.async_get(self.hass) return self._registry def _breadcrumb( @@ -473,9 +473,8 @@ class ProtectMediaSource(MediaSource): continue # smart detect events have a paired motion event - if ( - event.get("type") == EventType.MOTION.value - and len(event.get("smartDetectEvents", [])) > 0 + if event.get("type") == EventType.MOTION.value and event.get( + "smartDetectEvents" ): continue @@ -717,7 +716,7 @@ class ProtectMediaSource(MediaSource): return None entity_id: str | None = None - entity_registry = await self.get_registry() + entity_registry = self.async_get_registry() for channel in camera.channels: # do not use the package camera if channel.id == 3: