Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with blocked communication and reload #168

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions custom_components/zaptec/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,17 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

_LOGGER.debug("Unloading entry %s", entry.entry_id)

coordinator = hass.data[DOMAIN][entry.entry_id]
await coordinator.cancel_streams()
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)

if unload_ok:
coordinator = hass.data[DOMAIN].pop(entry.entry_id)
await coordinator.cancel_streams()
hass.data[DOMAIN].pop(entry.entry_id)

await async_unload_services(hass)

return unload_ok


async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Reload config entry."""
_LOGGER.debug("Reloading entry %s", entry.entry_id)
Expand Down
6 changes: 4 additions & 2 deletions custom_components/zaptec/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,10 @@ async def _stream(self, cb=None, ssl_context=None):

self._stream_receiver = None
async with servicebus_client:
receiver = servicebus_client.get_subscription_receiver(
topic_name=conf["Topic"], subscription_name=conf["Subscription"]
receiver = await asyncio.to_thread(
servicebus_client.get_subscription_receiver,
topic_name=conf["Topic"],
subscription_name=conf["Subscription"]
)
# Store the receiver in order to close it and cancel this stream
self._stream_receiver = receiver
Expand Down