mira-ble
Async Python library for Mira digital showers (Activate and current-generation Mode valves, and the Platinum) over Bluetooth LE. It reads the valve's state, outlet limits, presets and last run, and runs or stops outlets and presets, with every control command confirmed by reading the valve back.
It is the library behind the Home Assistant integration ha-mira-ble, and has no Home Assistant dependency.
Status: alpha, run on one real valve. Pairing, every read, starting a preset, running an outlet and both stops were run against one Mira Platinum, a handful of times, attended: from macOS, and through an ESPHome proxy under Home Assistant. Nothing has run on a local Linux adapter or on another model; those paths are tested only against a simulation and against replies recorded by the projects credited below. Start with the read-only commands and watch it behave.
This drives plumbing that produces hot water. Never run it unattended. The library cannot stop the water if the link drops or your program exits: the valve's own maximum run time is the only backstop then.
This project is not affiliated with Mira Showers or Kohler. Mira and Kohler are trademarks of their owners.
Supported hardware
Valves whose Bluetooth name looks like Mira 0051#… or Mira 004C Bathroom and that offer
the GATT service 267f0001-eb15-43f5-94c3-67d2221188f7. Older Mira Mode valves offer
bccb0001-ca66-11e5-88a4-0002a5d5c51b and speak an unrelated protocol; they are not
supported.
| Model | Status |
|---|---|
| Mira Activate, current Mira Mode | Protocol measured on real valves by other projects; this library not yet run on one |
| Mira Platinum | Run on one unit from macOS: pairing, every read, a preset start, an outlet command, the pause and the all-zero stop. A preset warms the water up and then holds until the outlet button or an outlet command starts the shower. The vendor app itself controls the Platinum through the cloud |
Install
pip install mira-ble # or: uv add mira-ble
Python 3.13 or newer.
Pairing
The valve only talks over a bonded link, and only accepts a new bond while it is in pairing mode: on a controller with a button, hold it for five seconds until it flashes; on a dial controller use Menu → Settings → Connect. Switching the valve's power off and on is reported to leave it pairable for a short while as well. Pairing is "Just Works" (no code to enter).
The library pairs on every connection, which is a quick re-encrypt once a bond exists. The bond lives on the adapter (or ESPHome proxy) that made it. The vendor app's own text says a valve keeps up to ten paired devices and lists them under "Manage Paired Devices"; nobody here has measured the limit.
If the valve is reset, or the device is removed from it in the app, the adapter keeps
offering keys the valve no longer accepts. Forget the valve on the adapter and pair again
(remove_bluez_bond() does that on Linux).
ESPHome proxies built on ESP-IDF 5.5.6 (ESPHome 2026.10.x) forget a bond after the first connection (esphome#21880): the second connection is refused as if the valve had never been paired. Pin the proxy to ESP-IDF 5.5.5 or use a release with the fix.
Command line
$ mira-ble scan
12345678-1234-5678-1234-56789ABCDEF0 Mira 0051#0123456789012345 -58 dBm
$ mira-ble status <address>
idle water 21.4 C flow 0 of 4 L/min
$ mira-ble watch <address>
19:18:26 idle water 25.5 C flow 0 of 4 L/min
19:18:29 outlet 1 water 25.5 C target 40.0 C flow 3 of 15 L/min
$ mira-ble outlets-config <address>
Outlet 1 (hand_shower, type 1): 30-45 C (default 38), 4-16 L/min (default 12), stops after 30:00
$ mira-ble presets <address>
1 Everyday 38.0 C outlet 1 30:00 12 L/min
$ mira-ble run <address> --outlet 1 --temperature 38 --flow 10
outlet 1 water 22.0 C target 38.0 C flow 3 of 10 L/min
$ mira-ble stop <address>
idle water 31.0 C flow 0 of 4 L/min
The output above is illustrative. scan, info, status, watch, outlets-config and
presets change nothing on the valve: start with those, with watch --raw running while
someone uses the shower at the wall, before sending anything.
runreads the outlets' own maximum temperature first and applies the lower of that and--max-temperature(default 45 °C; give it before the command name).- If a
runorstartcannot be confirmed, the tool sends a stop before exiting and says so; if it printsCHECK THE SHOWER, go and look. startsends the preset command once. On a Mira Platinum that warms the water up and then holds, waiting;start --throughwaits for the hold and sends the command again, which runs the preset with its own timer (water then runs for the preset's whole duration).presetsexits with an error and a reason when it could read none; some valves only answer preset reads while running.-vlogs every frame, from this package only. Frames carry the valve's name and serial number when those are read.- Addresses are MAC addresses on Linux and Windows, and UUIDs on macOS. Flow is litres per minute; the vendor app shows the same number on its 0 to 25 scale.
Library
import asyncio
from bleak import BleakScanner
from mira_ble import BleTransport, MiraValve, Outlet
async def main() -> None:
device = await BleakScanner.find_device_by_address("AA:BB:CC:DD:EE:FF")
async with BleTransport(device, expect_new_bond=True) as transport:
valve = MiraValve(transport, max_temperature=42.0)
capabilities = await valve.probe() # outlets and presets; tolerant of a quiet valve
limit = capabilities.max_temperature(Outlet.FIRST) # the outlet's own maximum
state = await valve.set_outlets(
Outlet.FIRST, temperature=38.0, flow=10.0, max_temperature=limit
)
print(state.water_temperature, state.flow)
try:
await asyncio.sleep(60)
finally:
await valve.stop()
asyncio.run(main())
Units are degrees Celsius, litres per minute, seconds and litres throughout.
What the control commands guarantee
- Temperature limits before anything is written. A target above
max_temperature(default 45 °C), above a per-call limit, or above the absolute ceiling of 48 °C raisesUnsafeValue; so does a limit that is not a number. - Confirmation by the valve's state, within a few seconds.
set_outlets,stopandrun_presetrequire the valve's acknowledgement and then read the state until it shows the command, for up to 8 s (valves take time to act).NotConfirmedcarries the last state read: the valve may still be acting, so if a start is not confirmed, callstop(). - "Stopped" means no water.
State.runningis true for an open outlet or measured flow; a stop is confirmed only when neither shows on two reads. A valve may stay held (State.held, a pause it ends by itself) for a while after;State.activecovers both.stop()first sends the vendor app's pause (the valve's own temperature and flow with the hold bit), which leaves the valve's settings alone; if water still runs it sends the all-zero stop, then "run preset 0". - One word for what the valve is doing.
State.phaseisrest,warming_up,paused,presetorrunning;State.presetandState.time_remaininggive the running preset and the seconds it has left by the valve's own count, andState.volumethe litres used.run_preset()sends the preset command once;run_preset_through()carries a preset past the warm-up hold measured on a Mira Platinum. - Complete state. A command names every outlet that should run; any other is switched
off. Which fixture is outlet 1 depends on the plumbing:
outlets-configandpresetstell. - Replies are matched by shape. A reply carries no identifier, so each read accepts only a reply of the right shape, and a request that does not complete (timeout, cancellation) closes the link.
- Prefer short connections through a proxy. Measured through an ESPHome proxy on a Mira
Platinum, requests on a new link take 0.1 to 0.3 s; once the link has been up for a few
seconds they take 7 to 10 s and often time out.
BleTransport.link_agesays how old the link is. From macOS a link held for minutes stayed quick. - Optional reads.
read_identity()andprobe()record what a valve refused or ignored inerrorsand carry on; only the state read must succeed. - No configuration writes. The library does not implement the opcodes that change outlet limits, controller configuration, Wi-Fi credentials, commissioning state, the serial number or that reset the valve. Preset write and delete are the only persistent writes; a write replaces the whole slot for good, so note down what is there first.
Errors
Everything derives from MiraError. Connection problems are MiraConnectionError
(PairingRequired, ConnectionLost, RequestTimeout); the valve refusing a command is
CommandRejected; a malformed reply is ProtocolError.
PairingRequired.refused tells an outright refusal (the valve is not in pairing mode and the
adapter holds no bond it accepts) from a link that merely could not be encrypted, which can
also be a proxy that needs a restart. Only the first is a reason to pair again.
Testing your own code
mira_ble.testing.FakeValve is a transport standing in for a valve: its state changes when
commanded, and it can be made slow to act, silent on chosen opcodes, chatty, or to stay held
after a stop as a Platinum was measured to. It is a model built from recordings and reports, not the
firmware. The module also ships the recorded replies. It is test support, and may change
between minor versions.
Versions
Pin an exact version. While the version is 0.x a minor release may change the API or the
protocol layer; read the
changelog before upgrading. The
supported API is what mira_ble exports.
Protocol
docs/protocol.md describes the frame format, every opcode the vendor app builds, the layouts this library decodes, and where each fact comes from.
Acknowledgements
- Ryan Shaw, mira-mode-control (MIT): the state and preset layouts, verified by commanding known values on a real valve, and the recorded replies used as test vectors here.
- Hayden Griffin, ha-mira-mode (MIT): the outlet configuration and last-usage layouts, with recordings.
- Jon Williams, Mira-Activate-HA (MIT): frames captured from the vendor app, and the hard-won lessons about ESPHome proxies: pairing on every connection, settling before the subscribe, and not re-pairing on suspicion.
- Nigel Hannam, shower-controller-documentation: the older generation's protocol.
- ble-bond (MIT, same author): the bonded Bluetooth link this library runs on, shared with grundfos-ble. Its BlueZ pairing agent is adapted from alpha-hwr, credited there.
Copyright notices: THIRD_PARTY_NOTICES.md.
Development
nix develop # or: uv sync --group dev
uv run pytest --cov
uv run ruff check . && uv run ruff format --check . && uv run mypy
Licence
MIT.
Metadata
Release files for mira-ble 0.1.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 |
|---|---|---|---|---|
| mira_ble-0.1.0.tar.gz | 65.6 kB | With provenance | Details for mira_ble-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mira_ble-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for mira_ble-0.1.0-py3-none-any.whl |
Total release size: 111.5 kB
Release files / mira_ble-0.1.0.tar.gz
| Download URL | mira_ble-0.1.0.tar.gz |
|---|---|
| Size | 65.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ae7f0d57d0324d810f62e8972a73104c50bd321753a322f9a5585e086a99ceb4
|
|
BLAKE2b-256 checksum How to use checksums |
a8a0a9662b1ddad25ba555e584a2b7f0183a4f47d248b101abc86547c66a27bc
|
| 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 16, 2026.
Transparency logRelease files / mira_ble-0.1.0-py3-none-any.whl
| Download URL | mira_ble-0.1.0-py3-none-any.whl |
|---|---|
| Size | 45.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d053cc4616de4084f3eff2ba3edf54c431c1aae68f6be34a77691ad4b24c1a38
|
|
BLAKE2b-256 checksum How to use checksums |
e410c03afe5b6e3e9a0daaf9d23170c6dee0324d952190dca31f7515a793eed2
|
| 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 16, 2026.
Transparency logSecurity for mira-ble 0.1.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 mira_ble-0.1.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 16, 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.