From a9a9e697725170771c4cc5f6690f5830967289a8 Mon Sep 17 00:00:00 2001 From: fuatakgun Date: Tue, 27 Dec 2022 21:12:34 +0100 Subject: [PATCH] fix: test connection without init --- custom_components/eufy_security/config_flow.py | 2 +- .../eufy_security/eufy_security_api/api_client.py | 5 ++++- custom_components/eufy_security/manifest.json | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/custom_components/eufy_security/config_flow.py b/custom_components/eufy_security/config_flow.py index 4ad9f50..7bf830b 100644 --- a/custom_components/eufy_security/config_flow.py +++ b/custom_components/eufy_security/config_flow.py @@ -108,7 +108,7 @@ async def _show_config_form(self, user_input): # pylint: disable=unused-argumen async def _test_credentials(self, host, port): # pylint: disable=unused-argument try: api_client: ApiClient = ApiClient(host, port, aiohttp_client.async_get_clientsession(self.hass)) - await api_client.connect() + await api_client.ws_connect() await api_client.disconnect() return True except Exception as ex: # pylint: disable=broad-except diff --git a/custom_components/eufy_security/eufy_security_api/api_client.py b/custom_components/eufy_security/eufy_security_api/api_client.py index 43288d2..db8a8d4 100644 --- a/custom_components/eufy_security/eufy_security_api/api_client.py +++ b/custom_components/eufy_security/eufy_security_api/api_client.py @@ -56,9 +56,12 @@ def __init__(self, host: str, port: int, session: aiohttp.ClientSession) -> None self.captcha_future: asyncio.Future[dict] = self.get_new_future() self.mfa_future: asyncio.Future[dict] = self.get_new_future() + async def ws_connect(self): + await self.client.connect() + async def connect(self): """Set up web socket connection and set products""" - await self.client.connect() + await self.ws_connect() await self._set_schema(SCHEMA_VERSION) await self._set_products() diff --git a/custom_components/eufy_security/manifest.json b/custom_components/eufy_security/manifest.json index 1beabab..14366da 100644 --- a/custom_components/eufy_security/manifest.json +++ b/custom_components/eufy_security/manifest.json @@ -3,7 +3,7 @@ "name": "Eufy Security", "documentation": "https://github.com/fuatakgun/eufy_security", "issue_tracker": "https://github.com/fuatakgun/eufy_security/issues", - "dependencies": ["ffmpeg", "http"], + "dependencies": ["ffmpeg", "stream"], "config_flow": true, "version": "5.0.2", "codeowners": ["@fuatakgun"],