kettle
Control your Xiaomi Smart Kettle 2 Pro from the Terminal: boil, heat to a temperature, keep warm for up to 24 hours, check the state or stop it. Everything runs over your own Wi-Fi, directly to the kettle - no Xiaomi Home app and no cloud connection when you use it.
$ kettle warm 80 --keep 2
warm to 80 C and keep warm at 80 C for 2 h: water at 41 C, idle, no fault.
About to send set_properties:
(2,4) = 80
...
Start heating? [y/N] y
status: heating, 41 C, fault OK (0)
Written for the EU model (BHR9107EU, xiaomi.kettle.v20, 1.7 L, 1800 W), tested on firmware 2.2.7_0016.
It has no dependencies except Python itself. This is the standalone tool and a documented protocol reference (SPEC.md)
made just for fun... or not. Setting a kettle right from the Terminal while working is pretty neat, actually :)
Features
| Command | What it does |
|---|---|
kettle setup |
Guided first-time setup: asks for the token, finds the kettle, checks and saves it. |
kettle boil |
Heats to boiling (99 °C, the kettle's boil mode), then stops. |
kettle warm <40-99> |
Heats to that temperature in °C, then stops. |
kettle cancel (or stop) |
Stops heating / keep-warm. |
kettle status |
State, current temperature, target, fault, keep-warm settings. |
kettle shell |
Interactive session with the same commands. |
kettle info |
Model, firmware and MAC from the kettle. |
kettle find |
Finds the kettle on the network again if its IP changed. |
Call options
Go right after kettle, before the command.
| Option | What it does |
|---|---|
--ip <address> |
Kettle IP address (default: the one saved by kettle setup). |
--token <32 hex> |
Kettle token (default: the saved one). |
--force-model |
Send commands even to a model other than xiaomi.kettle.v20. The property IDs may differ there, so only use it if you know they match. |
--help (-h), --version (-v) |
Show the help or the version and exit. |
Command options
Go after the command, e.g. kettle warm 70 --dry-run. kettle <command> --help shows the ones it accepts.
| Option | What it does |
|---|---|
--keep [[<40-99>] <1-24>] (-k) |
For boil and warm: after heating, keep the water warm at that temperature for that many hours (fractions like 1.5 work). Both parts are optional: the temperature defaults to the heating target (99 °C for boil), the time to 1 hour, and a single value is the time. |
--yes (-y) |
For boil, warm and shell: skip the heating confirmation. |
--dry-run |
For boil, warm, cancel, shell and provision: print the requests, send nothing. |
--timeout <seconds> |
Seconds to wait for a reply from the kettle (default: 3). |
--debug |
Print the raw packets and requests. |
--yes, --dry-run, --timeout and --debug can also be given to kettle shell, then they apply to every command typed in it.
Safety. Heating commands refuse to start unless the kettle is a xiaomi.kettle.v20, idle, on its base and
reporting no fault, and a status read that fails or is unclear never starts anything. They print exactly what they
will send and ask y/N (without a terminal, --yes is required). This model has no water-level reading, so a
low-water condition only shows up as a fault code. Heat water remotely only when you know the kettle has water in it.
Installation
kettle is available from a variety of sources.
pip or brew is recommended, because they have a convenient way to manage updates automatically.
- pip (Recommended for everyone with a Python environment)
- You can check if you have Python installed by running
python --versionin the Terminal or cmd. - For Mac and Linux users, there is a high chance that you already have Python installed on your system.
- For Windows users, you can download Python from the official website. The tool is built and tested for macOS and Linux; it should work on Windows too, but that is untested.
- After confirmation, install kettle through the PyPI package
manager, typing
pip install kettle-x2p-cliin the Terminal. For Mac users, you may need to usepip3instead ofpip. The package is calledkettle-x2p-cli; the command it installs iskettle. - Verify the installation with
kettle --version. - You are perfect, you can use the app with
kettlefrom any folder in your system.
- You can check if you have Python installed by running
- brew (Recommended for Mac and Linux users)
- Type
brew tap manefunction/tapin your Terminal to add my custom tap (app source) to your brew sources, if you haven't already. - Type
brew install kettleto install the application itself. - Verify the installation with
kettle --version. - You are perfect, you can use the app with
kettlefrom any folder in your system.
- Type
- Python package (manual installation, for advanced users)
- Clone the repository or download the source code from GitHub.
- Go to the folder with the code in your Terminal.
- Run
pip install .to installkettleto your system. - Run
kettle --versionto verify the install.
- Ready-to-use Windows binary (for Windows users without Python)
- Download
kettle.exefrom the GitHub Releases page. - Since it isn't code-signed, Windows SmartScreen may warn about an unrecognized publisher the first time you run it — click "More info" → "Run anyway" to proceed.
- Open Command Prompt or PowerShell,
cdto the folder withkettle.exe, and run.\kettle.exe --versionto verify it works. - You are perfect, you can use the app with
.\kettle.exe. The binary is built automatically for each release; CI only checks that it starts and reports the right version, so the Windows build is less tested than macOS and Linux.
- Download
Updates arrive with pip install --upgrade kettle-x2p-cli or brew upgrade. Your saved kettle settings live outside the install
(~/.config/kettle/), so upgrading or reinstalling never loses them. (pip may ask you to use a virtual environment or pipx on newer
systems; pipx install kettle-x2p-cli is a good fit for a command line tool.)
First-time setup
Run kettle setup and follow the instructions on the screen. It takes about five minutes the first time and is
never needed again unless you re-pair the kettle.
- Add the kettle to the Xiaomi Home app (iOS / Android) so it joins your 2.4 GHz Wi-Fi.
- Get the kettle's token with the free, open-source
Xiaomi Cloud Tokens Extractor. The setup
screen shows the exact commands for Windows, macOS and Linux. It asks for your Xiaomi login and lists your devices
with their tokens; copy the 32-character token of Xiaomi Smart Kettle 2 Pro (
xiaomi.kettle.v20). - Paste the token into
kettle setup(the input is hidden). It scans your network, tries the token on every Xiaomi device it finds, and the one that answers is your kettle. - It checks the model and saves everything to
~/.config/kettle/config.json(readable by you only).
Then try kettle status. Reserve the kettle's address in your router (DHCP reservation) so it never moves; if it
does, kettle find locates it again.
For scripts, skip the prompts: kettle --token <token> --ip <ip> setup. Note that a token typed on the command
line is visible in your shell history, so the interactive prompt is the safer way.
Why the Xiaomi app and cloud are needed once
The kettle talks to the local network with a secret 16-byte token, and only Xiaomi's cloud keeps it for you.
On firmware 2.2.7 the kettle changes that token when it joins your Wi-Fi, so the token it shows while in
setup mode stops working afterwards. I tried the alternatives (including the app's own extra provisioning parameters,
kettle provision --app-params); none gave a usable token without the cloud. After the one-time extraction,
all control is local. If you re-pair or reset the kettle, the token changes and you run kettle setup again.
Usage
kettle status # what is it doing?
kettle boil # asks for confirmation, then heats to boiling
kettle warm 70 # 70 °C, then stop (green tea)
kettle warm 85 --keep 1.5 # 85 °C and keep it there for 1.5 hours
kettle warm 85 -k 60 2 # 85 °C, then keep it at 60 °C for 2 hours
kettle warm 60 --keep # 60 °C and keep 60 °C for the default hour
kettle boil -k 60 2 # boil, then keep at 60 °C for 2 hours
kettle boil -k 3 # boil and keep 99 °C for 3 hours
kettle boil --keep # boil and keep 99 °C for an hour
kettle stop # stop everything (same as cancel)
kettle warm 70 --dry-run # show what would be sent
kettle shell # keep a session open
In kettle shell you type the same commands without the kettle prefix (boil, warm 70, status, stop, quit).
Keep-warm time is limited by the kettle to 1-24 hours, and the target temperature to 40-99 °C; anything
else is rejected before it is sent.
Troubleshooting
- "no reply from ...": the kettle is offline, the IP changed (
kettle find), or the token is out of date (the kettle silently ignores requests it cannot decrypt). Runkettle setupagain if you re-paired it. - Setup does not find the kettle: your computer and the kettle must be on the same network (no guest network or VLAN between them). You can enter the IP by hand; it is in your router's client list.
- "kettle fault: something wrong (N)": check the water level and that the kettle sits on its base. Fault codes are
not documented by Xiaomi;
OK (0)means none.
How it works
The kettle speaks Xiaomi's miio protocol over UDP port 54321: a hello handshake that returns the device id and a timestamp, then JSON-RPC calls encrypted with AES-128-CBC keyed from the token. Its functions are described by a MIoT spec (service/property numbers); the ones used here are listed in SPEC.md. The client is a few hundred lines of standard-library Python, including its own AES, and handles re-handshakes and timestamp drift by itself.
Development
python3 -m venv .venv && .venv/bin/pip install -e .
.venv/bin/python -m unittest discover -s tests -v
The tests run against a fake kettle on the loopback interface that speaks the real wire format; nothing touches a
real device. The release workflow checks that the tag matches src/kettle/__init__.py, builds the package and
publishes it to PyPI and creates the GitHub release; the Homebrew formula is bumped automatically.
Credits
- python-miio for documenting the miio protocol.
- Xiaomi Cloud Tokens Extractor by Piotr Machowski.
- miot-spec.org for the device specs, and username-ardrey for Xiaomi Smart Kettle integration for Home Assistant, which shows how this model is started.
This is an unofficial project and is not affiliated with Xiaomi.
Repository info
This repo follows the Conventional Commits specification.
Metadata
Release files for kettle-x2p-cli 1.3.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 |
|---|---|---|---|---|
| kettle_x2p_cli-1.3.0.tar.gz | 37.9 kB | With provenance | Details for kettle_x2p_cli-1.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kettle_x2p_cli-1.3.0-py3-none-any.whl | Python 3 | none | any | Details for kettle_x2p_cli-1.3.0-py3-none-any.whl |
Total release size: 62.7 kB
Release files / kettle_x2p_cli-1.3.0.tar.gz
| Download URL | kettle_x2p_cli-1.3.0.tar.gz |
|---|---|
| Size | 37.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eca3df87574d056a61af58ccbb4fdf6f4ab5d4e8215541979e5ff6484bab08c6
|
|
BLAKE2b-256 checksum How to use checksums |
2678b979888af58fac40282ce47effb9b48544d8afc0a2b13fe94486dbe6b940
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 21, 2026.
Transparency logRelease files / kettle_x2p_cli-1.3.0-py3-none-any.whl
| Download URL | kettle_x2p_cli-1.3.0-py3-none-any.whl |
|---|---|
| Size | 24.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
262dff23432fd12822a39cb3bcc5751465deb90bbbc95b74e972aa93f9d4d3b7
|
|
BLAKE2b-256 checksum How to use checksums |
dd69b31f985eb5fd6fb201405588b98dcf69f1efbfe531eb0be7bcc65f111cfa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 21, 2026.
Transparency logSecurity for kettle-x2p-cli 1.3.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 kettle_x2p_cli-1.3.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 Oct 21, 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.