Skip to content

Commit

Permalink
Improve/correct async loading of Version
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeweerd committed Aug 8, 2024
1 parent 354b9fc commit c321250
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 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")
register_services(hass)
await register_services(hass)

return True


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

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

currentVersion = hass.async_add_executor_job(u.getVersion)
currentVersion = await u.getVersion()
if currentVersion != LOADED_VERSION:
LOGGER.debug(
"Reload services because VERSION changed from %s to %s",
Expand Down Expand Up @@ -860,7 +860,7 @@ async def toolkit_service(service):
schema=value,
)

LOADED_VERSION = u.getVersion()
LOADED_VERSION = await 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 @@ -55,7 +55,7 @@ def getZigpyVersion() -> str:
return ZIGPY_VERSION


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

0 comments on commit c321250

Please sign in to comment.