Use bluetooth data tools for address conversion in esphome (#91443)

This commit is contained in:
J. Nick Koston 2023-04-16 11:55:08 -10:00 committed by GitHub
parent ac76a2b1df
commit 4420201fe6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 3 deletions

View File

@ -2,6 +2,7 @@
from __future__ import annotations
from aioesphomeapi import BluetoothLEAdvertisement
from bluetooth_data_tools import int_to_bluetooth_address
from homeassistant.components.bluetooth import BaseHaRemoteScanner
from homeassistant.core import callback
@ -14,9 +15,8 @@ class ESPHomeScanner(BaseHaRemoteScanner):
def async_on_advertisement(self, adv: BluetoothLEAdvertisement) -> None:
"""Call the registered callback."""
# The mac address is a uint64, but we need a string
mac_hex = f"{adv.address:012X}"
self._async_on_advertisement(
f"{mac_hex[0:2]}:{mac_hex[2:4]}:{mac_hex[4:6]}:{mac_hex[6:8]}:{mac_hex[8:10]}:{mac_hex[10:12]}",
int_to_bluetooth_address(adv.address),
adv.rssi,
adv.name,
adv.service_uuids,

View File

@ -14,6 +14,10 @@
"integration_type": "device",
"iot_class": "local_push",
"loggers": ["aioesphomeapi", "noiseprotocol"],
"requirements": ["aioesphomeapi==13.7.0", "esphome-dashboard-api==1.2.3"],
"requirements": [
"aioesphomeapi==13.7.0",
"bluetooth-data-tools==0.4.0",
"esphome-dashboard-api==1.2.3"
],
"zeroconf": ["_esphomelib._tcp.local."]
}

View File

@ -465,6 +465,7 @@ bluetooth-adapters==0.15.3
bluetooth-auto-recovery==1.0.3
# homeassistant.components.bluetooth
# homeassistant.components.esphome
# homeassistant.components.ld2410_ble
# homeassistant.components.led_ble
bluetooth-data-tools==0.4.0

View File

@ -385,6 +385,7 @@ bluetooth-adapters==0.15.3
bluetooth-auto-recovery==1.0.3
# homeassistant.components.bluetooth
# homeassistant.components.esphome
# homeassistant.components.ld2410_ble
# homeassistant.components.led_ble
bluetooth-data-tools==0.4.0