A Python implementation of the new 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.
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 withgw-lmz.lamarzocco.com
to send commands. pylamarzocco can be initialized to only issue remote commands, or to initialize an instance oflmlocalapi
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 = await LaMarzoccoCloudClient(username, password)
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
Built Distribution
File details
Details for the file pylamarzocco-1.2.6.tar.gz
.
File metadata
- Download URL: pylamarzocco-1.2.6.tar.gz
- Upload date:
- Size: 21.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f724c35e1f2494bb10b4ba432bb0656f077ffb0163794c2dae0e3ff2d8eeaf9a |
|
MD5 | 834073c49fd7113264d0c1417bc4502d |
|
BLAKE2b-256 | 3a5759535aa655f1f5c1a46b389bedbb886824bf74f5f12b9448a8dcb753a0c5 |
Provenance
The following attestation bundles were made for pylamarzocco-1.2.6.tar.gz
:
Publisher:
pypi.yaml
on zweckj/pylamarzocco
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
pylamarzocco-1.2.6.tar.gz
- Subject digest:
f724c35e1f2494bb10b4ba432bb0656f077ffb0163794c2dae0e3ff2d8eeaf9a
- Sigstore transparency entry: 150609648
- Sigstore integration time:
- Predicate type:
File details
Details for the file pylamarzocco-1.2.6-py3-none-any.whl
.
File metadata
- Download URL: pylamarzocco-1.2.6-py3-none-any.whl
- Upload date:
- Size: 23.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c85b89c3fb85f5d640e2d9b164b59f65446d20056c9247d0be04d0d129c187e4 |
|
MD5 | 4a7363c3d22835e4b7980db174eb3657 |
|
BLAKE2b-256 | 118fe6aabbb3f6b8c44514394700b506e8b567b7de5781fa87be3afd309fe458 |
Provenance
The following attestation bundles were made for pylamarzocco-1.2.6-py3-none-any.whl
:
Publisher:
pypi.yaml
on zweckj/pylamarzocco
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
pylamarzocco-1.2.6-py3-none-any.whl
- Subject digest:
c85b89c3fb85f5d640e2d9b164b59f65446d20056c9247d0be04d0d129c187e4
- Sigstore transparency entry: 150609649
- Sigstore integration time:
- Predicate type: