diff --git a/homeassistant/components/togrill/coordinator.py b/homeassistant/components/togrill/coordinator.py index 4b50037c404..6d01e279b05 100644 --- a/homeassistant/components/togrill/coordinator.py +++ b/homeassistant/components/togrill/coordinator.py @@ -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() diff --git a/homeassistant/components/togrill/entity.py b/homeassistant/components/togrill/entity.py index f744b9f851b..4e25332e73e 100644 --- a/homeassistant/components/togrill/entity.py +++ b/homeassistant/components/togrill/entity.py @@ -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 + )