mirror of
https://github.com/CCOSTAN/Home-AssistantConfig.git
synced 2025-08-16 02:25:10 +00:00
Finally got around to installing This amazing component by @ludeeus
This commit is contained in:
19
config/custom_components/hacs/store.py
Executable file
19
config/custom_components/hacs/store.py
Executable file
@@ -0,0 +1,19 @@
|
||||
"""Storage handers."""
|
||||
from homeassistant.helpers.json import JSONEncoder
|
||||
from homeassistant.helpers.storage import Store
|
||||
from .hacsbase.const import STORAGE_VERSION
|
||||
|
||||
|
||||
async def async_load_from_store(hass, key):
|
||||
"""Load the retained data from store and return de-serialized data."""
|
||||
store = Store(hass, STORAGE_VERSION, f"hacs.{key}", encoder=JSONEncoder)
|
||||
restored = await store.async_load()
|
||||
if restored is None:
|
||||
return {}
|
||||
return restored
|
||||
|
||||
|
||||
async def async_save_to_store(hass, key, data):
|
||||
"""Generate dynamic data to store and save it to the filesystem."""
|
||||
store = Store(hass, STORAGE_VERSION, f"hacs.{key}", encoder=JSONEncoder)
|
||||
await store.async_save(data)
|
Reference in New Issue
Block a user