1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Remove workaround in togrill to trigger coordinator (#154784)

This commit is contained in:
Joakim Plate
2025-10-18 19:41:02 +02:00
committed by GitHub
parent d2380608e1
commit 3b09adb360

View File

@@ -199,7 +199,7 @@ class ToGrillCoordinator(DataUpdateCoordinator[dict[tuple[int, int | None], Pack
if self.client and not self.client.is_connected:
await self.client.disconnect()
self.client = None
self._async_request_refresh_soon()
self._debounced_refresh.async_schedule_call()
raise DeviceFailed("Device was disconnected")
client = await self._get_connected_client()
@@ -212,26 +212,10 @@ class ToGrillCoordinator(DataUpdateCoordinator[dict[tuple[int, int | None], Pack
raise DeviceFailed(f"Device failed {exc}") from exc
return self.data
@callback
def _async_request_refresh_soon(self) -> None:
"""Request a refresh in the near future.
This way have been called during an update and
would be ignored by debounce logic, so we delay
it by a slight amount to hopefully let the current
update finish first.
"""
async def _delayed_refresh() -> None:
await asyncio.sleep(0.5)
await self.async_request_refresh()
self.config_entry.async_create_task(self.hass, _delayed_refresh())
@callback
def _disconnected_callback(self) -> None:
"""Handle Bluetooth device being disconnected."""
self._async_request_refresh_soon()
self._debounced_refresh.async_schedule_call()
@callback
def _async_handle_bluetooth_event(
@@ -241,4 +225,4 @@ class ToGrillCoordinator(DataUpdateCoordinator[dict[tuple[int, int | None], Pack
) -> None:
"""Handle a Bluetooth event."""
if isinstance(self.last_exception, DeviceNotFound):
self._async_request_refresh_soon()
self._debounced_refresh.async_schedule_call()