Skip to content

Commit

Permalink
Use bluetooth data tools for address conversion in esphome (home-assi…
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Apr 16, 2023
1 parent ac76a2b commit 4420201
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions homeassistant/components/esphome/bluetooth/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion homeassistant/components/esphome/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."]
}
1 change: 1 addition & 0 deletions requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4420201

Please sign in to comment.