Improve rainbird error handling (#98239)
This commit is contained in:
parent
6f97270cd2
commit
9ddf11f6cd
7 changed files with 170 additions and 17 deletions
|
@ -8,7 +8,11 @@ import logging
|
|||
from typing import TypeVar
|
||||
|
||||
import async_timeout
|
||||
from pyrainbird.async_client import AsyncRainbirdController, RainbirdApiException
|
||||
from pyrainbird.async_client import (
|
||||
AsyncRainbirdController,
|
||||
RainbirdApiException,
|
||||
RainbirdDeviceBusyException,
|
||||
)
|
||||
from pyrainbird.data import ModelAndVersion
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -84,8 +88,10 @@ class RainbirdUpdateCoordinator(DataUpdateCoordinator[RainbirdDeviceState]):
|
|||
try:
|
||||
async with async_timeout.timeout(TIMEOUT_SECONDS):
|
||||
return await self._fetch_data()
|
||||
except RainbirdDeviceBusyException as err:
|
||||
raise UpdateFailed("Rain Bird device is busy") from err
|
||||
except RainbirdApiException as err:
|
||||
raise UpdateFailed(f"Error communicating with Device: {err}") from err
|
||||
raise UpdateFailed("Rain Bird device failure") from err
|
||||
|
||||
async def _fetch_data(self) -> RainbirdDeviceState:
|
||||
"""Fetch data from the Rain Bird device.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue