Limit log spam by ESPHome (#47456)

This commit is contained in:
Anders Melchiorsen 2021-03-05 16:16:07 +01:00 committed by GitHub
parent 864380e77c
commit 79ebe930e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -256,13 +256,16 @@ async def _setup_auto_reconnect_logic(
# really short reconnect interval.
tries = min(tries, 10) # prevent OverflowError
wait_time = int(round(min(1.8 ** tries, 60.0)))
_LOGGER.info("Trying to reconnect to %s in %s seconds", host, wait_time)
if tries == 1:
_LOGGER.info("Trying to reconnect to %s in the background", host)
_LOGGER.debug("Retrying %s in %d seconds", host, wait_time)
await asyncio.sleep(wait_time)
try:
await cli.connect(on_stop=try_connect, login=True)
except APIConnectionError as error:
_LOGGER.info(
logger = _LOGGER.info if tries == 0 else _LOGGER.debug
logger(
"Can't connect to ESPHome API for %s (%s): %s",
entry.unique_id,
host,