Add missing transmit power to ESPHome Bluetooth scanners (#98175)

We did not previously have a way to get the transmit power value when using
ESPHome scanners. bluetooth-data-tools 1.8.0 includes it in the
advertisment tuple to fully align with the bleak implementation.

txpower is not yet used in the HA codebase but may be expected by
upstream libaries that calculate estimated distance
This commit is contained in:
J. Nick Koston 2023-08-10 15:59:37 -10:00 committed by GitHub
parent 296c27859e
commit 108bcabf75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 14 additions and 14 deletions

View File

@ -18,7 +18,7 @@
"bleak-retry-connector==3.1.1",
"bluetooth-adapters==0.16.0",
"bluetooth-auto-recovery==1.2.1",
"bluetooth-data-tools==1.7.0",
"bluetooth-data-tools==1.8.0",
"dbus-fast==1.91.2"
]
}

View File

@ -2,7 +2,10 @@
from __future__ import annotations
from aioesphomeapi import BluetoothLEAdvertisement, BluetoothLERawAdvertisement
from bluetooth_data_tools import int_to_bluetooth_address, parse_advertisement_data
from bluetooth_data_tools import (
int_to_bluetooth_address,
parse_advertisement_data_tuple,
)
from homeassistant.components.bluetooth import MONOTONIC_TIME, BaseHaRemoteScanner
from homeassistant.core import callback
@ -11,6 +14,8 @@ from homeassistant.core import callback
class ESPHomeScanner(BaseHaRemoteScanner):
"""Scanner for esphome."""
__slots__ = ()
@callback
def async_on_advertisement(self, adv: BluetoothLEAdvertisement) -> None:
"""Call the registered callback."""
@ -34,15 +39,10 @@ class ESPHomeScanner(BaseHaRemoteScanner):
"""Call the registered callback."""
now = MONOTONIC_TIME()
for adv in advertisements:
parsed = parse_advertisement_data((adv.data,))
self._async_on_advertisement(
int_to_bluetooth_address(adv.address),
adv.rssi,
parsed.local_name,
parsed.service_uuids,
parsed.service_data,
parsed.manufacturer_data,
None,
*parse_advertisement_data_tuple((adv.data,)),
{"address_type": adv.address_type},
now,
)

View File

@ -17,7 +17,7 @@
"requirements": [
"async_interrupt==1.1.1",
"aioesphomeapi==15.1.15",
"bluetooth-data-tools==1.7.0",
"bluetooth-data-tools==1.8.0",
"esphome-dashboard-api==1.2.3"
],
"zeroconf": ["_esphomelib._tcp.local."]

View File

@ -20,5 +20,5 @@
"documentation": "https://www.home-assistant.io/integrations/ld2410_ble",
"integration_type": "device",
"iot_class": "local_push",
"requirements": ["bluetooth-data-tools==1.7.0", "ld2410-ble==0.1.1"]
"requirements": ["bluetooth-data-tools==1.8.0", "ld2410-ble==0.1.1"]
}

View File

@ -32,5 +32,5 @@
"dependencies": ["bluetooth_adapters"],
"documentation": "https://www.home-assistant.io/integrations/led_ble",
"iot_class": "local_polling",
"requirements": ["bluetooth-data-tools==1.7.0", "led-ble==1.0.0"]
"requirements": ["bluetooth-data-tools==1.8.0", "led-ble==1.0.0"]
}

View File

@ -12,7 +12,7 @@ bleak-retry-connector==3.1.1
bleak==0.20.2
bluetooth-adapters==0.16.0
bluetooth-auto-recovery==1.2.1
bluetooth-data-tools==1.7.0
bluetooth-data-tools==1.8.0
certifi>=2021.5.30
ciso8601==2.3.0
cryptography==41.0.3

View File

@ -543,7 +543,7 @@ bluetooth-auto-recovery==1.2.1
# homeassistant.components.esphome
# homeassistant.components.ld2410_ble
# homeassistant.components.led_ble
bluetooth-data-tools==1.7.0
bluetooth-data-tools==1.8.0
# homeassistant.components.bond
bond-async==0.2.1

View File

@ -454,7 +454,7 @@ bluetooth-auto-recovery==1.2.1
# homeassistant.components.esphome
# homeassistant.components.ld2410_ble
# homeassistant.components.led_ble
bluetooth-data-tools==1.7.0
bluetooth-data-tools==1.8.0
# homeassistant.components.bond
bond-async==0.2.1