laifen-ble
Async Bluetooth LE library for the Laifen Wave electric toothbrush (LFTB01-P).
It reads the toothbrush state (active mode, per-mode settings, battery level, brushing time,
running state and feature flags), tracks brushing sessions, and controls the toothbrush: mode and
per-mode strength, range and speed, brushing time, 30-second reminder, high frequency, and
starting or stopping the motor. It reads the firmware version when its format is known. It is
built on bleak and
bleak-retry-connector and is
intended to be used by the Home Assistant laifen integration.
Supported devices
| Model | Advertised name | Status |
|---|---|---|
| Laifen Wave (tested with firmware V2.0.93) | LFTB01-P-xxxx |
Supported |
| Other Laifen models | other names | Not supported |
Usage
import asyncio
from bleak import BleakScanner
from laifen_ble import LaifenToothbrush, Mode, is_supported
async def main() -> None:
device = await BleakScanner.find_device_by_filter(
lambda device, advertisement: is_supported(advertisement.local_name)
)
toothbrush = LaifenToothbrush(device)
toothbrush.register_callback(lambda: print(toothbrush.state))
await toothbrush.connect()
await toothbrush.set_mode(Mode.MODE_2)
await toothbrush.set_brushing_time(150)
await asyncio.sleep(30)
print(toothbrush.last_session)
await toothbrush.disconnect()
asyncio.run(main())
The toothbrush only advertises while it is awake (after a button press) and disconnects on its
own about a minute after the last activity. While connected it pushes its state on every change,
so registered callbacks are called whenever the state, the firmware version or the connection
changes. Every command waits for the acknowledgement of the toothbrush and reads the state back.
The battery level is not pushed, so call update() to read the state again, for example while
the toothbrush stays awake on its charger.
state.battery_level is None when the toothbrush reports a value above 100. After a
disconnect, state keeps the last state received, so check connected before relying on it.
A brushing session is a period in which the motor runs for at least five seconds; the short
vibrations that confirm button presses are ignored. last_session holds the start time and
duration of the last completed session. current_session holds the session in progress, with its
duration up to now, once the motor has run for five seconds. Read it again to follow the duration,
because the toothbrush does not push it. Sessions are measured while the toothbrush is connected:
- A session that was already running when the toothbrush was connected starts at the moment of the connection.
- When the connection drops while the motor runs and the toothbrush is connected again within a minute while it still runs, the session continues. If it would then last more than a few seconds longer than the longest brushing time, the toothbrush must have been stopped and started again in between, and the session starts at the moment of the latest connection.
- When the toothbrush is connected again later, only the rest of the session is recorded. When it has stopped by then, the interrupted session is not recorded.
Errors
LaifenConnectionError: the toothbrush could not be reached, the connection dropped, or it did not answer in time.UnsupportedStateError: raised byconnect()when the toothbrush reports its state in a layout this library does not know.LaifenValueError: a value is outside what the toothbrush accepts in its current state.LaifenCommandError: the toothbrush refused a command.LaifenMotorError.reasontells why it refused to start or stop the motor, for example because it is charging.
All of them derive from LaifenError.
Protocol
The protocol was documented by marc-alexis-com/laifen-toolbox and earlier explored by UrbanTechIO/Laifen. This library only sends commands that were confirmed on a real toothbrush. Airplane mode, head calibration, factory reset, emergency shutdown and reading the brushing history are intentionally not implemented.
Development
python -m venv .venv
. .venv/bin/activate
pip install -e '.[test,lint]'
pytest
ruff check . && ruff format --check . && mypy src tests
License
MIT
Metadata
Release files for laifen-ble 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| laifen_ble-0.4.0.tar.gz | 17.6 kB | With provenance | Details for laifen_ble-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| laifen_ble-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for laifen_ble-0.4.0-py3-none-any.whl |
Total release size: 29.8 kB
Release files / laifen_ble-0.4.0.tar.gz
| Download URL | laifen_ble-0.4.0.tar.gz |
|---|---|
| Size | 17.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c8e4fb0aff876fdb9bff4ec6b43a73a656d3ebee4683c6b38f3aa8d868130dda
|
|
BLAKE2b-256 checksum How to use checksums |
914524bc519424f244c453f78b4b83fed2a0baf7e56b792005914e4a16e3c830
|
| 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 27, 2026.
Transparency logRelease files / laifen_ble-0.4.0-py3-none-any.whl
| Download URL | laifen_ble-0.4.0-py3-none-any.whl |
|---|---|
| Size | 12.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
575f5bf5712c827ef7ec0c77a268793671345ba3331c17dc576a9a90ccb15f01
|
|
BLAKE2b-256 checksum How to use checksums |
e4b8a019de13a07a11d16f1af451d352255a034ab674d3246e0e556e760222d4
|
| 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 27, 2026.
Transparency logSecurity for laifen-ble 0.4.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.
Attestation for laifen_ble-0.4.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 27, 2026.
Transparency logA 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.