Handle StorageError in the Broadlink integration (#35986)

This commit is contained in:
Felipe Martins Diel authored and GitHub committed 2020-05-23 11:10:06 +02:00
1 parent 88ebdf3a53
commit 3d253fa52a
2 files changed
+8 -5

No files matched your search

@@ -6,7 +6,7 @@ from datetime import timedelta
import logging
import re
from broadlink.exceptions import BroadlinkException, ReadError
from broadlink.exceptions import BroadlinkException, ReadError, StorageError
import voluptuous as vol
from homeassistant.const import CONF_HOST
@@ -85,10 +85,11 @@ async def async_setup_service(hass, host, device):
_LOGGER.info("Press the key you want Home Assistant to learn")
start_time = utcnow()
while (utcnow() - start_time) < timedelta(seconds=20):
await asyncio.sleep(1)
try:
packet = await device.async_request(device.api.check_data)
except ReadError:
await asyncio.sleep(1)
except (ReadError, StorageError):
continue
except BroadlinkException as err_msg:
_LOGGER.error("Failed to learn: %s", err_msg)
return