Migrate HomeKit Controller to use stable identifiers (#80064)
This commit is contained in:
parent
e3a3f93441
commit
f23b1750e8
66 changed files with 781 additions and 234 deletions
|
@ -16,6 +16,7 @@ from homeassistant.components.number import (
|
|||
NumberEntityDescription,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -59,12 +60,12 @@ async def async_setup_entry(
|
|||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up Homekit numbers."""
|
||||
hkid = config_entry.data["AccessoryPairingID"]
|
||||
hkid: str = config_entry.data["AccessoryPairingID"]
|
||||
conn: HKDevice = hass.data[KNOWN_DEVICES][hkid]
|
||||
|
||||
@callback
|
||||
def async_add_characteristic(char: Characteristic) -> bool:
|
||||
entities = []
|
||||
entities: list[HomeKitNumber] = []
|
||||
info = {"aid": char.service.accessory.aid, "iid": char.service.iid}
|
||||
|
||||
if description := NUMBER_ENTITIES.get(char.type):
|
||||
|
@ -72,6 +73,11 @@ async def async_setup_entry(
|
|||
else:
|
||||
return False
|
||||
|
||||
for entity in entities:
|
||||
conn.async_migrate_unique_id(
|
||||
entity.old_unique_id, entity.unique_id, Platform.NUMBER
|
||||
)
|
||||
|
||||
async_add_entities(entities, True)
|
||||
return True
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue