Migrate HomeKit Controller to use stable identifiers (#80064)

This commit is contained in:
J. Nick Koston
2022-10-11 11:26:03 -10:00
committed by GitHub
parent e3a3f93441
commit f23b1750e8
66 changed files with 781 additions and 234 deletions

View File

@@ -5,8 +5,9 @@ from aiohomekit.model.services import ServicesTypes
from aiohomekit.testing import FAKE_CAMERA_IMAGE
from homeassistant.components import camera
from homeassistant.helpers import entity_registry as er
from .common import setup_test_component
from .common import get_next_aid, setup_test_component
def create_camera(accessory):
@@ -14,6 +15,22 @@ def create_camera(accessory):
accessory.add_service(ServicesTypes.CAMERA_RTP_STREAM_MANAGEMENT)
async def test_migrate_unique_ids(hass, utcnow):
"""Test migrating entity unique ids."""
entity_registry = er.async_get(hass)
aid = get_next_aid()
camera = entity_registry.async_get_or_create(
"camera",
"homekit_controller",
f"homekit-0001-aid:{aid}",
)
await setup_test_component(hass, create_camera)
assert (
entity_registry.async_get(camera.entity_id).unique_id
== f"00:00:00:00:00:00_{aid}"
)
async def test_read_state(hass, utcnow):
"""Test reading the state of a HomeKit camera."""
helper = await setup_test_component(hass, create_camera)