From f0d520d91ff388b04c61f9f8892596a16a382c52 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 2 Jan 2024 22:01:12 +0100 Subject: [PATCH] Remove assert for unique_id (#106910) * Remove assert for unique_id * Use str | None return instead --- homeassistant/components/axis/device.py | 9 ++++----- homeassistant/components/axis/entity.py | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/axis/device.py b/homeassistant/components/axis/device.py index 243ad90d4a30..67ef61af8ac7 100644 --- a/homeassistant/components/axis/device.py +++ b/homeassistant/components/axis/device.py @@ -101,10 +101,9 @@ class AxisNetworkDevice: return name @property - def unique_id(self) -> str: + def unique_id(self) -> str | None: """Return the unique ID (serial number) of this device.""" - assert (unique_id := self.config_entry.unique_id) - return unique_id + return self.config_entry.unique_id # Options @@ -176,8 +175,8 @@ class AxisNetworkDevice: device_registry.async_get_or_create( config_entry_id=self.config_entry.entry_id, configuration_url=self.api.config.url, - connections={(CONNECTION_NETWORK_MAC, self.unique_id)}, - identifiers={(AXIS_DOMAIN, self.unique_id)}, + connections={(CONNECTION_NETWORK_MAC, self.unique_id)}, # type: ignore[arg-type] + identifiers={(AXIS_DOMAIN, self.unique_id)}, # type: ignore[arg-type] manufacturer=ATTR_MANUFACTURER, model=f"{self.model} {self.product_type}", name=self.name, diff --git a/homeassistant/components/axis/entity.py b/homeassistant/components/axis/entity.py index 5a1fede53c7e..81f0b1678fb4 100644 --- a/homeassistant/components/axis/entity.py +++ b/homeassistant/components/axis/entity.py @@ -42,7 +42,7 @@ class AxisEntity(Entity): self.device = device self._attr_device_info = DeviceInfo( - identifiers={(AXIS_DOMAIN, device.unique_id)}, + identifiers={(AXIS_DOMAIN, device.unique_id)}, # type: ignore[arg-type] serial_number=device.unique_id, )