Skip to main content

tenways-ble

Small experimental Python library and CLI for local BLE access to TENWAYS e-bikes. It powers the Home Assistant integration ha-tenways.

  • discovers nearby TENWAYS BLE devices;
  • decodes the proprietary King Meter frame protocol (CRC-16/MODBUS, TLV fields) used by the TENWAYS Longtail Duo and, untested, other King Meter models (see Supported bikes);
  • reads live telemetry: traction battery, odometer, trip, max/average speed, ride time, light, remaining range;
  • reads firmware and serial number;
  • reads the standard Bluetooth Battery Level characteristic (0x2A19), which is not the traction battery;
  • writes only frames the TENWAYS app also writes, and only when called: the clock sync set_clock() and clearing the trip reset_trip(). No lock, light or configuration commands. The app sends the clock only to AGOX, AGOT, CARGO and the Longtail Duo; on other models set_clock() is untested.

The protocol was reconstructed from an Android HCI capture of the official TENWAYS app; all test vectors are the original captured frames. Tested on a Longtail Duo, including both writes; current speed and power are not yet confirmed while riding.

Installation

pip install tenways-ble

Python 3.11 or newer and bleak. On Linux, BlueZ and a working Bluetooth adapter are required.

Library usage

import asyncio
from tenways_ble import TenwaysBike

async def main():
    async with TenwaysBike("E8:88:6C:31:B3:0D") as bike:
        status = await bike.read_status()
        print(status.battery_percent, status.odometer_km)

asyncio.run(main())

TenwaysBike also accepts an already connected BleakClient (for example from bleak-retry-connector in Home Assistant). It then only speaks the protocol and leaves the connection to the caller.

The sans-I/O protocol module tenways_ble.protocol builds and parses frames without any Bluetooth dependency.

Both writes wait for an acknowledgement that carries the written key; pass wait_for_reply=False to only send.

CLI

tenways scan                            # likely TENWAYS devices nearby
tenways status E8:88:6C:31:B3:0D        # live telemetry (traction battery, odometer, …)
tenways device-info E8:88:6C:31:B3:0D   # firmware and serial number
tenways battery E8:88:6C:31:B3:0D       # standard BLE battery (not the traction battery)
tenways info E8:88:6C:31:B3:0D          # basic GATT information and battery level
tenways listen E8:88:6C:31:B3:0D        # proprietary notifications, stop with Ctrl+C

Supported bikes

The library picks a profile from the advertised name, matched like the TENWAYS app picks its driver (TenwaysBike(client, name=...), CLI --model). Without a name it assumes a Longtail Duo; an unknown name gets the app's default driver (ago).

Advertised name App driver Status Notes
Longtail Duo long tail duo/CGO009_D tested all reads, set_clock(), reset_trip()
CGO009_D long tail duo/CGO009_D untested same requests as the Duo; written with response like the app; the app sends it no clock
CGO009 (not CGO009L) 009 untested asks for assist level 0x12 too (raw_12); the app sends it no clock
CGO800, CGO800 Plus, CGO800S 800s untested CRC low byte first, odometer in whole km, firmware as text; some CGO800 Plus displays need the encrypted session (not supported); the app sends it no clock
AGO, AGOX, AGOT, CARGO, CGO009L, other names ago (the app's default) untested same status fields as the Duo, serial number from key 0x05; the app sends the clock to AGOX, AGOT and CARGO only
AGO AIR, Wayfarer_B, AGOX_D, AGOT_D, CGO COMPACT_D, AGO AIR-BELT_D AGO AIR not supported encrypted King Meter session (0xD8/0xD2 handshake)
CGO600_D CGO600_D not supported 0x57 frames, not King Meter
CGO600, CGO600 Pro, CGO600 PLUS Nordic UART not supported not King Meter
DM… DM not supported separate driver, not analysed

"Untested" means the requests follow the app, but no such bike has answered this library yet. Not supported models raise TenwaysUnsupportedError and nothing is sent. With a debug log of your bike (or, for the unsupported ones, an HCI capture of the TENWAYS app; never publish it raw) they can be added: please open an issue. Details: driver per model.

Safety

tenways-ble never writes arbitrary data to the proprietary TENWAYS write characteristic; the only writes are the explicit clock sync and clear trip, both taken from the TENWAYS app. Reverse engineering should start from observed traffic rather than guessed commands.

Never publish a raw phone HCI log; it contains traffic and identifiers of other devices.

Documentation

  • Devices and King Meter protocol: GATT layout, frame format, every key and both writes, with what is confirmed on the bike.
  • Research notes: findings from the app's code, read and write keys per model, tests on the Duo, open fields, capture procedure.
  • Development: development install, HCI trace on Linux, releasing.

License

MIT

Acknowledgements / Credits

Based on and inspired by stein155/cgo600-bridge, which provided valuable groundwork for understanding the proprietary TENWAYS telemetry protocol and its integration with Home Assistant.

Many thanks to the original author and contributors.

The Longtail Duo implementation was developed using independently captured Bluetooth HCI traffic from the official TENWAYS app. It uses the King Meter BLE transport rather than the Nordic UART Service used by the CGO600 bridge.

Metadata

Release files for tenways-ble 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tenways-ble 0.6.0
File Size Uploaded Provenance Actions
tenways_ble-0.6.0.tar.gz 180.1 kB With provenance Details for tenways_ble-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tenways-ble 0.6.0
File Interpreter ABI Platform Actions
tenways_ble-0.6.0-py3-none-any.whl Python 3 none any Details for tenways_ble-0.6.0-py3-none-any.whl

Total release size: 199.4 kB

Release files / tenways_ble-0.6.0.tar.gz

Download URL tenways_ble-0.6.0.tar.gz
Size 180.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3e4f1404e11c0e8b626747306d150ae8579b4baf12cbf49241b0b39bd9423c5a
BLAKE2b-256 checksum
How to use checksums
884944eef7a825a53708789696d5553e80cd48fe92e514bf3bd45e1541dca7e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Release files / tenways_ble-0.6.0-py3-none-any.whl

Download URL tenways_ble-0.6.0-py3-none-any.whl
Size 19.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57882f10842a570e6f332072a4d3c0241a4c47f81a983d311ef14315a3ee2f65
BLAKE2b-256 checksum
How to use checksums
aa4a4d8ff21218e1182aee63649bfa82d644a6cecd33205d15217fefb2c56119
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Security for tenways-ble 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for tenways_ble-0.6.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page