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 #241 blocking call #242

Merged
merged 1 commit into from
Aug 5, 2024
Merged
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
13 changes: 7 additions & 6 deletions custom_components/zha_toolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,12 +652,12 @@ async def async_setup(hass, config):
return True

LOGGER.debug("Setup services from async_setup")
await register_services(hass)
await hass.async_add_executor_job(register_services, hass)

return True


async def register_services(hass): # noqa: C901
def register_services(hass): # noqa: C901
global LOADED_VERSION # pylint: disable=global-statement
hass_ref = hass

Expand Down Expand Up @@ -705,11 +705,12 @@ async def toolkit_service(service):
LOGGER.debug("module is %s", module)
importlib.reload(u)

if await u.getVersion() != LOADED_VERSION:
currentVersion = hass.async_add_executor_job(u.getVersion)
if currentVersion != LOADED_VERSION:
LOGGER.debug(
"Reload services because VERSION changed from %s to %s",
LOADED_VERSION,
u.getVersion(),
currentVersion,
)
await _register_services(hass)

Expand Down Expand Up @@ -738,7 +739,7 @@ async def toolkit_service(service):

# Preload event_data
event_data = {
"zha_toolkit_version": await u.getVersion(),
"zha_toolkit_version": currentVersion,
"zigpy_version": u.getZigpyVersion(),
"zigpy_rf_version": u.get_radio_version(app),
"ieee_org": ieee_str,
Expand Down Expand Up @@ -859,7 +860,7 @@ async def toolkit_service(service):
schema=value,
)

LOADED_VERSION = await u.getVersion()
LOADED_VERSION = u.getVersion()


async def command_handler_default(
Expand Down
2 changes: 1 addition & 1 deletion custom_components/zha_toolkit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def getZigpyVersion() -> str:
return ZIGPY_VERSION


async def getVersion() -> str:
def getVersion() -> str:
# pylint: disable=global-variable-undefined,used-before-assignment
# pylint: disable=global-statement
global VERSION_TIME
Expand Down
Loading