Skip to main content

xiaomi-vacuum-sdk

Async Python SDK for Xiaomi MIoT robot vacuums: local control over the encrypted MIoT UDP protocol, and rendering of the cloud map blob to PNG.

Built as a focused replacement for python-miio + vacuum-map-parser-xiaomi covering exactly the surface a vacuum integration needs — no legacy miIO protocol, no CLI, no device discovery. Reference models are the Xiaomi Robot Vacuum X20 Max (xiaomi.vacuum.d109gl) and S20+ (xiaomi.vacuum.b108gl); the API is model-agnostic and takes MIoT property/action addresses as input.

Install

pip install xiaomi-vacuum-sdk

Requires Python >= 3.13. Runtime dependencies: cryptography, pillow.

Local control

from xiaomi_vacuum_sdk import ActionAddress, MiotClient, PropertyAddress

client = MiotClient(host="192.168.1.50", token="ffffffffffffffffffffffffffffffff")
try:
    info = await client.info()
    print(info.model, info.firmware_version)

    state = await client.get_properties(
        {
            "status": PropertyAddress(siid=2, piid=1),
            "battery_level": PropertyAddress(siid=3, piid=1),
        }
    )
    print(state)

    await client.call_action(ActionAddress(siid=2, aiid=1))
    await client.set_property(PropertyAddress(siid=7, piid=4), 1)
finally:
    await client.close()

All calls are async-native (asyncio UDP transport, no threads). Errors form a typed hierarchy rooted at MiotError:

  • MiotConnectionError — network failure or response timeout.
  • MiotDeviceError — the device answered with a non-zero error code (code, message attributes).
  • MiotAckTimeoutError — the device accepted the command but never sent the ack (Xiaomi vacuums do this routinely while busy); a distinct type so callers can choose optimistic handling.

Map rendering

from xiaomi_vacuum_sdk import MapRenderer, RenderOptions

renderer = MapRenderer(RenderOptions())
png = renderer.render(blob, model="xiaomi.vacuum.d109gl", device_id="412345678")

blob is the encrypted map exactly as downloaded from the Xiaomi cloud (get_file_url object storage). The renderer absorbs the format quirks — model-derived AES key, optional {"data": "<base64>"} envelope, zlib inflate — and returns finished PNG bytes. Rendering is CPU-bound and sync; wrap it in an executor inside async applications.

RenderOptions controls palette, room colors, drawn layers, scale and element sizes; every field has a sensible default.

License

MIT.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xiaomi_vacuum_sdk-0.1.0.tar.gz (80.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xiaomi_vacuum_sdk-0.1.0-py3-none-any.whl (29.7 kB view details)

Uploaded Python 3

File details

Details for the file xiaomi_vacuum_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: xiaomi_vacuum_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 80.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for xiaomi_vacuum_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e19c84837e3fe8b2b071e8f503291f775ab2071091d000495684c2125e83967d
MD5 a66da2bd15c85ea5ab5a2622e160cd30
BLAKE2b-256 e38970da334eb273f76aa2ab0b83e7ce77d71142dacbb17f9dc243b988efb22d

See more details on using hashes here.

File details

Details for the file xiaomi_vacuum_sdk-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for xiaomi_vacuum_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cdde010a1aa3501219855d4d3df4fb70af2eef2c38d2b81df347e1cd8227d400
MD5 9b91ec8e6216bbe6ef7d41c2202688d2
BLAKE2b-256 259a4c961ed376b670d407db53abaab66deff0875a73d517c90a84f2f5ea2de6

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page