Skip to content

Commit

Permalink
fix: update for bleak 0.20 (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Mar 18, 2023
1 parent 420757b commit 1e18be2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/bluetooth_adapters/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def load_history_from_managed_objects(
address = props["Address"]
rssi = props.get("RSSI", MIN_RSSI)

if (prev_history := history.get(address)) and prev_history.device.rssi >= rssi:
if (
prev_history := history.get(address)
) and prev_history.advertisement_data.rssi >= rssi:
continue

split_path = path_str.split("/")
Expand Down
8 changes: 5 additions & 3 deletions src/bluetooth_adapters/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def _serialize_discovered_device_advertisement_datas(
"""Serialize discovered_device_advertisement_datas."""
return {
address: DiscoveredDeviceDict(
device=_ble_device_to_dict(device),
device=_ble_device_to_dict(device, advertisement_data),
advertisement_data=_advertisement_data_to_dict(advertisement_data),
)
for (
Expand Down Expand Up @@ -183,12 +183,14 @@ def _deserialize_discovered_device_advertisement_datas(
}


def _ble_device_to_dict(ble_device: BLEDevice) -> BLEDeviceDict:
def _ble_device_to_dict(
ble_device: BLEDevice, advertisement_data: AdvertisementData
) -> BLEDeviceDict:
"""Serialize ble_device."""
return BLEDeviceDict(
address=ble_device.address,
name=ble_device.name,
rssi=ble_device.rssi,
rssi=advertisement_data.rssi, # For backwards compatibility
details=ble_device.details,
)

Expand Down

0 comments on commit 1e18be2

Please sign in to comment.