Skip to content

Commit

Permalink
Merge pull request #242 from mdeweerd/dev
Browse files Browse the repository at this point in the history
Fix #241 blocking call
  • Loading branch information
mdeweerd authored Aug 5, 2024
2 parents c6a1d4a + ed25e70 commit 2fe9507
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions custom_components/zha_toolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,12 +657,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 @@ -710,11 +710,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 @@ -743,7 +744,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 @@ -864,7 +865,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 @@ -59,7 +59,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

0 comments on commit 2fe9507

Please sign in to comment.