From fc11d34a51d980227c4cb4bb6a6117e66a633879 Mon Sep 17 00:00:00 2001 From: Koen Vervloesem Date: Mon, 20 Mar 2023 18:46:59 +0100 Subject: [PATCH] Replace deprecated BLEDevice.rssi by AdvertisementData.rssi (#114) Bleak 0.20.0 deprecates BLEDevice.rssi. This PR replaces this attribute by AdvertisementData.rssi, introduced in Bleak 0.19.0. This also bumps the minimal Bleak version required by Theengs Gateway to 0.19.0. --- TheengsGateway/ble_gateway.py | 6 ++---- setup.py | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/TheengsGateway/ble_gateway.py b/TheengsGateway/ble_gateway.py index ba94df54..c030b7ae 100644 --- a/TheengsGateway/ble_gateway.py +++ b/TheengsGateway/ble_gateway.py @@ -289,9 +289,7 @@ async def ble_scan_loop(self): def detection_callback(self, device, advertisement_data): """Detect device in received advertisement data.""" - logger.debug( - "%s RSSI:%d %s", device.address, device.rssi, advertisement_data - ) + logger.debug("%s:%s", device.address, advertisement_data) # Try to add the device to dictionary of clocks to synchronize time. self.add_clock(device.address) @@ -319,7 +317,7 @@ def detection_callback(self, device, advertisement_data): if data_json: data_json["id"] = device.address - data_json["rssi"] = device.rssi + data_json["rssi"] = advertisement_data.rssi decoded_json = decodeBLE(json.dumps(data_json)) if decoded_json: diff --git a/setup.py b/setup.py index 5e67f5c0..90496228 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ setup_requires=setup_requires, include_package_data=True, install_requires=[ - "bleak>=0.15.0", + "bleak>=0.19.0", "bluetooth-clocks<1.0", "bluetooth-numbers>=1.0,<2.0", "paho-mqtt>=1.6.1",