Skip to content

Commit 2fe9507

Browse files
authored
Merge pull request #242 from mdeweerd/dev
Fix #241 blocking call
2 parents c6a1d4a + ed25e70 commit 2fe9507

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
@@ -657,12 +657,12 @@ async def async_setup(hass, config):
657657
return True
658658

659659
LOGGER.debug("Setup services from async_setup")
660-
await register_services(hass)
660+
await hass.async_add_executor_job(register_services, hass)
661661

662662
return True
663663

664664

665-
async def register_services(hass): # noqa: C901
665+
def register_services(hass): # noqa: C901
666666
global LOADED_VERSION # pylint: disable=global-statement
667667
hass_ref = hass
668668

@@ -710,11 +710,12 @@ async def toolkit_service(service):
710710
LOGGER.debug("module is %s", module)
711711
importlib.reload(u)
712712

713-
if await u.getVersion() != LOADED_VERSION:
713+
currentVersion = hass.async_add_executor_job(u.getVersion)
714+
if currentVersion != LOADED_VERSION:
714715
LOGGER.debug(
715716
"Reload services because VERSION changed from %s to %s",
716717
LOADED_VERSION,
717-
u.getVersion(),
718+
currentVersion,
718719
)
719720
await _register_services(hass)
720721

@@ -743,7 +744,7 @@ async def toolkit_service(service):
743744

744745
# Preload event_data
745746
event_data = {
746-
"zha_toolkit_version": await u.getVersion(),
747+
"zha_toolkit_version": currentVersion,
747748
"zigpy_version": u.getZigpyVersion(),
748749
"zigpy_rf_version": u.get_radio_version(app),
749750
"ieee_org": ieee_str,
@@ -864,7 +865,7 @@ async def toolkit_service(service):
864865
schema=value,
865866
)
866867

867-
LOADED_VERSION = await u.getVersion()
868+
LOADED_VERSION = u.getVersion()
868869

869870

870871
async def command_handler_default(

custom_components/zha_toolkit/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def getZigpyVersion() -> str:
5959
return ZIGPY_VERSION
6060

6161

62-
async def getVersion() -> str:
62+
def getVersion() -> str:
6363
# pylint: disable=global-variable-undefined,used-before-assignment
6464
# pylint: disable=global-statement
6565
global VERSION_TIME

0 commit comments

Comments
 (0)