From 9631c0ba2b524cc9a2fd5ac0156dd6e9d995acfd Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 13 Sep 2023 13:19:01 -0500 Subject: [PATCH] Use short hand attributes in onvif camera (#100319) see #95315 --- homeassistant/components/onvif/camera.py | 25 ++++++++---------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/homeassistant/components/onvif/camera.py b/homeassistant/components/onvif/camera.py index 96ce70344fd..013dd2e453f 100644 --- a/homeassistant/components/onvif/camera.py +++ b/homeassistant/components/onvif/camera.py @@ -113,29 +113,20 @@ class ONVIFCameraEntity(ONVIFBaseEntity, Camera): ) self._stream_uri: str | None = None self._stream_uri_future: asyncio.Future[str] | None = None + self._attr_entity_registry_enabled_default = ( + device.max_resolution == profile.video.resolution.width + ) + if profile.index: + self._attr_unique_id = f"{self.mac_or_serial}_{profile.index}" + else: + self._attr_unique_id = self.mac_or_serial + self._attr_name = f"{device.name} {profile.name}" @property def use_stream_for_stills(self) -> bool: """Whether or not to use stream to generate stills.""" return bool(self.stream and self.stream.dynamic_stream_settings.preload_stream) - @property - def name(self) -> str: - """Return the name of this camera.""" - return f"{self.device.name} {self.profile.name}" - - @property - def unique_id(self) -> str: - """Return a unique ID.""" - if self.profile.index: - return f"{self.mac_or_serial}_{self.profile.index}" - return self.mac_or_serial - - @property - def entity_registry_enabled_default(self) -> bool: - """Return if the entity should be enabled when first added to the entity registry.""" - return self.device.max_resolution == self.profile.video.resolution.width - async def stream_source(self): """Return the stream source.""" return await self._async_get_stream_uri()