1 """Tracking for bluetooth low energy devices."""
3 from __future__
import annotations
5 from abc
import abstractmethod
14 from .const
import DOMAIN
15 from .coordinator
import async_get_coordinator, async_last_service_info
19 """Base Private Bluetooth Entity."""
21 _attr_should_poll =
False
22 _attr_has_entity_name =
True
24 def __init__(self, config_entry: ConfigEntry) ->
None:
25 """Set up a new BleScanner entity."""
26 irk = config_entry.data[
"irk"]
34 name=f
"Private BLE Device {irk[:6]}",
35 identifiers={(DOMAIN, irk)},
39 self.
_irk_irk = binascii.unhexlify(irk)
40 self._last_info: bluetooth.BluetoothServiceInfoBleak |
None =
None
43 """Configure entity when it is added to Home Assistant."""
46 coordinator.async_track_service_info(
51 coordinator.async_track_unavailable(
58 service_info, bluetooth.BluetoothChange.ADVERTISEMENT
64 self, service_info: bluetooth.BluetoothServiceInfoBleak
66 """Respond when the bluetooth device being tracked is no longer visible."""
72 service_info: bluetooth.BluetoothServiceInfoBleak,
73 change: bluetooth.BluetoothChange,
75 """Respond when the bluetooth device being tracked broadcasted updated information."""
None _async_track_service_info(self, bluetooth.BluetoothServiceInfoBleak service_info, bluetooth.BluetoothChange change)
None _async_track_unavailable(self, bluetooth.BluetoothServiceInfoBleak service_info)
None __init__(self, ConfigEntry config_entry)
None async_added_to_hass(self)
None async_on_remove(self, CALLBACK_TYPE func)
str|None translation_key(self)
BluetoothServiceInfoBleak|None async_last_service_info(HomeAssistant hass, str address, bool connectable=True)
PrivateDevicesCoordinator async_get_coordinator(HomeAssistant hass)