mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Handle StorageError in the Broadlink integration (#35986)
This commit is contained in:
parent
88ebdf3a53
commit
3d253fa52a
@ -6,7 +6,7 @@ from datetime import timedelta
|
|||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from broadlink.exceptions import BroadlinkException, ReadError
|
from broadlink.exceptions import BroadlinkException, ReadError, StorageError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import CONF_HOST
|
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")
|
_LOGGER.info("Press the key you want Home Assistant to learn")
|
||||||
start_time = utcnow()
|
start_time = utcnow()
|
||||||
while (utcnow() - start_time) < timedelta(seconds=20):
|
while (utcnow() - start_time) < timedelta(seconds=20):
|
||||||
|
await asyncio.sleep(1)
|
||||||
try:
|
try:
|
||||||
packet = await device.async_request(device.api.check_data)
|
packet = await device.async_request(device.api.check_data)
|
||||||
except ReadError:
|
except (ReadError, StorageError):
|
||||||
await asyncio.sleep(1)
|
continue
|
||||||
except BroadlinkException as err_msg:
|
except BroadlinkException as err_msg:
|
||||||
_LOGGER.error("Failed to learn: %s", err_msg)
|
_LOGGER.error("Failed to learn: %s", err_msg)
|
||||||
return
|
return
|
||||||
|
@ -14,6 +14,7 @@ from broadlink.exceptions import (
|
|||||||
BroadlinkException,
|
BroadlinkException,
|
||||||
DeviceOfflineError,
|
DeviceOfflineError,
|
||||||
ReadError,
|
ReadError,
|
||||||
|
StorageError,
|
||||||
)
|
)
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
@ -321,10 +322,11 @@ class BroadlinkRemote(RemoteEntity):
|
|||||||
code = None
|
code = None
|
||||||
start_time = utcnow()
|
start_time = utcnow()
|
||||||
while (utcnow() - start_time) < timedelta(seconds=timeout):
|
while (utcnow() - start_time) < timedelta(seconds=timeout):
|
||||||
|
await asyncio.sleep(1)
|
||||||
try:
|
try:
|
||||||
code = await self.device.async_request(self.device.api.check_data)
|
code = await self.device.async_request(self.device.api.check_data)
|
||||||
except ReadError:
|
except (ReadError, StorageError):
|
||||||
await asyncio.sleep(1)
|
continue
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user