| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
This PR adds a GATT-based fallback to FTMS discovery so devices that advertise the FTMS service but omit machine type service data can still be identified.
Changes:
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/pyftms/client/properties/machine_type.py | Adds GATT characteristic-based machine type detection. |
| src/pyftms/client/properties/__init__.py | Re-exports the new GATT detection helper. |
| src/pyftms/client/__init__.py | Adds discovery fallback logic that connects to devices lacking machine type service data. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
| except (BleakError, NotFitnessMachineError, OSError): | ||
| _LOGGER.debug( | ||
| "Could not determine machine type for '%s' " | ||
| "via GATT fallback.", | ||
| dev.address, | ||
| ) | ||
| continue |
| except NotFitnessMachineError: | ||
| continue | ||
| # The device advertises the FTMS service UUID but does | ||
| # not include machine type in its service data (e.g. | ||
| # Bodytone DU30). Fall back to GATT characteristic | ||
| # inspection by briefly connecting to the device. | ||
| try: |
| try: | ||
| async with BleakClient( | ||
| dev, services=[FTMS_UUID] | ||
| ) as cli: |
| # advertise the FTMS UUID in service_uuids but provide no service data, so | ||
| # they would be silently dropped. We therefore scan for all BLE devices | ||
| # and filter manually. | ||
| async with BleakScanner(**kwargs) as scanner: |
|
Discovery result: (.venv) homeserver:~/python-pyftms$ python -m pyftms
Scanning for available FTMS devices...
1. INDOOR_BIKE: name: DU30-B1D8, address: 24:00:0C:A0:3B:98
Connection to INDOOR_BIKE: name: DU30-B1D8, address: 24:00:0C:A0:3B:98
1. Device Info: {}
2. Supported settings: ['target_resistance', 'target_power']
3. Supported ranges: {'target_resistance': SettingRange(min_value=0, max_value=32.0, step=1.0), 'target_power': SettingRange(min_value=0, max_value=999, step=1)}
4. Supported properties: ['speed_instant', 'speed_average', 'cadence_instant', 'cadence_average', 'distance_total', 'resistance_level', 'power_instant', 'power_average', 'energy_total', 'energy_per_hour', 'energy_per_minute', 'heart_rate', 'time_elapsed', 'training_status']
5. Available properties: ['speed_instant', 'speed_average', 'cadence_instant', 'cadence_average', 'distance_total', 'resistance_level', 'power_instant', 'power_average', 'energy_total', 'energy_per_hour', 'energy_per_minute', 'heart_rate', 'metabolic_equivalent', 'time_elapsed', 'time_remaining', 'training_status']
Done.
|
Sorry, something went wrong.
A D-Bus disconnect event can fire before self._cli is assigned during connection setup (bleak_retry_connector registers the disconnect callback before establish_connection returns). This causes an AttributeError when _on_disconnect calls del self._cli on a fresh IndoorBike instance. Fix: check with hasattr before deleting _cli.
|
Hi @netsoft-ruidias, thank you for the Bodytone DU30-B1D8 work and for sharing the successful discovery output. I ported the GATT data-characteristic machine type detection idea from #67 into my pyftms fork on top of the UUID-only advertisement fallback and post-connect type correction work I already had there. See #70. There is also a drop-in HACS repo for the hassio-ftms fork, using the pyftms fork. The fork now exposes a reusable get_machine_type_from_gatt(...) helper, uses it during the existing post-connect probe, and keeps discovery from opening GATT connections inside the advertisement loop. That also addresses the Copilot review notes about per-device discovery blocking/retries and keeps the scanner UUID filter behavior intact. The _cli disconnect guard and Python 3.14 support were already present in the fork, so those pieces are included there as well. Would you mind trying the latest fork build with your Bodytone bike when you have a chance? The tag is v0.4.15+mw.6, and I’d really appreciate confirmation that it still discovers and connects cleanly to your DU30. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This pull request improves the ability of the FTMS device discovery process to correctly identify machine types, especially for devices that do not advertise their type in service data. The main enhancement is a fallback mechanism that inspects GATT characteristics if the machine type cannot be determined from advertisement data. Additionally, the new utility function for GATT-based type detection has been added and exported for broader use.
Enhancements to FTMS device discovery:
New utility for machine type detection:
Dependency and import updates: