Skip to content

Commit ed25e70

Browse files
committed
Fix #241 blocking call
1 parent ad0ef0e commit ed25e70

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

custom_components/zha_toolkit/__init__.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -652,12 +652,12 @@ async def async_setup(hass, config):
652652
return True
653653

654654
LOGGER.debug("Setup services from async_setup")
655-
await register_services(hass)
655+
await hass.async_add_executor_job(register_services, hass)
656656

657657
return True
658658

659659

660-
async def register_services(hass): # noqa: C901
660+
def register_services(hass): # noqa: C901
661661
global LOADED_VERSION # pylint: disable=global-statement
662662
hass_ref = hass
663663

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

708-
if await u.getVersion() != LOADED_VERSION:
708+
currentVersion = hass.async_add_executor_job(u.getVersion)
709+
if currentVersion != LOADED_VERSION:
709710
LOGGER.debug(
710711
"Reload services because VERSION changed from %s to %s",
711712
LOADED_VERSION,
712-
u.getVersion(),
713+
currentVersion,
713714
)
714715
await _register_services(hass)
715716

@@ -738,7 +739,7 @@ async def toolkit_service(service):
738739

739740
# Preload event_data
740741
event_data = {
741-
"zha_toolkit_version": await u.getVersion(),
742+
"zha_toolkit_version": currentVersion,
742743
"zigpy_version": u.getZigpyVersion(),
743744
"zigpy_rf_version": u.get_radio_version(app),
744745
"ieee_org": ieee_str,
@@ -859,7 +860,7 @@ async def toolkit_service(service):
859860
schema=value,
860861
)
861862

862-
LOADED_VERSION = await u.getVersion()
863+
LOADED_VERSION = u.getVersion()
863864

864865

865866
async def command_handler_default(

custom_components/zha_toolkit/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def getZigpyVersion() -> str:
5454
return ZIGPY_VERSION
5555

5656

57-
async def getVersion() -> str:
57+
def getVersion() -> str:
5858
# pylint: disable=global-variable-undefined,used-before-assignment
5959
# pylint: disable=global-statement
6060
global VERSION_TIME

0 commit comments

Comments
 (0)