Skip to content

Commit 698d3c2

Browse files
authored
fix: account for switching adapter when finding changed_manufacturer_data (#9)
1 parent 85363e5 commit 698d3c2

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Sphinx = {version = "^5.0", optional = true}
3030
sphinx-rtd-theme = {version = "^1.0", optional = true}
3131
myst-parser = {version = "^0.18", optional = true}
3232
sensor-state-data = ">=2.6.0"
33-
bluetooth-sensor-state-data = ">=1.6.0"
33+
bluetooth-sensor-state-data = ">=1.6.1"
3434
bluetooth-data-tools = ">=0.1.2"
3535

3636
[tool.poetry.extras]

src/sensorpro_ble/parser.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ def _start_update(self, service_info: BluetoothServiceInfo) -> None:
3535
if 43605 not in service_info.manufacturer_data:
3636
return
3737
changed_manufacturer_data = self.changed_manufacturer_data(service_info)
38-
if not changed_manufacturer_data:
38+
if not changed_manufacturer_data or len(changed_manufacturer_data) > 1:
39+
# If len(changed_manufacturer_data) > 1 it means we switched
40+
# ble adapters so we do not know which data is the latest
41+
# and we need to wait for the next update.
3942
return
4043
last_id = list(changed_manufacturer_data)[-1]
4144

0 commit comments

Comments
 (0)