mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Fix tplink camera entity unique id (#133880)
This commit is contained in:
parent
386a722393
commit
7f6a77ad2f
@ -108,7 +108,7 @@ class TPLinkCameraEntity(CoordinatedTPLinkEntity, Camera):
|
|||||||
|
|
||||||
def _get_unique_id(self) -> str:
|
def _get_unique_id(self) -> str:
|
||||||
"""Return unique ID for the entity."""
|
"""Return unique ID for the entity."""
|
||||||
return f"{legacy_device_id(self._device)}-{self.entity_description}"
|
return f"{legacy_device_id(self._device)}-{self.entity_description.key}"
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_update_attrs(self) -> None:
|
def _async_update_attrs(self) -> None:
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
'supported_features': <CameraEntityFeature: 3>,
|
'supported_features': <CameraEntityFeature: 3>,
|
||||||
'translation_key': 'live_view',
|
'translation_key': 'live_view',
|
||||||
'unique_id': "123456789ABCDEFGH-TPLinkCameraEntityDescription(key='live_view', device_class=None, entity_category=None, entity_registry_enabled_default=True, entity_registry_visible_default=True, force_update=False, icon=None, has_entity_name=False, name=<UndefinedType._singleton: 0>, translation_key='live_view', translation_placeholders=None, unit_of_measurement=None, deprecated_info=None)",
|
'unique_id': '123456789ABCDEFGH-live_view',
|
||||||
'unit_of_measurement': None,
|
'unit_of_measurement': None,
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
|
@ -24,6 +24,7 @@ from homeassistant.core import HomeAssistant, HomeAssistantError
|
|||||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
|
DEVICE_ID,
|
||||||
IP_ADDRESS3,
|
IP_ADDRESS3,
|
||||||
MAC_ADDRESS3,
|
MAC_ADDRESS3,
|
||||||
SMALLEST_VALID_JPEG_BYTES,
|
SMALLEST_VALID_JPEG_BYTES,
|
||||||
@ -68,6 +69,33 @@ async def test_states(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def test_camera_unique_id(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
mock_camera_config_entry: MockConfigEntry,
|
||||||
|
device_registry: dr.DeviceRegistry,
|
||||||
|
) -> None:
|
||||||
|
"""Test camera unique id."""
|
||||||
|
mock_device = _mocked_device(
|
||||||
|
modules=[Module.Camera],
|
||||||
|
alias="my_camera",
|
||||||
|
ip_address=IP_ADDRESS3,
|
||||||
|
mac=MAC_ADDRESS3,
|
||||||
|
device_id=DEVICE_ID,
|
||||||
|
)
|
||||||
|
|
||||||
|
await setup_platform_for_device(
|
||||||
|
hass, mock_camera_config_entry, Platform.CAMERA, mock_device
|
||||||
|
)
|
||||||
|
|
||||||
|
device_entries = dr.async_entries_for_config_entry(
|
||||||
|
device_registry, mock_camera_config_entry.entry_id
|
||||||
|
)
|
||||||
|
assert device_entries
|
||||||
|
entity_id = "camera.my_camera_live_view"
|
||||||
|
entity_registry = er.async_get(hass)
|
||||||
|
assert entity_registry.async_get(entity_id).unique_id == f"{DEVICE_ID}-live_view"
|
||||||
|
|
||||||
|
|
||||||
async def test_handle_mjpeg_stream(
|
async def test_handle_mjpeg_stream(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_camera_config_entry: MockConfigEntry,
|
mock_camera_config_entry: MockConfigEntry,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user