Python library for controlling KingSmith WalkingPad treadmills over BLE (FTMS and legacy WiLink protocols)
Project description
walkingpad-controller
Python library for controlling KingSmith WalkingPad treadmills over Bluetooth Low Energy (BLE).
Supports both FTMS (Fitness Machine Service) and legacy WiLink protocols behind a unified API. Protocol is auto-detected based on the BLE device name and advertised services.
Features
- Unified API — single
WalkingPadControllerclass for all device types - Auto protocol detection — FTMS for newer KS-HD-* devices, WiLink for older models
- Real-time status — speed, distance, duration, calories, steps via BLE notifications
- Cold-start handling — waits for belt to start moving and stabilize before sending speed commands, avoiding BLE disconnects on KingSmith devices
- Reconnect recovery — pending target speed is automatically re-applied after BLE reconnection
- KingSmith extensions — step counter via proprietary FTMS extension (bit 13)
Installation
pip install walkingpad-controller
For legacy WiLink device support (older WalkingPad models):
pip install walkingpad-controller[wilink]
Quick Start
import asyncio
from bleak import BleakScanner
from walkingpad_controller import WalkingPadController
async def main():
# Find your treadmill
device = await BleakScanner.find_device_by_name("KS-HD-Z1D")
# Create controller (protocol auto-detected from BLE name)
controller = WalkingPadController(ble_device=device)
# Connect
await controller.connect()
print(f"Protocol: {controller.protocol.value}")
print(f"Speed range: {controller.min_speed}-{controller.max_speed} km/h")
# Start the belt (runs at minimum speed)
await controller.start()
# Set desired speed
await controller.set_speed(3.0)
# Read status
print(f"Speed: {controller.status.speed} km/h")
print(f"Steps: {controller.status.steps}")
# Stop and disconnect
await controller.stop()
await controller.disconnect()
asyncio.run(main())
Status Callbacks
Register callbacks to receive real-time status updates:
from walkingpad_controller import WalkingPadController, TreadmillStatus
def on_status(status: TreadmillStatus):
print(f"Speed: {status.speed} km/h, Distance: {status.distance}m, "
f"Duration: {status.duration}s, Calories: {status.calories}, "
f"Steps: {status.steps}")
controller = WalkingPadController(ble_device=device)
controller.register_status_callback(on_status)
controller.register_disconnect_callback(lambda: print("Disconnected!"))
await controller.connect()
API Reference
WalkingPadController
The main entry point. Auto-detects protocol and delegates to the appropriate backend.
| Property / Method | Description |
|---|---|
protocol |
Detected protocol (ProtocolType.FTMS or ProtocolType.WILINK) |
connected |
Whether the device is currently connected |
status |
Current TreadmillStatus |
min_speed / max_speed |
Speed range in km/h (read from device for FTMS) |
speed_increment |
Speed step size in km/h |
connect() |
Connect and auto-detect protocol |
disconnect() |
Disconnect from the device |
start() |
Start the belt (runs at minimum speed) |
stop() |
Stop the belt |
set_speed(speed_kmh) |
Set speed (starts belt if stopped) |
switch_mode(mode) |
Switch operating mode (WiLink: auto/manual/standby) |
register_status_callback(cb) |
Register a TreadmillStatus callback |
register_disconnect_callback(cb) |
Register a disconnect callback |
update_ble_device(device) |
Update BLE device reference after rediscovery |
update_state() |
Poll / refresh current status from the device |
TreadmillStatus
Dataclass with real-time treadmill data:
| Field | Type | Description |
|---|---|---|
belt_state |
int |
0=stopped, 1=active, 5=standby, 9=starting |
speed |
float |
Current speed in km/h |
mode |
int |
Operating mode (0=auto, 1=manual, 2=standby) |
distance |
int |
Total distance in meters |
duration |
int |
Elapsed time in seconds |
steps |
int |
Step count (FTMS KingSmith extension) |
calories |
int |
Total energy in kcal |
calories_per_hour |
int |
Energy rate |
heart_rate |
int |
Heart rate in bpm (if available) |
timestamp |
float |
Unix timestamp of last update |
Protocol-Specific Controllers
For advanced use, you can use the protocol controllers directly:
FTMSController— FTMS protocol (newer KS-HD-* devices)WiLinkController— Legacy WiLink protocol (older WalkingPad models, requires[wilink]extra)
Supported Devices
FTMS Protocol (tested)
- KingSmith KS-Z1D (BLE name:
KS-HD-Z1D) - Other KingSmith devices with BLE names starting with
KS-HD-
WiLink Protocol (via ph4-walkingpad)
- WalkingPad A1, A1 Pro
- WalkingPad C1, C2
- Other models supported by ph4-walkingpad
Known Behavior
FTMS Cold Start
KingSmith FTMS devices require a START_OR_RESUME command before the belt will accept speed commands. The library handles this automatically: it sends START, waits for the belt to report speed > 0 via treadmill data notifications, then waits an additional stabilization period before sending SET_TARGET_SPEED. This avoids the BLE disconnects that occur when speed commands are sent too early during motor startup.
BLE Connection Drops
KingSmith FTMS devices may occasionally drop the BLE connection after a cold start due to firmware limitations. The library stores the pending target speed and automatically re-applies it after reconnection (with appropriate stabilization delay). When used with the Home Assistant integration's "Stay Connected" mode, this provides seamless recovery.
Connection Exclusivity
Only one BLE client can connect to the treadmill at a time. If Home Assistant holds the connection, the KS Fit app cannot connect, and vice versa.
Requirements
- Python 3.10+
- bleak >= 0.20.0
- ph4-walkingpad >= 1.0.0 (optional, for WiLink devices)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file walkingpad_controller-0.4.0.tar.gz.
File metadata
- Download URL: walkingpad_controller-0.4.0.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b8613c4189ed798af97a7e885c9b5dba66a32b41ab58ed1577b133cfac3e979
|
|
| MD5 |
e9f96ad2532374ba359d8bb0275504fc
|
|
| BLAKE2b-256 |
331f27c14fffa088284b98a6bfc8b07909c7088c54860a237678b080a3a9a248
|
Provenance
The following attestation bundles were made for walkingpad_controller-0.4.0.tar.gz:
Publisher:
publish.yml on mcdax/walkingpad-controller
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
walkingpad_controller-0.4.0.tar.gz -
Subject digest:
1b8613c4189ed798af97a7e885c9b5dba66a32b41ab58ed1577b133cfac3e979 - Sigstore transparency entry: 1144712578
- Sigstore integration time:
-
Permalink:
mcdax/walkingpad-controller@2c4cd520609ae4356bff721c1183978be392c968 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/mcdax
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2c4cd520609ae4356bff721c1183978be392c968 -
Trigger Event:
release
-
Statement type:
File details
Details for the file walkingpad_controller-0.4.0-py3-none-any.whl.
File metadata
- Download URL: walkingpad_controller-0.4.0-py3-none-any.whl
- Upload date:
- Size: 19.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d37d393223911d7d9723a244aa11c33669773bbca9ef07723dde388a047a9fc9
|
|
| MD5 |
17b948b50d957a873adc3b18978afb49
|
|
| BLAKE2b-256 |
bcadb8ccedb623d6f883d6646762f0355455ebaa8a9b12edde739c1bbe1b7457
|
Provenance
The following attestation bundles were made for walkingpad_controller-0.4.0-py3-none-any.whl:
Publisher:
publish.yml on mcdax/walkingpad-controller
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
walkingpad_controller-0.4.0-py3-none-any.whl -
Subject digest:
d37d393223911d7d9723a244aa11c33669773bbca9ef07723dde388a047a9fc9 - Sigstore transparency entry: 1144712711
- Sigstore integration time:
-
Permalink:
mcdax/walkingpad-controller@2c4cd520609ae4356bff721c1183978be392c968 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/mcdax
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2c4cd520609ae4356bff721c1183978be392c968 -
Trigger Event:
release
-
Statement type: