mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 06:37:52 +00:00
Add -9999 error fix back in Xiaomi Miio (#57399)
This commit is contained in:
parent
5829f93b53
commit
6ef70c85ee
@ -146,12 +146,23 @@ def get_platforms(config_entry):
|
|||||||
def _async_update_data_default(hass, device):
|
def _async_update_data_default(hass, device):
|
||||||
async def update():
|
async def update():
|
||||||
"""Fetch data from the device using async_add_executor_job."""
|
"""Fetch data from the device using async_add_executor_job."""
|
||||||
try:
|
|
||||||
|
async def _async_fetch_data():
|
||||||
|
"""Fetch data from the device."""
|
||||||
async with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
state = await hass.async_add_executor_job(device.status)
|
state = await hass.async_add_executor_job(device.status)
|
||||||
_LOGGER.debug("Got new state: %s", state)
|
_LOGGER.debug("Got new state: %s", state)
|
||||||
return state
|
return state
|
||||||
|
|
||||||
|
try:
|
||||||
|
return await _async_fetch_data()
|
||||||
|
except DeviceException as ex:
|
||||||
|
if getattr(ex, "code", None) != -9999:
|
||||||
|
raise UpdateFailed(ex) from ex
|
||||||
|
_LOGGER.info("Got exception while fetching the state, trying again: %s", ex)
|
||||||
|
# Try to fetch the data a second time after error code -9999
|
||||||
|
try:
|
||||||
|
return await _async_fetch_data()
|
||||||
except DeviceException as ex:
|
except DeviceException as ex:
|
||||||
raise UpdateFailed(ex) from ex
|
raise UpdateFailed(ex) from ex
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user