Skip to content

Commit

Permalink
fix: compat with upcoming bleak (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Oct 1, 2022
1 parent 6d2153c commit 61fcdbf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/bluetooth_adapters/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from bleak.backends.device import BLEDevice
from bleak.backends.scanner import AdvertisementData

MIN_RSSI = -127


@dataclass
class AdvertisementHistory:
Expand All @@ -27,7 +29,7 @@ def load_history_from_managed_objects(
continue

address = props["Address"]
rssi = props.get("RSSI", 0)
rssi = props.get("RSSI", MIN_RSSI)

if (prev_history := history.get(address)) and prev_history.device.rssi >= rssi:
continue
Expand All @@ -53,6 +55,7 @@ def load_history_from_managed_objects(
service_uuids=uuids,
platform_data=props,
tx_power=props.get("TxPower"),
rssi=rssi,
)
history[device.address] = AdvertisementHistory(
device, advertisement_data, adapter
Expand Down

0 comments on commit 61fcdbf

Please sign in to comment.