Allow storing other items than untyped dict in StorageCollection (#90932)

Allow storing other items than untyped dict in StorageCollection
This commit is contained in:
Erik Montnemery
2023-04-06 10:57:00 -04:00
committed by GitHub
parent 8025fbf398
commit 59a02cd08c
18 changed files with 134 additions and 91 deletions
@@ -56,7 +56,7 @@ STORAGE_KEY = DOMAIN
STORAGE_VERSION = 1
class InputButtonStorageCollection(collection.StorageCollection):
class InputButtonStorageCollection(collection.DictStorageCollection):
"""Input button collection stored in storage."""
CREATE_UPDATE_SCHEMA = vol.Schema(STORAGE_FIELDS)
@@ -70,10 +70,10 @@ class InputButtonStorageCollection(collection.StorageCollection):
"""Suggest an ID based on the config."""
return cast(str, info[CONF_NAME])
async def _update_data(self, data: dict, update_data: dict) -> dict:
async def _update_data(self, item: dict, update_data: dict) -> dict:
"""Return a new updated data object."""
update_data = self.CREATE_UPDATE_SCHEMA(update_data)
return {CONF_ID: data[CONF_ID]} | update_data
return {CONF_ID: item[CONF_ID]} | update_data
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: