Skip to content

Commit

Permalink
Use entry ID for storage key
Browse files Browse the repository at this point in the history
  • Loading branch information
WillCodeForCats committed Jun 15, 2024
1 parent 353eeee commit 6becd93
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions custom_components/tekmar_482/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(
self._id = name.lower()
self._sock = TrpcSocket(host, port)

self._storage = StoredData(self._hass, self._name)
self._storage = StoredData(self._hass, self._entry_id)

self._tha_inventory = {}
self.tha_gateway = []
Expand Down Expand Up @@ -1501,12 +1501,12 @@ def device_info(self) -> Optional[Dict[str, Any]]:
class StoredData(object):
"""Abstraction over Home Assistant Store."""

def __init__(self, hass: HomeAssistant, name: str) -> None:
def __init__(self, hass: HomeAssistant, entry_id: str) -> None:
self._hass = hass
self._name = name
self._entry_id = entry_id
self._data = None

self.store: Store[dict[str, Any]] = Store(
self.store: Store[dict[str, Any]] = TekmarStore(
self._hass,
STORAGE_VERSION_MAJOR,
STORAGE_KEY,
Expand All @@ -1516,14 +1516,14 @@ async def get_setting(self, key: str) -> Any:
if self._data is None:
self._data = await self.store.async_load()

return self._data.get(self._name).get(key)
return self._data.get(self._entry_id).get(key)

async def put_setting(self, key: str, value: Any) -> None:
self._data = await self.store.async_load()
if self._data is None:
self._data = {}

self._data.update([(self._name, {key: value})])
self._data.update([(self._entry_id, {key: value})])
await self.store.async_save(self._data)


Expand Down

0 comments on commit 6becd93

Please sign in to comment.