Skip to content

Commit

Permalink
fix: account for switching adapter when finding changed_manufacturer_…
Browse files Browse the repository at this point in the history
…data (#8)
  • Loading branch information
bdraco authored Feb 7, 2023
1 parent 964edbb commit 18a949b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ python = "^3.9"
Sphinx = {version = "^5.0", optional = true}
sphinx-rtd-theme = {version = "^1.0", optional = true}
myst-parser = {version = "^0.18", optional = true}
bluetooth-sensor-state-data = ">=1.6.0"
bluetooth-sensor-state-data = ">=1.6.1"
sensor-state-data = ">=2.3.1"
bluetooth-data-tools = ">=0.1.2"

Expand Down
5 changes: 4 additions & 1 deletion src/thermopro_ble/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ def _start_update(self, service_info: BluetoothServiceInfo) -> None:
self.set_device_manufacturer("ThermoPro")
changed_manufacturer_data = self.changed_manufacturer_data(service_info)

if not changed_manufacturer_data:
if not changed_manufacturer_data or len(changed_manufacturer_data) > 1:
# If len(changed_manufacturer_data) > 1 it means we switched
# ble adapters so we do not know which data is the latest
# and we need to wait for the next update.
return

last_id = list(changed_manufacturer_data)[-1]
Expand Down

0 comments on commit 18a949b

Please sign in to comment.