Skip to content

Commit

Permalink
Fix #238 Async version for reading the version from the manifest file
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeweerd committed Aug 5, 2024
1 parent e5a4910 commit 47d3f27
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ repos:
args:
- --reports=no
- --py-version=3.10
# additional_dependencies:
additional_dependencies:
- aiofiles>=0.4.0
# - pylint-blocking-calls
# - homeassistant-stubs>=2023.1.7
# exclude: ^$
Expand All @@ -165,6 +166,7 @@ repos:
- --show-error-context
additional_dependencies:
- zigpy==0.61.0
- aiofiles>=0.4.0
# - cryptography==3.3.2 # Compatible/Available on cygwin
#- homeassistant-stubs>=2023.1.7
#- pydantic
10 changes: 5 additions & 5 deletions custom_components/zha_toolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,12 +652,12 @@ async def async_setup(hass, config):
return True

LOGGER.debug("Setup services from async_setup")
register_services(hass)
await register_services(hass)

return True


def register_services(hass): # noqa: C901
async def register_services(hass): # noqa: C901
global LOADED_VERSION # pylint: disable=global-statement
hass_ref = hass

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

if u.getVersion() != LOADED_VERSION:
if await u.getVersion() != LOADED_VERSION:
LOGGER.debug(
"Reload services because VERSION changed from %s to %s",
LOADED_VERSION,
Expand Down Expand Up @@ -738,7 +738,7 @@ async def toolkit_service(service):

# Preload event_data
event_data = {
"zha_toolkit_version": u.getVersion(),
"zha_toolkit_version": await u.getVersion(),
"zigpy_version": u.getZigpyVersion(),
"zigpy_rf_version": u.get_radio_version(app),
"ieee_org": ieee_str,
Expand Down Expand Up @@ -859,7 +859,7 @@ async def toolkit_service(service):
schema=value,
)

LOADED_VERSION = u.getVersion()
LOADED_VERSION = await u.getVersion()


async def command_handler_default(
Expand Down
2 changes: 1 addition & 1 deletion custom_components/zha_toolkit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def getZigpyVersion() -> str:
return ZIGPY_VERSION


def getVersion() -> str:
async def getVersion() -> str:
# pylint: disable=global-variable-undefined,used-before-assignment
# pylint: disable=global-statement
global VERSION_TIME
Expand Down

0 comments on commit 47d3f27

Please sign in to comment.