Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions homeassistant/components/broadlink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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
Expand Down Expand Up @@ -85,10 +85,11 @@ async def async_learn_command(call):
_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
Expand Down
6 changes: 4 additions & 2 deletions homeassistant/components/broadlink/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
BroadlinkException,
DeviceOfflineError,
ReadError,
StorageError,
)
import voluptuous as vol

Expand Down Expand Up @@ -321,10 +322,11 @@ async def _async_capture_code(self, command, timeout):
code = None
start_time = utcnow()
while (utcnow() - start_time) < timedelta(seconds=timeout):
await asyncio.sleep(1)
try:
code = await self.device.async_request(self.device.api.check_data)
except ReadError:
await asyncio.sleep(1)
except (ReadError, StorageError):
continue
else:
break

Expand Down