Home Assistant Unofficial Reference 2024.12.1
homeassistant.components.bluetooth.api Namespace Reference

Functions

HomeAssistantBluetoothManager _get_manager (HomeAssistant hass)
 
bool async_address_present (HomeAssistant hass, str address, bool connectable=True)
 
BLEDevice|None async_ble_device_from_address (HomeAssistant hass, str address, bool connectable=True)
 
Iterable[BluetoothServiceInfoBleak] async_discovered_service_info (HomeAssistant hass, bool connectable=True)
 
Callable[[BluetoothServiceInfoBleak], None] async_get_advertisement_callback (HomeAssistant hass)
 
float|None async_get_fallback_availability_interval (HomeAssistant hass, str address)
 
float|None async_get_learned_advertising_interval (HomeAssistant hass, str address)
 
HaBleakScannerWrapper async_get_scanner (HomeAssistant hass)
 
BluetoothServiceInfoBleak|None async_last_service_info (HomeAssistant hass, str address, bool connectable=True)
 
BluetoothServiceInfoBleak async_process_advertisements (HomeAssistant hass, ProcessAdvertisementCallback callback, BluetoothCallbackMatcher match_dict, BluetoothScanningMode mode, int timeout)
 
None async_rediscover_address (HomeAssistant hass, str address)
 
Callable[[], None] async_register_callback (HomeAssistant hass, BluetoothCallback callback, BluetoothCallbackMatcher|None match_dict, BluetoothScanningMode mode)
 
CALLBACK_TYPE async_register_scanner (HomeAssistant hass, BaseHaScanner scanner, int|None connection_slots=None)
 
BaseHaScanner|None async_scanner_by_source (HomeAssistant hass, str source)
 
int async_scanner_count (HomeAssistant hass, bool connectable=True)
 
list[BluetoothScannerDevice] async_scanner_devices_by_address (HomeAssistant hass, str address, bool connectable=True)
 
None async_set_fallback_availability_interval (HomeAssistant hass, str address, float interval)
 
Callable[[], None] async_track_unavailable (HomeAssistant hass, Callable[[BluetoothServiceInfoBleak], None] callback, str address, bool connectable=True)
 

Detailed Description

The bluetooth integration apis.

These APIs are the only documented way to interact with the bluetooth integration.

Function Documentation

◆ _get_manager()

HomeAssistantBluetoothManager homeassistant.components.bluetooth.api._get_manager ( HomeAssistant  hass)
private
Get the bluetooth manager.

Definition at line 35 of file api.py.

◆ async_address_present()

bool homeassistant.components.bluetooth.api.async_address_present ( HomeAssistant  hass,
str  address,
bool   connectable = True 
)
Check if an address is present in the bluetooth device list.

Definition at line 102 of file api.py.

◆ async_ble_device_from_address()

BLEDevice | None homeassistant.components.bluetooth.api.async_ble_device_from_address ( HomeAssistant  hass,
str  address,
bool   connectable = True 
)
Return BLEDevice for an address if its present.

Definition at line 86 of file api.py.

◆ async_discovered_service_info()

Iterable[BluetoothServiceInfoBleak] homeassistant.components.bluetooth.api.async_discovered_service_info ( HomeAssistant  hass,
bool   connectable = True 
)
Return the discovered devices list.

Definition at line 70 of file api.py.

◆ async_get_advertisement_callback()

Callable[[BluetoothServiceInfoBleak], None] homeassistant.components.bluetooth.api.async_get_advertisement_callback ( HomeAssistant  hass)
Get the advertisement callback.

Definition at line 187 of file api.py.

◆ async_get_fallback_availability_interval()

float | None homeassistant.components.bluetooth.api.async_get_fallback_availability_interval ( HomeAssistant  hass,
str   address 
)
Get the fallback availability timeout for a MAC address.

Definition at line 203 of file api.py.

◆ async_get_learned_advertising_interval()

