1 """Tracking for bluetooth low energy devices."""
3 from __future__
import annotations
5 from collections.abc
import Mapping
16 from .entity
import BasePrivateDeviceEntity
18 _LOGGER = logging.getLogger(__name__)
23 config_entry: ConfigEntry,
24 async_add_entities: AddEntitiesCallback,
26 """Load Device Tracker entities for a config entry."""
31 """A trackable Private Bluetooth Device."""
33 _attr_should_poll =
False
34 _attr_has_entity_name =
True
35 _attr_translation_key =
"device_tracker"
40 """Return extra state attributes for this device."""
43 "current_address": last_info.address,
44 "source": last_info.source,
50 self, service_info: bluetooth.BluetoothServiceInfoBleak
58 service_info: bluetooth.BluetoothServiceInfoBleak,
59 change: bluetooth.BluetoothChange,
66 """Return the state of the device."""
67 return STATE_HOME
if self.
_last_info_last_info
else STATE_NOT_HOME
71 """Return the source type, eg gps or router, of the device."""
72 return SourceType.BLUETOOTH_LE
SourceType source_type(self)
None _async_track_unavailable(self, bluetooth.BluetoothServiceInfoBleak service_info)
None _async_track_service_info(self, bluetooth.BluetoothServiceInfoBleak service_info, bluetooth.BluetoothChange change)
Mapping[str, str] extra_state_attributes(self)
None async_write_ha_state(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)