### Complete Example of Using pylamarzocco Source: https://github.com/zweckj/pylamarzocco/blob/main/README.md This example shows how to use the pylamarzocco library to control a La Marzocco machine. It includes generating or loading an installation key, initializing the cloud client, registering the device if needed, retrieving machine information, and toggling the machine's power. ```python import asyncio import uuid from pathlib import Path from aiohttp import ClientSession from pylamarzocco import LaMarzoccoCloudClient, LaMarzoccoMachine from pylamarzocco.util import InstallationKey, generate_installation_key SERIAL = "your_serial_number" USERNAME = "your_username" PASSWORD = "your_password" async def main(): # Generate or load key material key_file = Path("installation_key.json") if not key_file.exists(): installation_key = generate_installation_key(str(uuid.uuid4()).lower()) with open(key_file, "w", encoding="utf-8") as f: f.write(installation_key.to_json()) registration_required = True else: with open(key_file, "r", encoding="utf-8") as f: installation_key = InstallationKey.from_json(f.read()) registration_required = False async with ClientSession() as session: # Initialize cloud client client = LaMarzoccoCloudClient( username=USERNAME, password=PASSWORD, installation_key=installation_key, client=session, ) # Register device if needed if registration_required: await client.async_register_client() # Initialize machine machine = LaMarzoccoMachine(SERIAL, client) # Get machine information await machine.get_dashboard() await machine.get_firmware() await machine.get_settings() # Control the machine await machine.set_power(True) await asyncio.sleep(5) await machine.set_power(False) asyncio.run(main()) ``` -------------------------------- ### Initialize LaMarzoccoCloudClient and register Source: https://github.com/zweckj/pylamarzocco/blob/main/README.md Create a LaMarzoccoCloudClient with username, password, installation key, and an aiohttp session. Register the client once for new installation keys. ```python from aiohttp import ClientSession from pylamarzocco import LaMarzoccoCloudClient async with ClientSession() as session: cloud_client = LaMarzoccoCloudClient( username=username, password=password, installation_key=installation_key, client=session, ) # Register the client (only needed once for new installation keys) await cloud_client.async_register_client() ``` -------------------------------- ### Install pylamarzocco via pip Source: https://github.com/zweckj/pylamarzocco/blob/main/README.md Install the library from PyPI using pip. ```bash pip install pylamarzocco ``` -------------------------------- ### Generate and save installation key Source: https://github.com/zweckj/pylamarzocco/blob/main/README.md Generate a new installation key using a UUID and save it to a JSON file for future use. ```python import uuid from pylamarzocco.util import generate_installation_key, InstallationKey # Generate new key material installation_key = generate_installation_key(str(uuid.uuid4()).lower()) # Save it for future use with open("installation_key.json", "w", encoding="utf-8") as f: f.write(installation_key.to_json()) # Or load existing key material with open("installation_key.json", "r", encoding="utf-8") as f: installation_key = InstallationKey.from_json(f.read()) ``` -------------------------------- ### Enable Backflush Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/remote_rest.md Use this GET request to enable the backflush process. ```json { "enable": True } ``` -------------------------------- ### GET /v1/home/machines//enable-backflush Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/remote_rest.md Enables the backflush cycle. ```APIDOC ## GET /v1/home/machines//enable-backflush ### Description Enables the backflush cycle. ### Method GET ### Endpoint `https://gw-lmz.lamarzocco.io/v1/home/machines//enable-backflush` ### Parameters #### Path Parameters - **SN** (string) - Required - The serial number of the machine. #### Request Body - **enable** (boolean) - Required - Set to true to enable backflush. ### Request Example ```json { "enable": true } ``` ``` -------------------------------- ### Get machine information using LaMarzoccoMachine methods Source: https://github.com/zweckj/pylamarzocco/blob/main/README.md Retrieve various details from the machine, including dashboard, firmware, schedule, settings, and statistics. Also convert machine data to a dictionary. ```python # Get dashboard information await machine.get_dashboard() # Get firmware information await machine.get_firmware() # Get schedule settings await machine.get_schedule() # Get machine settings await machine.get_settings() # Get statistics await machine.get_statistics() # Get machine data as dictionary machine_data = machine.to_dict() ``` -------------------------------- ### GET /v1/home/machines//enable-plumbin Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/remote_rest.md Enables or disables plumb-in mode. ```APIDOC ## GET /v1/home/machines//enable-plumbin ### Description Enables or disables plumb-in mode. ### Method GET ### Endpoint `https://gw-lmz.lamarzocco.io/v1/home/machines//enable-plumbin` ### Parameters #### Path Parameters - **SN** (string) - Required - The serial number of the machine. #### Request Body - **enable** (boolean) - Required - Set to true to enable plumb-in, false to disable. ### Request Example ```json { "enable": true } ``` ``` -------------------------------- ### Enable Plumb In Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/remote_rest.md Use this GET request to enable or disable the plumb in feature. ```json { "enable": True // False } ``` -------------------------------- ### GET /v1/home/machines//configuration Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/remote_rest.md Retrieves the configuration of the machine. The response schema is not provided in the source documentation. ```APIDOC ## GET /v1/home/machines//configuration ### Description Retrieves the configuration of the machine. The response schema is not provided in the source documentation. ### Method GET ### Endpoint https://gw-lmz.lamarzocco.io/v1/home/machines//configuration ### Parameters #### Path Parameters - **SN** (string) - Required - The serial number of the machine. ### Response #### Success Response (200) - **data** (object) - Configuration data (schema not provided). - **status** (boolean) - Indicates if the request was successful. #### Response Example (No example provided in source documentation) ``` -------------------------------- ### Set Machine Schedule Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/remote_rest.md Use this GET request to configure the weekly scheduling for the machine. ```json { "enable": True, // False "days": [ { "day": "MONDAY", "enable": false, "off": "00:00", "on": "00:00" }, { "day": "TUESDAY", "enable": false, "off": "00:00", "on": "00:00" }, { "day": "WEDNESDAY", "enable": false, "off": "00:00", "on": "00:00" }, { "day": "THURSDAY", "enable": false, "off": "00:00", "on": "00:00" }, { "day": "FRIDAY", "enable": false, "off": "00:00", "on": "00:00" }, { "day": "SATURDAY", "enable": false, "off": "00:00", "on": "00:00" }, { "day": "SUNDAY", "enable": false, "off": "00:00", "on": "00:00" } ] } ``` -------------------------------- ### GET /v1/home/machines//firmwarev2/ Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/remote_rest.md Retrieves the latest firmware information for both the gateway and the machine, including version, MD5 hash, and download URLs. ```APIDOC ## GET /v1/home/machines//firmwarev2/ ### Description Retrieves the latest firmware information for both the gateway and the machine, including version, MD5 hash, and download URLs. ### Method GET ### Endpoint https://gw-lmz.lamarzocco.io/v1/home/machines//firmwarev2/ ### Parameters #### Path Parameters - **SN** (string) - Required - The serial number of the machine. ### Response #### Success Response (200) - **data** (object) - Contains firmware details for gateway and machine. - **data.gateway_firmware** (object) - Gateway firmware information. - **data.gateway_firmware.latestVersion** (string) - Latest available version. - **data.gateway_firmware.md5** (string) - MD5 checksum (may be empty). - **data.gateway_firmware.update** (null) - Update status (null if no update). - **data.gateway_firmware.url_firmware** (string) - URL to download firmware. - **data.gateway_firmware.url_schema** (string) - URL to schema. - **data.gateway_firmware.version** (string) - Current version. - **data.machine_firmware** (object) - Machine firmware information. - **data.machine_firmware.latestVersion** (string) - Latest available version. - **data.machine_firmware.md5** (string) - MD5 checksum. - **data.machine_firmware.update** (null) - Update status (null if no update). - **data.machine_firmware.url_firmware** (string) - URL to download firmware. - **data.machine_firmware.url_schema** (string) - URL to schema. - **data.machine_firmware.version** (string) - Current version. - **status** (boolean) - Indicates if the request was successful. #### Response Example { "data": { "gateway_firmware": { "latestVersion": "v2.2-rc0", "md5": "", "update": null, "url_firmware": "http://firmware.lamarzocco.io/new_firmware/gateway/v2/home-gateway_v2.2-rc0.bin", "url_schema": "http://firmware.lamarzocco.io/new_json/gw/v2.2rc0.json", "version": "v2.2-rc0" }, "machine_firmware": { "latestVersion": "1.11", "md5": "7928e9d27f612dd3136e6ebd3a45eb944b263bf053f6ea6dfa1140c4c45b64d3", "update": null, "url_firmware": "http://firmware.lamarzocco.io/new_firmware/machine/micra/atmega32/NewuLApp-111.bin", "url_schema": "http://firmware.lamarzocco.io/new_json/fw/MR/v1.11.json", "version": "1.11" } }, "status": true } ``` -------------------------------- ### GET /v1/home/machines//scheduling Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/remote_rest.md Sets the weekly schedule for the machine. ```APIDOC ## GET /v1/home/machines//scheduling ### Description Sets the weekly schedule for the machine. ### Method GET ### Endpoint `https://gw-lmz.lamarzocco.io/v1/home/machines//scheduling` ### Parameters #### Path Parameters - **SN** (string) - Required - The serial number of the machine. #### Request Body - **enable** (boolean) - Required - Whether the schedule is enabled. - **days** (array) - Required - List of day settings. - **day** (string) - Required - Day of the week (e.g., "MONDAY"). - **enable** (boolean) - Required - Whether the schedule is enabled for this day. - **off** (string) - Required - Off time in HH:MM format. - **on** (string) - Required - On time in HH:MM format. ### Request Example ```json { "enable": true, "days": [ { "day": "MONDAY", "enable": false, "off": "00:00", "on": "00:00" }, { "day": "TUESDAY", "enable": false, "off": "00:00", "on": "00:00" }, { "day": "WEDNESDAY", "enable": false, "off": "00:00", "on": "00:00" }, { "day": "THURSDAY", "enable": false, "off": "00:00", "on": "00:00" }, { "day": "FRIDAY", "enable": false, "off": "00:00", "on": "00:00" }, { "day": "SATURDAY", "enable": false, "off": "00:00", "on": "00:00" }, { "day": "SUNDAY", "enable": false, "off": "00:00", "on": "00:00" } ] } ``` ``` -------------------------------- ### Get Boiler Temperature Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/remote_rest.md Use this GET request to retrieve the target temperature for a specific boiler. ```json { "identifier": "" } ``` -------------------------------- ### Connect to dashboard WebSocket with callback and disconnect Source: https://github.com/zweckj/pylamarzocco/blob/main/README.md Start a WebSocket connection to receive real-time dashboard updates. An optional callback function can process incoming ThingDashboardWebsocketConfig messages. Disconnect using machine.websocket.disconnect(). ```python from pylamarzocco.models import ThingDashboardWebsocketConfig def callback(config: ThingDashboardWebsocketConfig): """Callback function for websocket updates.""" print(f"Received update: {config.to_dict()}") # Connect to dashboard websocket with optional callback await machine.connect_dashboard_websocket(callback) # The websocket will receive real-time updates about the machine status # To disconnect later: await machine.websocket.disconnect() ``` -------------------------------- ### GET /v1/home/machines//target-boiler Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/remote_rest.md Retrieves or sets the target temperature for a boiler. ```APIDOC ## GET /v1/home/machines//target-boiler ### Description Retrieves or sets the target temperature for a boiler. ### Method GET ### Endpoint `https://gw-lmz.lamarzocco.io/v1/home/machines//target-boiler` ### Parameters #### Path Parameters - **SN** (string) - Required - The serial number of the machine. #### Request Body - **identifier** (string) - Required - The boiler identifier. - **value** (number) - Required - The target temperature. ### Request Example ```json { "identifier": "" } ``` ``` -------------------------------- ### GET /v1/home/machines//statistics/daily Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/remote_rest.md Retrieves daily statistics for a specific machine within a given date range and timezone. ```APIDOC ## GET /v1/home/machines//statistics/daily ### Description Retrieves daily statistics for a specific machine within a given date range and timezone. ### Method GET ### Endpoint `https://gw-lmz.lamarzocco.io/v1/home/machines//statistics/daily?startDate=2024-04-04T00:00:00.000000&endDate=2024-04-05T00:00:00.000000&timezoneOffset=-4&timezone=America/New_York` ### Parameters #### Path Parameters - **SN** (string) - Required - The serial number of the machine. #### Query Parameters - **startDate** (string) - Required - The start date in ISO 8601 format. - **endDate** (string) - Required - The end date in ISO 8601 format. - **timezoneOffset** (integer) - Required - The timezone offset in minutes. - **timezone** (string) - Required - The IANA timezone name. ### Response #### Success Response (200) - **data** (array) - List of daily statistics entries. - **count** (integer) - Total number of brews. - **doseA** (integer) - Count for dose A. - **doseB** (integer) - Count for dose B. - **doseC** (integer) - Count for dose C. - **doseD** (integer) - Count for dose D. - **doseTea** (integer) - Count for tea dose. - **doseContinous** (integer) - Count for continuous dose. - **flush** (integer) - Count for flush. - **date** (string) - The date in ISO 8601 format. - **timestamp** (integer) - The timestamp in milliseconds. - **status** (boolean) - Indicates if the request was successful. #### Response Example ```json { "data": [ { "count": 10, "doseA": 0, "doseB": 0, "doseC": 1, "doseD": 6, "doseTea": 0, "doseContinous": 1, "flush": 3, "date": "2024-04-04T00:00:00.000Z", "timestamp": 1712178000000 } ], "status": true } ``` ``` -------------------------------- ### GET /v1/home/machines//statistics/counters Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/remote_rest.md Retrieves the coffee counters for a specific machine, showing the count for each coffee type. ```APIDOC ## GET /v1/home/machines//statistics/counters ### Description Retrieves the coffee counters for a specific machine, showing the count for each coffee type. ### Method GET ### Endpoint `https://gw-lmz.lamarzocco.io/v1/home/machines//statistics/counters` ### Parameters #### Path Parameters - **SN** (string) - Required - The serial number of the machine. ### Response #### Success Response (200) - **data** (array) - List of counter entries. - **coffeeType** (integer) - The type of coffee (e.g., 0, 1, 2, 3, 4, -1). - **count** (integer) - The number of times that coffee type was brewed. - **status** (boolean) - Indicates if the request was successful. #### Response Example ```json { "data": [ { "coffeeType": 0, "count": 167 }, { "coffeeType": 1, "count": 0 }, { "coffeeType": 2, "count": 0 }, { "coffeeType": 3, "count": 0 }, { "coffeeType": 4, "count": 0 }, { "coffeeType": -1, "count": 228 } ], "status": true } ``` ``` -------------------------------- ### GET /v1/home/machines//status Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/remote_rest.md Retrieves the current status of the machine, including tank level, boiler settings, machine state, and temperatures. ```APIDOC ## GET /v1/home/machines//status ### Description Retrieves the current status of the machine, including tank level, boiler settings, machine state, and temperatures. ### Method GET ### Endpoint https://gw-lmz.lamarzocco.io/v1/home/machines//status ### Parameters #### Path Parameters - **SN** (string) - Required - The serial number of the machine. ### Response #### Success Response (200) - **data** (object) - Status data. - **data.LEVEL_TANK** (boolean) - Indicates if the water tank is full. - **data.MACHINE_REMOTSETS** (object) - Remote settings. - **data.MACHINE_REMOTSETS.BACKFLUSH_ENABLE** (boolean) - Whether backflush is enabled. - **data.MACHINE_REMOTSETS.BOILER_ENABLE** (boolean) - Whether boiler is enabled. - **data.MACHINE_REMOTSETS.PLUMBIN_ENABLE** (boolean) - Whether plumb-in is enabled. - **data.MACHINE_STATUS** (string) - Machine state (e.g., "ON"). - **data.TEMP_COFFEE** (number) - Coffee temperature in Celsius. - **data.TEMP_STEAM** (number) - Steam temperature in Celsius. - **data.received** (string) - Timestamp of the status update. - **status** (boolean) - Indicates if the request was successful. #### Response Example { "data": { "LEVEL_TANK": true, "MACHINE_REMOTSETS": { "BACKFLUSH_ENABLE": false, "BOILER_ENABLE": true, "PLUMBIN_ENABLE": false }, "MACHINE_STATUS": "ON", "TEMP_COFFEE": 97, "TEMP_STEAM": 131, "received": "2023-01-23T11:04:46.431Z" }, "status": true } ``` -------------------------------- ### GET daily machine counters Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/remote_rest.md Retrieves daily coffee statistics for a specific machine within a defined date range and timezone. ```json { "data": [ { "count": 10, "doseA": 0, "doseB": 0, "doseC": 1, "doseD": 6, "doseTea": 0, "doseContinous": 1, "flush": 3, "date": "2024-04-04T00:00:00.000Z", "timestamp": 1712178000000 } ], "status": true } ``` -------------------------------- ### GET machine counters Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/remote_rest.md Retrieves the total coffee counters for a specific machine using the statistics/counters endpoint. ```json { "data": [ { "coffeeType": 0, "count": 167 }, { "coffeeType": 1, "count": 0 }, { "coffeeType": 2, "count": 0 }, { "coffeeType": 3, "count": 0 }, { "coffeeType": 4, "count": 0 }, { "coffeeType": -1, "count": 228 } ], "status": true } ``` -------------------------------- ### Initialize LaMarzoccoBluetoothClient with discovered device and token Source: https://github.com/zweckj/pylamarzocco/blob/main/README.md After obtaining the token, discover Bluetooth devices and initialize the client with the first device and the token. ```python from pylamarzocco import LaMarzoccoBluetoothClient # Discover available bluetooth devices if bluetooth_devices := await LaMarzoccoBluetoothClient.discover_devices(): print("Found bluetooth device:", bluetooth_devices[0]) bluetooth_client = LaMarzoccoBluetoothClient( ble_device=bluetooth_devices[0], ble_token=ble_token, # Use the token from any of the three methods above ) ``` -------------------------------- ### Initialize LaMarzoccoMachine with serial number and clients Source: https://github.com/zweckj/pylamarzocco/blob/main/README.md Create a LaMarzoccoMachine instance by providing the machine's serial number and at least one client. The bluetooth_client is optional. ```python from pylamarzocco import LaMarzoccoMachine machine = LaMarzoccoMachine( serial_number=serial_number, cloud_client=cloud_client, bluetooth_client=bluetooth_client, # Optional ) ``` -------------------------------- ### Initiate connection Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/websockets.md Establishes a WebSocket connection to the machine's streaming API using an authorization token. ```APIDOC ## WebSocket Connection ### Description Initiates a WebSocket connection to the machine's streaming API. ### Endpoint ws://IP:8081/api/v1/streaming ### Headers - **Authorization** (string) - Required - Bearer token for authentication ### Connection Example ``` ws://IP:8081/api/v1/streaming -H ``` -------------------------------- ### Connect to Bluetooth Shot Counter with Callbacks Source: https://github.com/zweckj/pylamarzocco/blob/main/README.md Use this to connect to the Bluetooth shot counter and receive real-time brewing updates and telemetry. Requires a machine with shot counter firmware and a valid Bluetooth token. The callbacks are invoked on brewing updates and telemetry notifications. ```python from pylamarzocco.models import BluetoothMachineTelemetry, BluetoothShotCounterUpdate def on_shot(update: BluetoothShotCounterUpdate | None): """Called on every brewing update, and with None when Bluetooth disconnects.""" if update is not None: print(update.state, update.timer_value, update.brewing_start_time) def on_telemetry(telemetry: BluetoothMachineTelemetry): """Called with the values of each telemetry notification.""" print(telemetry.steam_boiler_temperature, telemetry.machine_mode) await machine.get_dashboard() # or get_dashboard_from_bluetooth() if await machine.connect_bluetooth_shot_counter(on_shot, on_telemetry): ... # machine.dashboard is now updated in real time # Later. This doesn't call the callbacks, refresh afterwards if needed. await machine.disconnect_bluetooth_shot_counter() ``` -------------------------------- ### get_settings Source: https://github.com/zweckj/pylamarzocco/blob/main/README.md Retrieves machine settings from the machine. ```APIDOC ## get_settings ### Description Retrieves machine settings from the machine. ### Method async ### Endpoint machine.get_settings() ### Parameters None ### Request Example ```python await machine.get_settings() ``` ### Response Returns machine settings. ``` -------------------------------- ### set_steam Source: https://github.com/zweckj/pylamarzocco/blob/main/README.md Enables or disables steam. ```APIDOC ## set_steam ### Description Enables or disables steam. ### Method async ### Endpoint machine.set_steam(steam) ### Parameters - **steam** (bool) - Required - True to enable steam, False to disable. ### Request Example ```python await machine.set_steam(True) # Enable steam await machine.set_steam(False) # Disable steam ``` ### Response No explicit response documented. ``` -------------------------------- ### get_firmware Source: https://github.com/zweckj/pylamarzocco/blob/main/README.md Retrieves firmware information from the machine. ```APIDOC ## get_firmware ### Description Retrieves firmware information from the machine. ### Method async ### Endpoint machine.get_firmware() ### Parameters None ### Request Example ```python await machine.get_firmware() ``` ### Response Returns firmware information. ``` -------------------------------- ### Retrieve Bluetooth token via LaMarzoccoCloudClient Source: https://github.com/zweckj/pylamarzocco/blob/main/README.md Use this method if you have cloud credentials. Initialize the cloud client, list machines, and read the ble_auth_token field from the first machine. ```python from pylamarzocco import LaMarzoccoCloudClient # Initialize and authenticate with the cloud client cloud_client = LaMarzoccoCloudClient( username=username, password=password, installation_key=installation_key, client=session, ) # Get all machines associated with your account things = await cloud_client.list_things() # The token is available in the ble_auth_token field ble_token = things[0].ble_auth_token ``` -------------------------------- ### set_power Source: https://github.com/zweckj/pylamarzocco/blob/main/README.md Turns the machine on or off. ```APIDOC ## set_power ### Description Turns the machine on or off. ### Method async ### Endpoint machine.set_power(power) ### Parameters - **power** (bool) - Required - True to turn on, False to turn off. ### Request Example ```python await machine.set_power(True) # Turn on await machine.set_power(False) # Turn off ``` ### Response No explicit response documented. ``` -------------------------------- ### Initiate connection Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/websockets.md The endpoint for establishing a websocket connection, requiring an Authorization header with a Bearer token. ```text ws://IP:8081/api/v1/streaming -H "Authorization: Bearer " ``` -------------------------------- ### LaMarzoccoMachine Source: https://github.com/zweckj/pylamarzocco/blob/main/README.md Initializes a LaMarzoccoMachine object with the given serial number and clients. ```APIDOC ## LaMarzoccoMachine ### Description Initializes a LaMarzoccoMachine object with the given serial number and clients. ### Method Constructor ### Endpoint LaMarzoccoMachine(serial_number, cloud_client, bluetooth_client) ### Parameters - **serial_number** (string) - Required - The serial number of the machine. - **cloud_client** (object) - Required - The cloud client instance. - **bluetooth_client** (object) - Optional - The Bluetooth client instance. ### Request Example ```python from pylamarzocco import LaMarzoccoMachine machine = LaMarzoccoMachine( serial_number=serial_number, cloud_client=cloud_client, bluetooth_client=bluetooth_client, # Optional ) ``` ### Response Returns a LaMarzoccoMachine instance. ``` -------------------------------- ### to_dict Source: https://github.com/zweckj/pylamarzocco/blob/main/README.md Returns machine data as a dictionary. ```APIDOC ## to_dict ### Description Returns machine data as a dictionary. ### Method sync ### Endpoint machine.to_dict() ### Parameters None ### Request Example ```python machine_data = machine.to_dict() ``` ### Response Returns a dictionary containing machine data. ``` -------------------------------- ### Wake up Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/websockets.md JSON message indicating the machine has been woken up manually. ```json [ { "WakeUp": "manual" } ] ``` -------------------------------- ### get_schedule Source: https://github.com/zweckj/pylamarzocco/blob/main/README.md Retrieves schedule settings from the machine. ```APIDOC ## get_schedule ### Description Retrieves schedule settings from the machine. ### Method async ### Endpoint machine.get_schedule() ### Parameters None ### Request Example ```python await machine.get_schedule() ``` ### Response Returns schedule settings. ``` -------------------------------- ### POST /things/{serial}/command/{commandString} Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/cloud_commands.md Send a cloud command to a La Marzocco machine. The command string and payload vary by command type. This endpoint is used for all commands listed in the reference. ```APIDOC ## POST /things/{serial}/command/{commandString} ### Description Send a cloud command to a La Marzocco machine. The command string and payload vary by command type. This endpoint is used for all commands listed in the reference. ### Method POST ### Endpoint /things/{serial}/command/{commandString} ### Parameters #### Path Parameters - **serial** (string) - Required - The serial number of the machine. - **commandString** (string) - Required - The command string identifying the command to execute. ### Request Body The payload fields are at the top level of the JSON body. The fields depend on the command string. ### Response #### Success Response (200) No response body is documented. ### Commands #### CoffeeMachineChangeMode - **mode** (string) - Required - The mode to set. #### CoffeeMachineGroupChangeMode - **groupIndex** (int) - Required - The group index. - **mode** (string) - Required - The mode to set. #### CoffeeMachineSettingCoffeeBoilerEnabled - **boilerIndex** (int) - Required - The boiler index. - **enabled** (bool) - Required - Whether the boiler is enabled. #### CoffeeMachineSettingAutoFlushEnabled - **enabled** (bool) - Required - Whether auto flush is enabled. #### CoffeeMachineSettingSteamFlushEnabled - **enabled** (bool) - Required - Whether steam flush is enabled. #### CoffeeMachineSettingRinseFlushEnabled - **enabled** (bool) - Required - Whether rinse flush is enabled. #### CoffeeMachineSettingRinseFlushTime - **timeSeconds** (number) - Required - The rinse flush time in seconds. #### CoffeeMachineSettingCupWarmerEnabled - **enabled** (bool) - Required - Whether the cup warmer is enabled. #### CoffeeMachineSettingHotWaterDoseEnabled - **enabled** (bool) - Required - Whether hot water dose is enabled. #### CoffeeMachineSettingHotWaterDose - **doseIndex** (string) - Required - The dose index. - **dose** (number) - Required - The dose value. #### CoffeeMachineGroupDoseChangeMode - **groupIndex** (int) - Required - The group index. - **mode** (string) - Required - The mode to set. #### CoffeeMachineGroupDoseSettingDose - **groupIndex** (int) - Required - The group index. - **mode** (string) - Required - The mode. - **doseIndex** (string) - Required - The dose index. - **dose** (number) - Required - The dose value. #### CoffeeMachineGroupDoseSettingGroupBrewingPressure - **groupIndex** (int) - Required - The group index. - **pressure** (number) - Required - The brewing pressure. #### CoffeeMachineGroupDoseSettingContinuousDoseEnabled - **groupIndex** (int) - Required - The group index. - **rinseEnabled** (bool) - Required - Whether continuous dose is enabled. #### CoffeeMachineGroupDoseSettingContinuousDose - **groupIndex** (int) - Required - The group index. - **rinseSeconds** (number) - Required - The rinse seconds. #### CoffeeMachineGroupDoseSettingMirrorGroup1 - **groupIndex** (int) - Required - The group index. - **enabled** (bool) - Required - Whether mirror group 1 is enabled. #### CoffeeMachineSettingPlumbIn - **enabled** (bool) - Required - Whether plumb in is enabled. ### Notes - The commands `set_group_dose_mode`, `set_group_dose`, and `set_brewing_pressure` raise `OperationNotAvailable` for a dose mode outside the cluster currently active on the machine (`CMGroupDoses.availableModes`), once a dashboard has been fetched. ``` -------------------------------- ### Read Bluetooth token via LaMarzoccoBluetoothClient.read_token Source: https://github.com/zweckj/pylamarzocco/blob/main/README.md Use this method if you don't have cloud credentials. The machine must be in pairing mode. Discover devices, then read the token directly from the first device. ```python from pylamarzocco import LaMarzoccoBluetoothClient # Discover available bluetooth devices bluetooth_devices = await LaMarzoccoBluetoothClient.discover_devices() if bluetooth_devices: # Put your machine in pairing mode first! # Then read the token directly from the machine ble_token = await LaMarzoccoBluetoothClient.read_token(bluetooth_devices[0]) ``` -------------------------------- ### POST /v1/home/machines//enable-preinfusion Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/remote_rest.md Enables or disables preinfusion for a specific machine. ```APIDOC ## POST /v1/home/machines//enable-preinfusion ### Description Enables or disables preinfusion for a specific machine. ### Method POST ### Endpoint `https://gw-lmz.lamarzocco.io/v1/home/machines//enable-preinfusion` ### Parameters #### Path Parameters - **SN** (string) - Required - The serial number of the machine. #### Request Body - **mode** (string) - Required - The mode to set: "Enabled" or "Disabled". ### Request Example ```json { "mode": "Disabled" } ``` ``` -------------------------------- ### POST enable or disable preinfusion Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/remote_rest.md Configures the preinfusion mode to either Enabled or Disabled. ```json { "mode": "Disabled" // "Enabled" } ``` -------------------------------- ### set_coffee_target_temperature Source: https://github.com/zweckj/pylamarzocco/blob/main/README.md Sets the coffee target temperature. ```APIDOC ## set_coffee_target_temperature ### Description Sets the coffee target temperature. ### Method async ### Endpoint machine.set_coffee_target_temperature(temperature) ### Parameters - **temperature** (float) - Required - The target temperature in degrees Celsius. ### Request Example ```python await machine.set_coffee_target_temperature(93.0) ``` ### Response No explicit response documented. ``` -------------------------------- ### Brewing Update Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/websockets.md JSON structure providing real-time updates during a brewing process. ```json [ { "BrewingUpdateGroup1Time": 6.188 }, { "BrewingUpdateGroup1Ev": true }, { "BrewingUpdateGroup1Volume": 0 } ] ``` -------------------------------- ### Control LaMarzocco machine power, steam, temperature, and steam level Source: https://github.com/zweckj/pylamarzocco/blob/main/README.md Send commands to turn the machine on/off, enable/disable steam, set coffee target temperature, and set steam level. Steam level uses the SteamTargetLevel enum. ```python from pylamarzocco.const import SteamTargetLevel # Turn machine on/off await machine.set_power(True) # Turn on await machine.set_power(False) # Turn off # Control steam await machine.set_steam(True) # Enable steam await machine.set_steam(False) # Disable steam # Set coffee target temperature await machine.set_coffee_target_temperature(93.0) # Set steam level (1-3) await machine.set_steam_level(SteamTargetLevel.LEVEL_2) ``` -------------------------------- ### System Information Message Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/websockets.md JSON structure containing system-level details such as network interfaces, RAM usage, CPU load, and file storage status. ```json { "SystemInfo": "{\"network_interfaces\":[{\"name\":\"wlan0\",\"address\":\"192.168.x.x\",\"mac\":\"\",\"auth\":\"WPA2_WPA3_PSK\",\"channel\":11,\"rssi\":-61}],\"system_ram\":[{\"name\":\"internal\",\"free\":48671,\"allocated\":244116},{\"name\":\"external\",\"free\":4046327,\"allocated\":380152}],\"cpu\":{\"cpu0\":14,\"cpu1\":11},\"connections\":{\"ws\":21,\"ble\":17,\"mqtt\":10,\"wifi\":3},\"up_time\":228801,\"curr_time\":\"2023-07-10 06:03:50\",\"boot_reason\":\"ESP_RST_POWERON\",\"boot_count\":0,\"timezone\":2,\"fs\":{\"total\":4096000,\"used\":16384,\"files\":[{\"path\":\"/storage/auth\",\"size\":175},{\"path\":\"/storage/cert.crt\",\"size\":1224},{\"path\":\"/storage/log.txt\",\"size\":0},{\"path\":\"/storage/private.key\",\"size\":1675}]}}" } ``` -------------------------------- ### Dose snapshot Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/websockets.md JSON structure detailing the group capabilities and configured doses for the machine. ```json [ { "GroupCapabilities": "[{\"capabilities\":{\"groupType\":\"AV_Group\",\"groupNumber\":\"Group1\",\"boilerId\":\"CoffeeBoiler1\",\"hasScale\":false,\"hasFlowmeter\":true,\"numberOfDoses\":4},\"doses\":[{\"groupNumber\":\"Group1\",\"doseIndex\":\"DoseA\",\"doseType\":\"PulsesType\",\"stopTarget\":126},{\"groupNumber\":\"Group1\",\"doseIndex\":\"DoseB\",\"doseType\":\"PulsesType\",\"stopTarget\":130},{\"groupNumber\":\"Group1\",\"doseIndex\":\"DoseC\",\"doseType\":\"PulsesType\",\"stopTarget\":140},{\"groupNumber\":\"Group1\",\"doseIndex\":\"DoseD\",\"doseType\":\"PulsesType\",\"stopTarget\":77}],\"doseMode\":{\"groupNumber\":\"Group1\",\"brewingType\":\"PulsesType\"}}]" } ] ``` -------------------------------- ### POST /v1/home/machines//enable-boiler Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/remote_rest.md Enables or disables the steam boiler. ```APIDOC ## POST /v1/home/machines//enable-boiler ### Description Enables or disables the steam boiler. ### Method POST ### Endpoint `https://gw-lmz.lamarzocco.io/v1/home/machines//enable-boiler` ### Parameters #### Path Parameters - **SN** (string) - Required - The serial number of the machine. #### Request Body - **identitfier** (string) - Required - The boiler identifier. Value: "SteamBoiler". - **state** (boolean) - Required - The desired state: true to enable, false to disable. ### Request Example ```json { "identitfier": "SteamBoiler", "state": true } ``` ``` -------------------------------- ### Set Machine Power Status Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/remote_rest.md Use this POST request to set the machine status to ON or STANDBY. ```json { "status": "ON" // "STANDBY" } ``` -------------------------------- ### set_steam_level Source: https://github.com/zweckj/pylamarzocco/blob/main/README.md Sets the steam level (1-3). ```APIDOC ## set_steam_level ### Description Sets the steam level (1-3). ### Method async ### Endpoint machine.set_steam_level(level) ### Parameters - **level** (SteamTargetLevel) - Required - The steam level, e.g., SteamTargetLevel.LEVEL_2. ### Request Example ```python from pylamarzocco.const import SteamTargetLevel await machine.set_steam_level(SteamTargetLevel.LEVEL_2) ``` ### Response No explicit response documented. ``` -------------------------------- ### POST preinfusion settings Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/remote_rest.md Updates the preinfusion settings for a specific machine group and button. ```json { "button": "Continuous", "group": "Group1", "holdTimeMs": 2000, "wetTimeMs": 0 } ``` -------------------------------- ### get_dashboard Source: https://github.com/zweckj/pylamarzocco/blob/main/README.md Retrieves dashboard information from the machine. ```APIDOC ## get_dashboard ### Description Retrieves dashboard information from the machine. ### Method async ### Endpoint machine.get_dashboard() ### Parameters None ### Request Example ```python await machine.get_dashboard() ``` ### Response Returns dashboard information. ``` -------------------------------- ### connect_dashboard_websocket Source: https://github.com/zweckj/pylamarzocco/blob/main/README.md Connects to the dashboard WebSocket for real-time updates. ```APIDOC ## connect_dashboard_websocket ### Description Connects to the dashboard WebSocket for real-time updates. ### Method async ### Endpoint machine.connect_dashboard_websocket(callback) ### Parameters - **callback** (function) - Required - A callback function that receives a ThingDashboardWebsocketConfig object. ### Request Example ```python from pylamarzocco.models import ThingDashboardWebsocketConfig def callback(config: ThingDashboardWebsocketConfig): """Callback function for websocket updates.""" print(f"Received update: {config.to_dict()}") await machine.connect_dashboard_websocket(callback) ``` ### Response No explicit response documented. ``` -------------------------------- ### POST /v1/home/machines//setting-preinfusion Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/remote_rest.md Sets the preinfusion settings for a specific machine, including the button, group, hold time, and wet time. ```APIDOC ## POST /v1/home/machines//setting-preinfusion ### Description Sets the preinfusion settings for a specific machine, including the button, group, hold time, and wet time. ### Method POST ### Endpoint `https://gw-lmz.lamarzocco.io/v1/home/machines//setting-preinfusion` ### Parameters #### Path Parameters - **SN** (string) - Required - The serial number of the machine. #### Request Body - **button** (string) - Required - The button type (e.g., "Continuous"). - **group** (string) - Required - The group identifier (e.g., "Group1"). - **holdTimeMs** (integer) - Required - The hold time in milliseconds. - **wetTimeMs** (integer) - Required - The wet time in milliseconds. ### Request Example ```json { "button": "Continuous", "group": "Group1", "holdTimeMs": 2000, "wetTimeMs": 0 } ``` ``` -------------------------------- ### Enable Steam Boiler Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/remote_rest.md Use this POST request to enable or disable the steam boiler. ```json { "identitfier": "SteamBoiler", "state": True // False } ``` -------------------------------- ### POST /v1/home/machines//status Source: https://github.com/zweckj/pylamarzocco/blob/main/docs/legacy/remote_rest.md Sets the power status of the machine to ON or STANDBY. ```APIDOC ## POST /v1/home/machines//status ### Description Sets the power status of the machine to ON or STANDBY. ### Method POST ### Endpoint `https://gw-lmz.lamarzocco.io/v1/home/machines//status` ### Parameters #### Path Parameters - **SN** (string) - Required - The serial number of the machine. #### Request Body - **status** (string) - Required - The desired power status. Allowed values: "ON", "STANDBY". ### Request Example ```json { "status": "ON" } ``` ```