1 """Update coordinator for the Bluetooth integration."""
3 from __future__
import annotations
5 from abc
import ABC, abstractmethod
8 from habluetooth
import BluetoothScanningMode
13 async_address_present,
14 async_last_service_info,
15 async_register_callback,
16 async_track_unavailable,
18 from .match
import BluetoothCallbackMatcher
19 from .models
import BluetoothChange, BluetoothServiceInfoBleak
23 """Base class for passive bluetooth coordinator for bluetooth advertisements.
25 The coordinator is responsible for tracking devices.
31 logger: logging.Logger,
33 mode: BluetoothScanningMode,
36 """Initialize the coordinator."""
41 self._on_stop: list[CALLBACK_TYPE] = []
51 """Start the data updater."""
59 service_info: BluetoothServiceInfoBleak,
60 change: BluetoothChange,
62 """Handle a bluetooth event."""
66 """Return last known name of the device."""
70 return service_info.name
75 """Return the last time the device was seen."""
81 return service_info.time
88 """Start the callbacks."""
110 """Stop the callbacks."""
111 for unsub
in self._on_stop:
113 self._on_stop.clear()
117 self, service_info: BluetoothServiceInfoBleak
119 """Handle the device going unavailable."""
None _async_handle_unavailable(self, BluetoothServiceInfoBleak service_info)
CALLBACK_TYPE async_start(self)
None __init__(self, HomeAssistant hass, logging.Logger logger, str address, BluetoothScanningMode mode, bool connectable)
None _async_handle_bluetooth_event(self, BluetoothServiceInfoBleak service_info, BluetoothChange change)
bool async_address_present(HomeAssistant hass, str address, bool connectable=True)
Callable[[], None] async_register_callback(HomeAssistant hass, BluetoothCallback callback, BluetoothCallbackMatcher|None match_dict, BluetoothScanningMode mode)
Callable[[], None] async_track_unavailable(HomeAssistant hass, Callable[[BluetoothServiceInfoBleak], None] callback, str address, bool connectable=True)
BluetoothServiceInfoBleak|None async_last_service_info(HomeAssistant hass, str address, bool connectable=True)