# 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](https://github.com/zweckj/pylamarzocco/actions/workflows/pypi.yaml/badge.svg)
[![codecov](https://codecov.io/gh/zweckj/pylamarzocco/graph/badge.svg?token=350GPTLZXS)](https://codecov.io/gh/zweckj/pylamarzocco)
# Installing this libary
This project is on pypi and can be installed using pip
```bash
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](#lmbluetooth).
- `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
```python
cloud_client = LaMarzoccoCloudClient(username, password)
```
and you get your config
```python
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
```python
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](docs/bluetooth_characteristics.md).
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
```python
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
```python
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
```python
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](docs/websockets.md)
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
```python
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.
Raw data
{
"_id": null,
"home_page": null,
"name": "pylamarzocco",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": "Josef Zweck <24647999+zweckj@users.noreply.github.com>",
"keywords": "La Marzocco, lamarzocco, api, async, client",
"author": null,
"author_email": "Josef Zweck <24647999+zweckj@users.noreply.github.com>",
"download_url": "https://files.pythonhosted.org/packages/fe/e0/894b14928a83a4cbc7d8b722c550034ff08455ce27045ffc4558856c6160/pylamarzocco-1.2.11.tar.gz",
"platform": null,
"description": "# La Marzocco Python Client\n\nThis is a library to interface with La Marzocco's Home machines.\nIt also has support to get information for the Pico grinder.\n\n![workflow](https://github.com/zweckj/pylamarzocco/actions/workflows/pypi.yaml/badge.svg)\n[![codecov](https://codecov.io/gh/zweckj/pylamarzocco/graph/badge.svg?token=350GPTLZXS)](https://codecov.io/gh/zweckj/pylamarzocco)\n\n# Installing this libary\nThis project is on pypi and can be installed using pip\n\n```bash\npip install pylamarzocco\n```\n\n# Libraries in this project\n\n- `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](#lmbluetooth).\n- `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.\n- `LaMarzoccoBluetoothClient` provides a bluetooth client to send settings to the machine via bluetooth\n\n# Setup\n\n## LaMarzoccoCloudClient\n\nYou need `username` and `password`, which are the credentials you're using to sign into the La Marzocco Home app.\n\nIt is initialized like this\n\n```python\ncloud_client = LaMarzoccoCloudClient(username, password)\n```\n\nand you get your config\n```python\nawait cloud_client.get_config(serial_number)\n```\n\n## LaMarzoccoLocalClient\n\nIf 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.\nYou 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.\n\nThen you can init the class with\n\n```python\nlocal_client = LaMarzoccoLocalClient(ip, local_token)\n```\n\n## LaMarzoccoBluetoothClient\n\nSome commands, like turning the machine on and off are always sent through bluetooth whenever possible. The available bluetooth characteristics are described in [bluetooth_characteristics](docs/bluetooth_characteristics.md).\nThe class `LaMarzoccoBluetoothClient` discovers any bluetooth devices connects to it. Then we can send local bluetooth commands.\n\nTo use Bluetooth you can either init pylamarzocco with\n\n```python\n if bluetooth_devices := LaMarzoccoBluetoothClient.discover_devices():\n print(\"Found bluetooth device:\", bluetooth_devices[0])\n\n bluetooth_client = LaMarzoccoBluetoothClient(\n username,\n serial_number,\n local_token\n bluetooth_devices[0],\n )\n```\n\nThe 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.\n\n## Machine\n\nOnce you have any or all of the clients, you can initialize a machine object with\n\n```python\nmachine = Machine.create(model, serial_number, name, cloud_client, local_client, bluetooth_client)\n```\n\nYou 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.\n\n## Grinder\n\nThe Pico grinder can be initialized with\n\n```python\ngrinder = LaMarzoccoGrinder.create(model, serial_number, name, cloud_client, local_client, bluetooth_client)\n```\n\nwhere 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.\n\n### Websockets\n\nThe local API initiates a websocket connection to\n\n```\nhttp://{IP}:8081/api/v1/streaming\n```\n\nThe packets which are received on that WebSocket are documented in [websockets](docs/websockets.md)\n\nIf 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.\n\nTo use WebSockets start the integration with\n\n```python\nawait machine.websocket_connect(callback)\n```\n\nwith an optional callback function that will be called whenever there have been updates for the machine from the websocket.\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "A Python implementation of the new La Marzocco API",
"version": "1.2.11",
"project_urls": {
"Documentation": "https://github.com/zweckj/pylamarzocco",
"Homepage": "https://github.com/zweckj/pylamarzocco",
"Repository": "https://github.com/zweckj/pylamarzocco"
},
"split_keywords": [
"la marzocco",
" lamarzocco",
" api",
" async",
" client"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "da0fd5147c95c300bfa86371fa6d49dc3c4ad0344232ed874c602c0876e1c16f",
"md5": "df42030e6d99301f14b330729fd73c48",
"sha256": "d0748ace534908f31b22e9299ee4ba85b0e35ba223b3a8009066d4f327fe5d9e"
},
"downloads": -1,
"filename": "pylamarzocco-1.2.11-py3-none-any.whl",
"has_sig": false,
"md5_digest": "df42030e6d99301f14b330729fd73c48",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 23404,
"upload_time": "2024-11-23T11:13:32",
"upload_time_iso_8601": "2024-11-23T11:13:32.366065Z",
"url": "https://files.pythonhosted.org/packages/da/0f/d5147c95c300bfa86371fa6d49dc3c4ad0344232ed874c602c0876e1c16f/pylamarzocco-1.2.11-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fee0894b14928a83a4cbc7d8b722c550034ff08455ce27045ffc4558856c6160",
"md5": "a5aae19b2120f9b36d25c0b3b097f4d5",
"sha256": "6f45f106cc5d126369649bed1209ef4d60e0e49ea274ef0dc5d6170fcdcdf4f4"
},
"downloads": -1,
"filename": "pylamarzocco-1.2.11.tar.gz",
"has_sig": false,
"md5_digest": "a5aae19b2120f9b36d25c0b3b097f4d5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 22110,
"upload_time": "2024-11-23T11:13:34",
"upload_time_iso_8601": "2024-11-23T11:13:34.245235Z",
"url": "https://files.pythonhosted.org/packages/fe/e0/894b14928a83a4cbc7d8b722c550034ff08455ce27045ffc4558856c6160/pylamarzocco-1.2.11.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-23 11:13:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "zweckj",
"github_project": "pylamarzocco",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pylamarzocco"
}