Repository navigation
Add Laifen integration - #194907
Add Laifen integration#194907bzumik1 wants to merge 7 commits into
Conversation
|
👋 Hi! Thanks for contributing to Home Assistant. This is your PR dashboard which flags anything you need to address before your PR can be reviewed. Once everything is green, you can press the 'Ready for review' button at the bottom of the page to notify reviewers to take a look. More information about this dashboardThis dashboard automatically updates on every change to this PR and reevaluates the rules as you go. Until everything has been addressed, the bot will keep the PR in draft. Skip a check that doesn't applyIf you think a check doesn't apply to your PR (or the rule is bugged), comment Bot commandsReply with
Checks✨ Everything's in order! 8 checks passed (3 skipped)
|
There was a problem hiding this comment.
🟡 Changes recommended
After a polling failure, valid toothbrush push updates leave last_update_success false, keeping both sensors unavailable; the recovery path needs a fix and regression test.
1 open issue
What changed in this PR
Adds Bluetooth LE support for the Laifen Wave toothbrush (LFTB01-P), with discovery, connection validation, and sensors that retain their last values while the device sleeps.
Changes:
- Adds Bluetooth discovery and user setup flows.
- Manages wake-up connections, pushed updates, and periodic battery reads.
- Adds battery and brushing-duration sensors, tests, and integration registration.
| File | Description |
|---|---|
tests/components/laifen/test_sensor.py |
Tests sensor updates, restoration, and availability. |
tests/components/laifen/test_init.py |
Tests connection lifecycle, polling, and shutdown. |
tests/components/laifen/test_config_flow.py |
Tests discovery and user setup flows. |
tests/components/laifen/snapshots/test_sensor.ambr |
Captures sensor state and registry snapshots. |
tests/components/laifen/conftest.py |
Provides shared toothbrush mocks and fixtures. |
tests/components/laifen/__init__.py |
Adds setup and advertisement test helpers. |
requirements_all.txt |
Pins the laifen-ble dependency. |
mypy.ini |
Enables strict typing checks for Laifen. |
homeassistant/generated/integrations.json |
Registers integration metadata. |
homeassistant/generated/config_flows.py |
Registers the configuration flow. |
homeassistant/generated/bluetooth.py |
Adds the Bluetooth discovery matcher. |
homeassistant/components/laifen/strings.json |
Defines setup messages and sensor translations. |
homeassistant/components/laifen/sensor.py |
Implements battery and brushing-duration sensors. |
homeassistant/components/laifen/quality_scale.yaml |
Records quality-scale implementation status. |
homeassistant/components/laifen/manifest.json |
Declares metadata, discovery, and dependencies. |
homeassistant/components/laifen/icons.json |
Defines the brushing-duration icon. |
homeassistant/components/laifen/entity.py |
Provides shared entity identity and device linkage. |
homeassistant/components/laifen/coordinator.py |
Handles connections, notifications, and polling. |
homeassistant/components/laifen/const.py |
Defines the integration domain. |
homeassistant/components/laifen/config_flow.py |
Implements discovery and user configuration. |
homeassistant/components/laifen/__init__.py |
Sets up devices, sensors, and lifecycle cleanup. |
CODEOWNERS |
Assigns integration and test ownership. |
.strict-typing |
Includes Laifen in strict typing coverage. |
Review effort: Balanced (adaptive)
Notify the listeners with async_set_updated_data, so a pushed state marks the update as successful again after an unexpected error.
There was a problem hiding this comment.
🔵 Needs a closer look
Tests mock laifen-ble’s cleanup and callback contracts, leaving the unavailable pinned implementation’s failure handling, reconnect behavior, and BLE proxy lifecycle unverified.
No open issues 🎉
1 resolved since last review
Review effort: Balanced (adaptive)
There was a problem hiding this comment.
🔵 Needs a closer look
The sleepy-device lifecycle needs human validation because laifen-ble 0.3.10 callback and connection-cleanup guarantees could not be verified without its source or a device/proxy runtime.
No open issues 🎉
Review effort: Balanced (adaptive)
There was a problem hiding this comment.
🔵 Needs a closer look
The unavailable laifen-ble 0.4.0 implementation leaves connection, notification, and cleanup contracts unverified, and mocked tests cannot establish the required hardware lifecycle guarantees.
No open issues 🎉
Review effort: Balanced (adaptive)
There was a problem hiding this comment.
🔵 Needs a closer look
BLE cleanup and reconnect guarantees depend on unavailable laifen-ble source and unverified hardware behavior, while documentation, assets, coverage, and quality-scale checks also require verification.
No open issues 🎉
Review effort: Balanced (adaptive)
Check requirementsChecked at commit All requirements checks passed. ✅
📦 laifen-ble: 0.4.0
|
Check requirementsChecked at commit
📦 laifen-ble: 0.4.1
|

Proposed change
This adds the Laifen integration for the Laifen Wave (
LFTB01-P) electric toothbrush, which is reached over Bluetooth LE.The toothbrush is a sleepy device. It only advertises while it is awake (after a button press, or while it sits on its charger), and its advertisements never change. The integration connects when it advertises and keeps the connection while the toothbrush is awake. It clears the advertisement history at setup and after every disconnect, as
async_clear_advertisement_historydescribes, so the next identical wake-up is heard. The toothbrush pushes its state over the connection, but not battery changes, so the state is read every minute while it stays connected on its charger.This first PR adds the config flow (Bluetooth discovery and a user step, both test the connection) and the sensor platform: battery, current brushing duration and last brushing duration. The current brushing duration is updated every second while the toothbrush brushes. The battery and last brushing duration sensors keep their last value while the toothbrush sleeps. The event, select, number and switch platforms and diagnostics will follow in separate PRs.
The communication is in the laifen-ble library (MIT), published from GitHub Actions with trusted publishing: release workflow, tag 0.4.1. Its protocol is based on marc-alexis-com/laifen-toolbox. I tested the integration on a real
LFTB01-Pwith firmware V2.0.93, through ESPHome Bluetooth proxies and the local adapter.Why core: Laifen Wave owners already use Home Assistant through the UrbanTechIO/Laifen custom integration (25 stars, 10 issues and 5 pull requests since January 2025). I contacted its author about a core integration in UrbanTechIO/Laifen#15, but there is no reply yet. I run this integration as a custom integration on my own Home Assistant since 26 November 2026, and the protocol is documented independently in laifen-toolbox. In core, Laifen Wave owners get Bluetooth discovery and a maintained integration without installing a custom one.
Brand images: home-assistant/brands#11474
Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: