Skip to main content

A Python implementation of the La Marzocco API

Project description

La Marzocco Python Client

This is a library to interface with La Marzocco's Home machines. It also has support to get information for the Pico grinder.

workflow codecov

Installing this libary

This project is on pypi and can be installed using pip

pip install pylamarzocco

Libraries in this project

  • LaMarzoccoLocalClient calls the new local API the Micra exposes, using the Bearer token from the customer cloud endpoint. However, this API currently only supports getting the config, and some status objects (like shottimer) over websockets, but does not support setting anything (to my knowledge). Local settings appear to only happen through Bluetooth connections.
  • LaMarzoccoCloudClient interacts with gw-lmz.lamarzocco.com to send commands. pylamarzocco can be initialized to only issue remote commands, or to initialize an instance of lmlocalapi for getting the current machine settings. This helps to avoid flooding the cloud API and is faster overall.
  • LaMarzoccoBluetoothClient provides a bluetooth client to send settings to the machine via bluetooth

Setup

LaMarzoccoCloudClient

You need username and password, which are the credentials you're using to sign into the La Marzocco Home app.

It is initialized like this

cloud_client = LaMarzoccoCloudClient(username, password)

and you get your config

await cloud_client.get_config(serial_number)

LaMarzoccoLocalClient

If you just want to run the local API you need the IP of your machine, the Port it is listening on (8081 by default), the Bearer token (communicationKey) used for local communication. You can obtain that key by inspecting a call to https://cms.lamarzocco.io/api/customer, while connected to mitmproxy (process above), or making a new (authenticated) call to that endpoint.

Then you can init the class with

local_client = LaMarzoccoLocalClient(ip, local_token)

LaMarzoccoBluetoothClient

Some commands, like turning the machine on and off are always sent through bluetooth whenever possible. The available bluetooth characteristics are described in bluetooth_characteristics. The class LaMarzoccoBluetoothClient discovers any bluetooth devices connects to it. Then we can send local bluetooth commands.

To use Bluetooth you can either init pylamarzocco with

    if bluetooth_devices := LaMarzoccoBluetoothClient.discover_devices():
        print("Found bluetooth device:", bluetooth_devices[0])

    bluetooth_client = LaMarzoccoBluetoothClient(
        username,
        serial_number,
        local_token
        bluetooth_devices[0],
    )

The local_token is the same token you need to initialize the local API, which you need to get from LM's cloud once. The serial number is your machine's serial number and the username is the email of your LaMarzocco account.

Machine

Once you have any or all of the clients, you can initialize a machine object with

machine = Machine.create(model, serial_number, name, cloud_client, local_client, bluetooth_client)

You can then use the machine object to send commands to the machine, or to get the current status of the machine. If you're running in cloud only mode, please be mindful with the requests to not flood the cloud API.

Grinder

The Pico grinder can be initialized with

grinder = LaMarzoccoGrinder.create(model, serial_number, name, cloud_client, local_client, bluetooth_client)

where you can use the same cloud client as for the machine, but you need to initialize new local and bluetooth clients (the same way as for the machine) to use the grinder.

Websockets

The local API initiates a websocket connection to

http://{IP}:8081/api/v1/streaming

The packets which are received on that WebSocket are documented in websockets

If WebSockets are enabled the shot timer becomes available to use, however as long as the library is running in WebSocket mode, the App will no longer be able to connect.

To use WebSockets start the integration with

await machine.websocket_connect(callback)

with an optional callback function that will be called whenever there have been updates for the machine from the websocket.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

pylamarzocco-2.0.0b4.tar.gz (28.8 kB view details)

Uploaded Source

Built Distribution

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

pylamarzocco-2.0.0b4-py3-none-any.whl (29.2 kB view details)

Uploaded Python 3

File details

Details for the file pylamarzocco-2.0.0b4.tar.gz.

File metadata

  • Download URL: pylamarzocco-2.0.0b4.tar.gz
  • Upload date:
  • Size: 28.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pylamarzocco-2.0.0b4.tar.gz
Algorithm Hash digest
SHA256 c8c19c27467cebbf9f790970dbde79d77ca4adf23b644f4f18bc9013c2d690b8
MD5 88e574b8eb54f5bde4b4477aa503496b
BLAKE2b-256 8dacb2af6f6bd77cda9df4389db3e4ab9eb1f956e479670b10edea1f66420522

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylamarzocco-2.0.0b4.tar.gz:

Publisher: pypi.yaml on zweckj/pylamarzocco

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pylamarzocco-2.0.0b4-py3-none-any.whl.

File metadata

  • Download URL: pylamarzocco-2.0.0b4-py3-none-any.whl
  • Upload date:
  • Size: 29.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pylamarzocco-2.0.0b4-py3-none-any.whl
Algorithm Hash digest
SHA256 c9772ee650765c9ca9e4d877b2bd3c97d0666bfa0e74d5bd1742fdd8de9a7c0f
MD5 8a75f7506152ba3bfdca84f09a8d389c
BLAKE2b-256 23cc45b8c5afa2340f6f91127ba03096fcc7fb24a4103ddde4612b70c338c3a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylamarzocco-2.0.0b4-py3-none-any.whl:

Publisher: pypi.yaml on zweckj/pylamarzocco

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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