From 8f905a4000b5632b6a3971463775bacbeeed624d Mon Sep 17 00:00:00 2001 From: Ashley Gittins Date: Fri, 15 Nov 2024 04:52:34 +1100 Subject: [PATCH] fix: Local USB Bluetooth detection (#387) fixes #386 * fix: Local USB Bluetooth detection - fixes Failed to find Scanner (local USB Bluetooth) #386 - linting * - linting --- custom_components/bermuda/coordinator.py | 4 ++-- custom_components/bermuda/entity.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/custom_components/bermuda/coordinator.py b/custom_components/bermuda/coordinator.py index 1a774ab..eb3f8f7 100644 --- a/custom_components/bermuda/coordinator.py +++ b/custom_components/bermuda/coordinator.py @@ -153,7 +153,7 @@ def __init__( self._manager: HomeAssistantBluetoothManager = _get_manager(hass) # instance of the bluetooth manager self._hascanners: set[BaseHaScanner] # Links to the backend scanners - self._hascanner_timestamps: dict[str, dict[str, float]] = {} # scanner_address, device_address, stamp + self._hascanner_timestamps: dict[str, dict[str, float]] = {} # scanner_address, device_address, stamp self._entity_registry = er.async_get(self.hass) self._device_registry = dr.async_get(self.hass) @@ -1121,7 +1121,7 @@ def _refresh_scanners(self, scanners: list[BluetoothScannerDevice] | None = None scanner_devreg = self._device_registry.async_get_device( connections={ ("mac", scanner_address), # Matches ESPHome proxies, Shellys etc - ("bluetooth", scanner_address), # Matches local USB Bluetooth (hci0..) + ("bluetooth", scanner_address.upper()), # Matches local USB Bluetooth (hci0..) } ) if scanner_devreg is None: diff --git a/custom_components/bermuda/entity.py b/custom_components/bermuda/entity.py index 42558b6..80b2918 100644 --- a/custom_components/bermuda/entity.py +++ b/custom_components/bermuda/entity.py @@ -184,7 +184,7 @@ def _handle_coordinator_update(self) -> None: """ self.async_write_ha_state() - def _cached_ratelimit(self, statevalue: Any, interval:int|None=None): + def _cached_ratelimit(self, statevalue: Any, interval: int | None = None): """A simple way to rate-limit sensor updates.""" if interval is not None: self._cache_ratelimit_interval = interval