Skip to main content

Async client library for the Mahlkönig X54 grinder

Project description

Mahlkönig X54 Client

A Python client for the Mahlkönig X54 coffee grinder with WebSocket API support.

Installation

uv add mahlkoenig

or

pip install mahlkoenig

Features

  • Asynchronous WebSocket communication with the X54 grinder
  • API coverage for common grinder operations
  • Type-safe request and response handling
  • Automatic connection management and authentication
  • Easy access to grinder status, recipes, and statistics

Quick Start

import asyncio
from mahlkoenig import Grinder, AutoSleepTimePreset

async def main():
    # Connect to your grinder (default password is empty)
    async with Grinder(host="10.10.10.10") as client:
        # Get machine information
        machine_info = await client.request_machine_info()
        print(f"Connected to X54 grinder: {machine_info.serial_no}")
        print(f"Software version: {machine_info.sw_version}")
        
        # Get all recipes
        recipes = await client.request_recipe_list()
        for recipe_no, recipe in recipes.items():
            print(f"Recipe {recipe_no}: {recipe.name} - {recipe.grind_time}")
        
        # Set auto sleep time to 10 minutes
        await client.set_auto_sleep_time(AutoSleepTimePreset.MIN_10)
        print(f"Set auto sleep time to 10min")
        
        # Get grinding statistics
        stats = await client.request_statistics()
        print(f"Total grinding shots: {stats.total_grind_shots}")
        print(f"Total grinding time: {stats.total_grind_time}")

if __name__ == "__main__":
    asyncio.run(main())

API Reference

The Grinder class provides these main methods:

  • connect() - Establishes connection to the grinder
  • close() - Closes the connection
  • request_machine_info() - Gets machine information
  • request_wifi_info() - Gets WiFi settings
  • request_system_status() - Gets current grinder status
  • request_recipe_list() - Gets all programmed recipes
  • request_auto_sleep_time() - Gets current auto-sleep setting
  • set_auto_sleep_time() - Changes auto-sleep setting
  • request_statistics() - Gets usage statistics

The client also supports context manager syntax for automatic connection management.

Development

See DEVELOP.md for instruction on how to use mitmproxy to intercept the communication between the app and the grinder

License

MIT

Project details


Download files

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

Source Distribution

mahlkoenig-0.4.0.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

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

mahlkoenig-0.4.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file mahlkoenig-0.4.0.tar.gz.

File metadata

  • Download URL: mahlkoenig-0.4.0.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.7.2

File hashes

Hashes for mahlkoenig-0.4.0.tar.gz
Algorithm Hash digest
SHA256 ba80209a54ba2568cb874cddeec36040f9507148757ac23e8a2231920376d465
MD5 eb686b152b0835fa1637f2b619371afa
BLAKE2b-256 955d90aa452edd527ca833931fd1ffffa9a01ca47ad97138a91d74e21d97b05f

See more details on using hashes here.

File details

Details for the file mahlkoenig-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mahlkoenig-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e04ea550c697cd325dcc26b8296c54a40390227ca039516c406cf60ad0bfce55
MD5 f6bc7916887a688ba3bb23dc57972a0f
BLAKE2b-256 743794b69436a27da61480e7d40297dfea5567864f4351de0a50c80d82cfa04b

See more details on using hashes here.

Supported by

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