float | None homeassistant.components.bluetooth.api.async_get_learned_advertising_interval ( HomeAssistant  hass,
str   address 
)
Get the learned advertising interval for a MAC address.

Definition at line 195 of file api.py.

◆ async_get_scanner()

HaBleakScannerWrapper homeassistant.components.bluetooth.api.async_get_scanner ( HomeAssistant  hass)
Return a HaBleakScannerWrapper.

This is a wrapper around our BleakScanner singleton that allows
multiple integrations to share the same BleakScanner.

Definition at line 41 of file api.py.

◆ async_last_service_info()

BluetoothServiceInfoBleak | None homeassistant.components.bluetooth.api.async_last_service_info ( HomeAssistant  hass,
str  address,
bool   connectable = True 
)
Return the last service info for an address.

Definition at line 78 of file api.py.

◆ async_process_advertisements()

BluetoothServiceInfoBleak homeassistant.components.bluetooth.api.async_process_advertisements ( HomeAssistant  hass,
ProcessAdvertisementCallback  callback,
BluetoothCallbackMatcher  match_dict,
BluetoothScanningMode  mode,
int  timeout 
)
Process advertisements until callback returns true or timeout expires.

Definition at line 128 of file api.py.

◆ async_rediscover_address()

None homeassistant.components.bluetooth.api.async_rediscover_address ( HomeAssistant  hass,
str  address 
)
Trigger discovery of devices which have already been seen.

Definition at line 171 of file api.py.

◆ async_register_callback()

Callable[[], None] homeassistant.components.bluetooth.api.async_register_callback ( HomeAssistant  hass,
BluetoothCallback  callback,
BluetoothCallbackMatcher | None  match_dict,
BluetoothScanningMode  mode 
)
Register to receive a callback on bluetooth change.

mode is currently not used as we only support active scanning.
Passive scanning will be available in the future. The flag
is required to be present to avoid a future breaking change
when we support passive scanning.

Returns a callback that can be used to cancel the registration.

Definition at line 110 of file api.py.

◆ async_register_scanner()

CALLBACK_TYPE homeassistant.components.bluetooth.api.async_register_scanner ( HomeAssistant  hass,
BaseHaScanner  scanner,
int | None   connection_slots = None 
)
Register a BleakScanner.

Definition at line 177 of file api.py.

◆ async_scanner_by_source()

BaseHaScanner | None homeassistant.components.bluetooth.api.async_scanner_by_source ( HomeAssistant  hass,
str  source 
)
Return a scanner for a given source.

This method is only intended to be used by integrations that implement
a bluetooth client and need to interact with a scanner directly.

It is not intended to be used by integrations that need to interact
with a device.

Definition at line 51 of file api.py.

◆ async_scanner_count()

int homeassistant.components.bluetooth.api.async_scanner_count ( HomeAssistant  hass,
bool   connectable = True 
)
Return the number of scanners currently in use.

Definition at line 64 of file api.py.

◆ async_scanner_devices_by_address()

list[BluetoothScannerDevice] homeassistant.components.bluetooth.api.async_scanner_devices_by_address ( HomeAssistant  hass,
str  address,
bool   connectable = True 
)
Return all discovered BluetoothScannerDevice for an address.

Definition at line 94 of file api.py.

◆ async_set_fallback_availability_interval()

None homeassistant.components.bluetooth.api.async_set_fallback_availability_interval ( HomeAssistant  hass,
str  address,
float   interval 
)
Override the fallback availability timeout for a MAC address.

Definition at line 211 of file api.py.

◆ async_track_unavailable()

Callable[[], None] homeassistant.components.bluetooth.api.async_track_unavailable ( HomeAssistant  hass,
Callable[[BluetoothServiceInfoBleak], None]  callback,
str  address,
bool   connectable = True 
)
Register to receive a callback when an address is unavailable.

Returns a callback that can be used to cancel the registration.

Definition at line 157 of file api.py.