From e21a9b5c0a520fd38c77eaffdca5aadbbdc796e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olive=CC=81r=20Falvai?= Date: Sat, 18 Dec 2021 10:22:29 +0100 Subject: [PATCH] Add sleep before retrying API call --- custom_components/candy/client/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/custom_components/candy/client/__init__.py b/custom_components/candy/client/__init__.py index 927e917..ccd1b98 100644 --- a/custom_components/candy/client/__init__.py +++ b/custom_components/candy/client/__init__.py @@ -1,3 +1,4 @@ +import asyncio import json import logging from json import JSONDecodeError @@ -65,6 +66,7 @@ async def detect_encryption(session: aiohttp.ClientSession, device_ip: str) -> ( except Exception as e: _LOGGER.debug(e) _LOGGER.info("Failed to get a valid response without encryption, let's try with encrypted=1...") + await asyncio.sleep(5) url = _status_url(device_ip, use_encryption=True) async with session.get(url) as resp: resp_hex = await resp.text() # Response is hex encoded encrypted data