mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
Use bluetooth data tools for address conversion in esphome (#91443)
This commit is contained in:
parent
ac76a2b1df
commit
4420201fe6
@ -2,6 +2,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from aioesphomeapi import BluetoothLEAdvertisement
|
from aioesphomeapi import BluetoothLEAdvertisement
|
||||||
|
from bluetooth_data_tools import int_to_bluetooth_address
|
||||||
|
|
||||||
from homeassistant.components.bluetooth import BaseHaRemoteScanner
|
from homeassistant.components.bluetooth import BaseHaRemoteScanner
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
@ -14,9 +15,8 @@ class ESPHomeScanner(BaseHaRemoteScanner):
|
|||||||
def async_on_advertisement(self, adv: BluetoothLEAdvertisement) -> None:
|
def async_on_advertisement(self, adv: BluetoothLEAdvertisement) -> None:
|
||||||
"""Call the registered callback."""
|
"""Call the registered callback."""
|
||||||
# The mac address is a uint64, but we need a string
|
# The mac address is a uint64, but we need a string
|
||||||
mac_hex = f"{adv.address:012X}"
|
|
||||||
self._async_on_advertisement(
|
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.rssi,
|
||||||
adv.name,
|
adv.name,
|
||||||
adv.service_uuids,
|
adv.service_uuids,
|
||||||
|
@ -14,6 +14,10 @@
|
|||||||
"integration_type": "device",
|
"integration_type": "device",
|
||||||
"iot_class": "local_push",
|
"iot_class": "local_push",
|
||||||
"loggers": ["aioesphomeapi", "noiseprotocol"],
|
"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."]
|
"zeroconf": ["_esphomelib._tcp.local."]
|
||||||
}
|
}
|
||||||
|
@ -465,6 +465,7 @@ bluetooth-adapters==0.15.3
|
|||||||
bluetooth-auto-recovery==1.0.3
|
bluetooth-auto-recovery==1.0.3
|
||||||
|
|
||||||
# homeassistant.components.bluetooth
|
# homeassistant.components.bluetooth
|
||||||
|
# homeassistant.components.esphome
|
||||||
# homeassistant.components.ld2410_ble
|
# homeassistant.components.ld2410_ble
|
||||||
# homeassistant.components.led_ble
|
# homeassistant.components.led_ble
|
||||||
bluetooth-data-tools==0.4.0
|
bluetooth-data-tools==0.4.0
|
||||||
|
@ -385,6 +385,7 @@ bluetooth-adapters==0.15.3
|
|||||||
bluetooth-auto-recovery==1.0.3
|
bluetooth-auto-recovery==1.0.3
|
||||||
|
|
||||||
# homeassistant.components.bluetooth
|
# homeassistant.components.bluetooth
|
||||||
|
# homeassistant.components.esphome
|
||||||
# homeassistant.components.ld2410_ble
|
# homeassistant.components.ld2410_ble
|
||||||
# homeassistant.components.led_ble
|
# homeassistant.components.led_ble
|
||||||
bluetooth-data-tools==0.4.0
|
bluetooth-data-tools==0.4.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user