Skip to content

Commit 47d3f27

Browse files
committed
Fix #238 Async version for reading the version from the manifest file
1 parent e5a4910 commit 47d3f27

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

.pre-commit-config.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ repos:
146146
args:
147147
- --reports=no
148148
- --py-version=3.10
149-
# additional_dependencies:
149+
additional_dependencies:
150+
- aiofiles>=0.4.0
150151
# - pylint-blocking-calls
151152
# - homeassistant-stubs>=2023.1.7
152153
# exclude: ^$
@@ -165,6 +166,7 @@ repos:
165166
- --show-error-context
166167
additional_dependencies:
167168
- zigpy==0.61.0
169+
- aiofiles>=0.4.0
168170
# - cryptography==3.3.2 # Compatible/Available on cygwin
169171
#- homeassistant-stubs>=2023.1.7
170172
#- pydantic

custom_components/zha_toolkit/__init__.py

+5-5
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-
if u.getVersion() != LOADED_VERSION:
708+
if await u.getVersion() != LOADED_VERSION:
709709
LOGGER.debug(
710710
"Reload services because VERSION changed from %s to %s",
711711
LOADED_VERSION,
@@ -738,7 +738,7 @@ async def toolkit_service(service):
738738

739739
# Preload event_data
740740
event_data = {
741-
"zha_toolkit_version": u.getVersion(),
741+
"zha_toolkit_version": await u.getVersion(),
742742
"zigpy_version": u.getZigpyVersion(),
743743
"zigpy_rf_version": u.get_radio_version(app),
744744
"ieee_org": ieee_str,
@@ -859,7 +859,7 @@ async def toolkit_service(service):
859859
schema=value,
860860
)
861861

862-
LOADED_VERSION = u.getVersion()
862+
LOADED_VERSION = await u.getVersion()
863863

864864

865865
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-
def getVersion() -> str:
57+
async 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)