Skip to content

Commit

Permalink
Fix blocking call inside the event loop #1426
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Sep 7, 2024
1 parent cf6a3e1 commit 211d11e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions custom_components/sonoff/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import DeviceEntry

from .core import xutils
from .core.const import DOMAIN, PRIVATE_KEYS
from .core.ewelink import XRegistry
from .core import xutils


async def async_get_config_entry_diagnostics(hass: HomeAssistant, entry: ConfigEntry):
Expand Down Expand Up @@ -53,7 +53,7 @@ async def async_get_config_entry_diagnostics(hass: HomeAssistant, entry: ConfigE
devices = repr(e)

return {
"version": xutils.source_hash(),
"version": await hass.async_add_executor_job(xutils.source_hash),
"cloud_auth": registry.cloud.auth is not None,
"config": config,
"options": options,
Expand Down
11 changes: 8 additions & 3 deletions custom_components/sonoff/system_health.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provide info to system health."""

import logging
import re
import traceback
Expand All @@ -12,8 +13,8 @@
from homeassistant.components.http import HomeAssistantView
from homeassistant.core import HomeAssistant, callback

from .core.const import DOMAIN, PRIVATE_KEYS
from .core import xutils
from .core.const import DOMAIN, PRIVATE_KEYS


@callback
Expand All @@ -40,9 +41,11 @@ async def system_health_info(hass: HomeAssistant):
if "host" in device and "params" in device:
local_online += 1

source_hash = await hass.async_add_executor_job(xutils.source_hash)

integration = hass.data["integrations"][DOMAIN]
info = {
"version": f"{integration.version} ({xutils.source_hash()})",
"version": f"{integration.version} ({source_hash})",
"cloud_online": f"{cloud_online} / {cloud_total}",
"local_online": f"{local_online} / {local_total}",
}
Expand All @@ -57,9 +60,11 @@ async def setup_debug(hass: HomeAssistant, logger: Logger):
view = DebugView(logger)
hass.http.register_view(view)

source_hash = await hass.async_add_executor_job(xutils.source_hash)

integration = hass.data["integrations"][DOMAIN]
info = await hass.helpers.system_info.async_get_system_info()
info[DOMAIN + "_version"] = f"{integration.version} ({xutils.source_hash()})"
info[DOMAIN + "_version"] = f"{integration.version} ({source_hash})"
logger.debug(f"SysInfo: {info}")

integration.manifest["issue_tracker"] = view.url
Expand Down

0 comments on commit 211d11e

Please sign in to comment.