mirror of
https://github.com/home-assistant/core.git
synced 2025-11-12 20:40:18 +00:00
Migrate HomeKit Controller to use stable identifiers (#80064)
This commit is contained in:
@@ -7,7 +7,9 @@ from aiohomekit.model.characteristics import (
|
||||
)
|
||||
from aiohomekit.model.services import ServicesTypes
|
||||
|
||||
from .common import setup_test_component
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from .common import get_next_aid, setup_test_component
|
||||
|
||||
|
||||
def create_switch_service(accessory):
|
||||
@@ -215,3 +217,30 @@ async def test_char_switch_read_state(hass, utcnow):
|
||||
{CharacteristicsTypes.VENDOR_AQARA_PAIRING_MODE: False},
|
||||
)
|
||||
assert switch_1.state == "off"
|
||||
|
||||
|
||||
async def test_migrate_unique_id(hass, utcnow):
|
||||
"""Test a we can migrate a switch unique id."""
|
||||
entity_registry = er.async_get(hass)
|
||||
aid = get_next_aid()
|
||||
switch_entry = entity_registry.async_get_or_create(
|
||||
"switch",
|
||||
"homekit_controller",
|
||||
f"homekit-00:00:00:00:00:00-{aid}-8",
|
||||
)
|
||||
switch_entry_2 = entity_registry.async_get_or_create(
|
||||
"switch",
|
||||
"homekit_controller",
|
||||
f"homekit-0001-aid:{aid}-sid:8-cid:9",
|
||||
)
|
||||
await setup_test_component(hass, create_char_switch_service, suffix="pairing_mode")
|
||||
|
||||
assert (
|
||||
entity_registry.async_get(switch_entry.entity_id).unique_id
|
||||
== f"00:00:00:00:00:00_{aid}_8"
|
||||
)
|
||||
|
||||
assert (
|
||||
entity_registry.async_get(switch_entry_2.entity_id).unique_id
|
||||
== f"00:00:00:00:00:00_{aid}_8_9"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user