From 108bcabf75cf9e68b76de70f281842be760d6928 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 10 Aug 2023 15:59:37 -1000 Subject: [PATCH] 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 --- homeassistant/components/bluetooth/manifest.json | 2 +- .../components/esphome/bluetooth/scanner.py | 14 +++++++------- homeassistant/components/esphome/manifest.json | 2 +- homeassistant/components/ld2410_ble/manifest.json | 2 +- homeassistant/components/led_ble/manifest.json | 2 +- homeassistant/package_constraints.txt | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/bluetooth/manifest.json b/homeassistant/components/bluetooth/manifest.json index 481a760ba88..b1281af2bc2 100644 --- a/homeassistant/components/bluetooth/manifest.json +++ b/homeassistant/components/bluetooth/manifest.json @@ -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" ] } diff --git a/homeassistant/components/esphome/bluetooth/scanner.py b/homeassistant/components/esphome/bluetooth/scanner.py index 5013a288dcf..a54e7af59a6 100644 --- a/homeassistant/components/esphome/bluetooth/scanner.py +++ b/homeassistant/components/esphome/bluetooth/scanner.py @@ -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, ) diff --git a/homeassistant/components/esphome/manifest.json b/homeassistant/components/esphome/manifest.json index 303e773bbd3..c44c8b3e28d 100644 --- a/homeassistant/components/esphome/manifest.json +++ b/homeassistant/components/esphome/manifest.json @@ -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."] diff --git a/homeassistant/components/ld2410_ble/manifest.json b/homeassistant/components/ld2410_ble/manifest.json index 60d2efe6536..1115a0efc54 100644 --- a/homeassistant/components/ld2410_ble/manifest.json +++ b/homeassistant/components/ld2410_ble/manifest.json @@ -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"] } diff --git a/homeassistant/components/led_ble/manifest.json b/homeassistant/components/led_ble/manifest.json index 9ebbe07703a..ffaf2bf87db 100644 --- a/homeassistant/components/led_ble/manifest.json +++ b/homeassistant/components/led_ble/manifest.json @@ -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"] } diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index f3cfab069f0..282ff1ddb44 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -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 diff --git a/requirements_all.txt b/requirements_all.txt index 7787e0e334f..6b88719a737 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -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 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 341c2371c7a..ddb0cf0f8f5 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -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