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
@@ -203,7 +203,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
return True
class DateTimeStorageCollection(collection.StorageCollection):
class DateTimeStorageCollection(collection.DictStorageCollection):
"""Input storage based collection."""
CREATE_UPDATE_SCHEMA = vol.Schema(vol.All(STORAGE_FIELDS, has_date_or_time))
@@ -217,10 +217,10 @@ class DateTimeStorageCollection(collection.StorageCollection):
"""Suggest an ID based on the config."""
return 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
class InputDatetime(collection.CollectionEntity, RestoreEntity):