1
mirror of https://github.com/home-assistant/core synced 2024-07-15 09:42:11 +02:00

Remove assert for unique_id (#106910)

* Remove assert for unique_id

* Use str | None return instead
This commit is contained in:
Marc Mueller 2024-01-02 22:01:12 +01:00 committed by GitHub
parent 1526c321f1
commit f0d520d91f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 deletions

View File

@ -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,

View File

@ -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,
)