Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle StorageError in the Broadlink integration #35986

Merged
merged 2 commits into from May 23, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions homeassistant/components/broadlink/__init__.py
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
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