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

@@ -2,7 +2,9 @@
from aiohomekit.model.characteristics import CharacteristicsTypes
from aiohomekit.model.services import ServicesTypes
from .common import Helper, setup_test_component
from homeassistant.helpers import entity_registry as er
from .common import Helper, get_next_aid, setup_test_component
def create_switch_with_spray_level(accessory):
@@ -26,6 +28,24 @@ def create_switch_with_spray_level(accessory):
return service
async def test_migrate_unique_id(hass, utcnow):
"""Test a we can migrate a number unique id."""
entity_registry = er.async_get(hass)
aid = get_next_aid()
number = entity_registry.async_get_or_create(
"number",
"homekit_controller",
f"homekit-0001-aid:{aid}-sid:8-cid:9",
suggested_object_id="testdevice_spray_quantity",
)
await setup_test_component(hass, create_switch_with_spray_level)
assert (
entity_registry.async_get(number.entity_id).unique_id
== f"00:00:00:00:00:00_{aid}_8_9"
)
async def test_read_number(hass, utcnow):
"""Test a switch service that has a sensor characteristic is correctly handled."""
helper = await setup_test_component(hass, create_switch_with_spray_level)