Skip to content

Commit

Permalink
fix: Restore mug callback
Browse files Browse the repository at this point in the history
  • Loading branch information
sopelj committed Nov 6, 2024
1 parent 693fc7c commit 1d59f5c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions custom_components/ember_mug/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ async def _async_setup(self) -> None:
f"An error occurred updating {self.mug.model_name}: {e=}",
) from e

self.mug.register_callback(
self._async_handle_callback,
)

async def _async_update_data(self) -> MugData:
"""Poll the device."""
_LOGGER.debug("Updating")
Expand Down Expand Up @@ -166,6 +170,12 @@ def handle_bluetooth_event(
self.mug.ble_event_callback(service_info.device, service_info.advertisement)
self.hass.loop.create_task(close_stale_connections(service_info.device))

@callback
def _async_handle_callback(self, mug_data: MugData) -> None:
"""Handle a Bluetooth event."""
_LOGGER.debug("Callback called in Home Assistant")
self.async_set_updated_data(mug_data)

def refresh_from_mug(self) -> None:
"""Update stored data from mug data and trigger entities."""
self.async_set_updated_data(self.mug.data)
Expand Down

0 comments on commit 1d59f5c

Please sign in to comment.