mirror of
https://github.com/Electric-Special/ha-core.git
synced 2026-03-21 03:03:17 +01:00
Consider missing togrill device okey to log real errors (#161544)
This commit is contained in:
@@ -144,14 +144,15 @@ class ToGrillCoordinator(DataUpdateCoordinator[dict[tuple[int, int | None], Pack
|
||||
)
|
||||
except BleakError as exc:
|
||||
self.logger.debug("Connection failed", exc_info=True)
|
||||
raise DeviceNotFound("Unable to connect to device") from exc
|
||||
raise DeviceFailed("Unable to connect to device") from exc
|
||||
|
||||
try:
|
||||
async with asyncio.timeout(10):
|
||||
packet_a0 = await client.read(PacketA0Notify)
|
||||
except (BleakError, DecodeError, TimeoutError) as exc:
|
||||
self.logger.debug("Configuration read failed", exc_info=True)
|
||||
await client.disconnect()
|
||||
raise DeviceFailed(f"Device failed {exc}") from exc
|
||||
raise DeviceFailed("Failed to read device configuration") from exc
|
||||
|
||||
config_entry = self.config_entry
|
||||
|
||||
@@ -202,7 +203,11 @@ class ToGrillCoordinator(DataUpdateCoordinator[dict[tuple[int, int | None], Pack
|
||||
self._debounced_refresh.async_schedule_call()
|
||||
raise DeviceFailed("Device was disconnected")
|
||||
|
||||
client = await self._get_connected_client()
|
||||
try:
|
||||
client = await self._get_connected_client()
|
||||
except DeviceNotFound:
|
||||
return {}
|
||||
|
||||
try:
|
||||
await client.request(PacketA0Notify)
|
||||
await client.request(PacketA1Notify)
|
||||
@@ -224,5 +229,5 @@ class ToGrillCoordinator(DataUpdateCoordinator[dict[tuple[int, int | None], Pack
|
||||
change: BluetoothChange,
|
||||
) -> None:
|
||||
"""Handle a Bluetooth event."""
|
||||
if isinstance(self.last_exception, DeviceNotFound):
|
||||
if self.client is None:
|
||||
self._debounced_refresh.async_schedule_call()
|
||||
|
||||
@@ -49,3 +49,10 @@ class ToGrillEntity(CoordinatorEntity[ToGrillCoordinator]):
|
||||
translation_domain=DOMAIN, translation_key="rejected"
|
||||
) from exc
|
||||
await self.coordinator.async_request_refresh()
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Return if entity is available."""
|
||||
return (
|
||||
self.coordinator.last_update_success and self.coordinator.client is not None
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user