diff --git a/custom_components/webrtc/__init__.py b/custom_components/webrtc/__init__.py index 51aa2ec..5550ca9 100644 --- a/custom_components/webrtc/__init__.py +++ b/custom_components/webrtc/__init__.py @@ -131,7 +131,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): return True # 3. Serve go2rtc binary manually - binary = await utils.validate_binary(hass) + binary = await hass.async_add_executor_job(utils.validate_binary, hass) if not binary: return False diff --git a/custom_components/webrtc/utils.py b/custom_components/webrtc/utils.py index 8f7c8d0..a126438 100644 --- a/custom_components/webrtc/utils.py +++ b/custom_components/webrtc/utils.py @@ -11,6 +11,7 @@ from urllib.parse import urljoin import jwt +import requests from aiohttp import web from homeassistant.components.frontend import add_extra_js_url from homeassistant.components.http.auth import DATA_SIGN_SECRET, SIGN_QUERY_PARAM @@ -62,7 +63,7 @@ def unzip(content: bytes) -> bytes: return f.read() -async def validate_binary(hass: HomeAssistant) -> Optional[str]: +def validate_binary(hass: HomeAssistant) -> Optional[str]: filename = f"go2rtc-{BINARY_VERSION}" if platform.system() == "Windows": filename += ".exe" @@ -83,11 +84,11 @@ async def validate_binary(hass: HomeAssistant) -> Optional[str]: f"v{BINARY_VERSION}/{get_arch()}" ) _LOGGER.debug(f"Download new binary: {url}") - r = await async_get_clientsession(hass).get(url) + r = requests.get(url) if not r.ok: return None - raw = await r.read() + raw = r.content # unzip binary for windows if url.endswith(".zip"):