From c3921f2112d7c8841b0e323f71f7ac0a800f1550 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 5 Sep 2024 19:44:28 -0400 Subject: [PATCH] Add model ID to unifiprotect (#125376) --- homeassistant/components/unifiprotect/entity.py | 3 ++- tests/components/unifiprotect/test_camera.py | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/unifiprotect/entity.py b/homeassistant/components/unifiprotect/entity.py index 17b9f7c4fe9..34b4ec085af 100644 --- a/homeassistant/components/unifiprotect/entity.py +++ b/homeassistant/components/unifiprotect/entity.py @@ -278,7 +278,8 @@ class ProtectDeviceEntity(BaseProtectEntity): self._attr_device_info = DeviceInfo( name=self.device.display_name, manufacturer=DEFAULT_BRAND, - model=self.device.type, + model=self.device.market_name or self.device.type, + model_id=self.device.type, via_device=(DOMAIN, self.data.api.bootstrap.nvr.mac), sw_version=self.device.firmware_version, connections={(dr.CONNECTION_NETWORK_MAC, self.device.mac)}, diff --git a/tests/components/unifiprotect/test_camera.py b/tests/components/unifiprotect/test_camera.py index 9fedb67fea4..ea7a7ae942d 100644 --- a/tests/components/unifiprotect/test_camera.py +++ b/tests/components/unifiprotect/test_camera.py @@ -32,7 +32,7 @@ from homeassistant.const import ( Platform, ) from homeassistant.core import HomeAssistant -from homeassistant.helpers import entity_registry as er +from homeassistant.helpers import device_registry as dr, entity_registry as er from homeassistant.setup import async_setup_component from .utils import ( @@ -66,6 +66,14 @@ def validate_default_camera_entity( assert entity.disabled is False assert entity.unique_id == unique_id + device_registry = dr.async_get(hass) + device = device_registry.async_get(entity.device_id) + assert device + assert device.manufacturer == "Ubiquiti" + assert device.name == camera_obj.name + assert device.model == camera_obj.market_name or camera_obj.type + assert device.model_id == camera_obj.type + return entity_id