Restore accessory state into pairing using new HKC methods (#75276)
This commit is contained in:
parent
ecc219fbc1
commit
b9c8d65940
14 changed files with 130 additions and 91 deletions
|
@ -7,7 +7,7 @@ from typing import Any, TypedDict
|
|||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.storage import Store
|
||||
|
||||
from .const import DOMAIN
|
||||
from .const import DOMAIN, ENTITY_MAP
|
||||
|
||||
ENTITY_MAP_STORAGE_KEY = f"{DOMAIN}-entity-map"
|
||||
ENTITY_MAP_STORAGE_VERSION = 1
|
||||
|
@ -91,3 +91,13 @@ class EntityMapStorage:
|
|||
def _data_to_save(self) -> StorageLayout:
|
||||
"""Return data of entity map to store in a file."""
|
||||
return StorageLayout(pairings=self.storage_data)
|
||||
|
||||
|
||||
async def async_get_entity_storage(hass: HomeAssistant) -> EntityMapStorage:
|
||||
"""Get entity storage."""
|
||||
if ENTITY_MAP in hass.data:
|
||||
map_storage: EntityMapStorage = hass.data[ENTITY_MAP]
|
||||
return map_storage
|
||||
map_storage = hass.data[ENTITY_MAP] = EntityMapStorage(hass)
|
||||
await map_storage.async_initialize()
|
||||
return map_storage
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue