Skip to content

Commit c321250

Browse files
committed
Improve/correct async loading of Version
1 parent 354b9fc commit c321250

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

custom_components/zha_toolkit/__init__.py

+4-4
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-
register_services(hass)
655+
await register_services(hass)
656656

657657
return True
658658

659659

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

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

708-
currentVersion = hass.async_add_executor_job(u.getVersion)
708+
currentVersion = await u.getVersion()
709709
if currentVersion != LOADED_VERSION:
710710
LOGGER.debug(
711711
"Reload services because VERSION changed from %s to %s",
@@ -860,7 +860,7 @@ async def toolkit_service(service):
860860
schema=value,
861861
)
862862

863-
LOADED_VERSION = u.getVersion()
863+
LOADED_VERSION = await u.getVersion()
864864

865865

866866
async def command_handler_default(

custom_components/zha_toolkit/utils.py

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

5757

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

0 commit comments

Comments
 (0)