diff --git a/custom_components/zha_toolkit/__init__.py b/custom_components/zha_toolkit/__init__.py index 852ceaf..0dc603c 100644 --- a/custom_components/zha_toolkit/__init__.py +++ b/custom_components/zha_toolkit/__init__.py @@ -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 @@ -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) @@ -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, @@ -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( diff --git a/custom_components/zha_toolkit/utils.py b/custom_components/zha_toolkit/utils.py index 1118f79..e3d0307 100644 --- a/custom_components/zha_toolkit/utils.py +++ b/custom_components/zha_toolkit/utils.py @@ -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