Skip to content

Commit

Permalink
Merge pull request #12 from AfonsoFGarcia/fix-loop-errors
Browse files Browse the repository at this point in the history
Fix loop errors
  • Loading branch information
AfonsoFGarcia authored Oct 4, 2024
2 parents aeec05b + 6cc2113 commit 8cad0f1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
22 changes: 17 additions & 5 deletions custom_components/bluecon/ConfigFolderNotificationInfoStorage.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
from bluecon import INotificationInfoStorage
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
Expand All @@ -8,19 +9,30 @@

class ConfigFolderNotificationInfoStorage(INotificationInfoStorage):
def __init__(self, hass: HomeAssistant):
self.__hass = hass
self.__credentialsStore = Store(hass=hass, version=1, key=f"{DOMAIN}.CREDENTIALS")
self.__persistentIdsStore = Store(hass=hass, version=1, key=f"{DOMAIN}.PERSISTENT_IDS")

async def retrieveCredentials(self) -> dict[str, dict[str, Any]] | None:
return await self.__credentialsStore.async_load()
return asyncio.run_coroutine_threadsafe(
self.__credentialsStore.async_load(), self.__hass.loop
).result()

async def storeCredentials(self, credentials: dict[str, dict[str, Any]]):
await self.__credentialsStore.async_save(credentials)
asyncio.run_coroutine_threadsafe(
self.__credentialsStore.async_save(credentials), self.__hass.loop
).result()

async def retrievePersistentIds(self) -> list[str] | None:
return await self.__persistentIdsStore.async_load()
return asyncio.run_coroutine_threadsafe(
self.__persistentIdsStore.async_load(), self.__hass.loop
).result()

async def storePersistentId(self, persistentId: str):
persistentIds = await self.retrievePersistentIds() or []
persistentIds = asyncio.run_coroutine_threadsafe(
self.retrievePersistentIds(), self.__hass.loop
).result() or []
persistentId.append(persistentId)
await self.__persistentIdsStore.async_save(persistentIds)
asyncio.run_coroutine_threadsafe(
self.__persistentIdsStore.async_save(persistentIds), self.__hass.loop
).result()
2 changes: 1 addition & 1 deletion custom_components/bluecon/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"domain": "bluecon",
"name": "Fermax Blue",
"version": "0.6.0",
"version": "0.6.4",
"documentation": "https://hass-bluecon.afonsogarcia.dev/",
"issue_tracker": "https://github.com/AfonsoFGarcia/hass-bluecon/issues",
"requirements": ["bluecon==0.4.2", "aiohttp", "aiohttp", "rustPlusPushReceiver", "python-dateutil"],
Expand Down

0 comments on commit 8cad0f1

Please sign in to comment.