Skip to main content

A Python implementation of the local La Marzocco API

Project description

lmdirect

Local API access to network-connected La Marzocco espresso machines

This is a prototype library for interacting with the local network API of a La Marzocco espresso machine. It's still in the beginning stages, but currently it's able to retrieve configuration and status information from the machine and turn it on/off. I've reverse-engineered this from decoding the network traffic between the mobile app and the machine, so it's incomplete, imperfect, and may have significant bugs. It works on my La Marzocco GS/3, but I can't guarantee that you'll have a similar experience with yours.

You take any and all risks from using this on your machine!

Preparation & Installation

Using this library is an advanced exercise. You'll need to do the following:

  • Find the client_id and client_secret for your machine by sniffing the network traffic while operating the mobile app (mitmproxy is good for this). You'll need to capture a token request to https://cms.lamarzocco.io/oauth/v2/token and find the client_id and client_secret in the request.
  • Find the username & password that you used to register with La Marzocco when you set up remote access. The username is most likely the email address that you used for registration.

Once you have the client ID, client secret, username, and passowrd, construct a file called config.json with these contents and put it in the directory along with test.py:

{
    "ip_addr": "ip_address",
    "client_id": "a_long_string",
    "client_secret": "another_long_string",
    "username": "email@address.com",
    "password": "password"
}

Running the test app

Now, run python test.py and you should get a prompt that looks like this:

1 = ON, 2 = OFF, 3 = Status, Other = quit:

You can hit 1 to turn the machine on, 2 to turn it off, 3 to dump a dict of all the config and status items that it's received from your machine, and any other key to quit. The app requests all status & config information every 5 seconds, so you should see the values change when the state of the machine changes.

The machine can only accept a single connection at a time, but the library keeps the connection open long enough only to send commands and receive the responses. Both the mobile app and this library will attempt to reconnect if the port is in use, but you may need to wait a bit while using the mobile app for it to try again.

Notes

So far, these are the commands that I’ve found:

  • A command that I call D8 that appears to request the same info that you get from the “status” cloud endpoint. This is a read starting with “R”, and has a preamble of 40000020.
  • A command that I call E9 that appears to request the same info that you get from the “configuration” cloud endpoint. This is a read starting with “R”, and has a preamble of 0000001F
  • A command that I call EB that requests the auto on/off schedule. This is a read starting with “R”, and has a preamble of 0310001D
  • A command that writes a value, and it starts with “W” and has a preamble of 00000001. I’ve only used this to turn the machine on and off so far, so there may be other preambles.

The responses have a matching “R” or “W” and mostly-matching preamble based on the command and these are the types that I’ve found and decoded (more or less):

  • A periodic short status broadcast that gives the current brew/steam boiler temps. I don’t need to send a command to get this - it may just be sent to whoever has an active socket connection. Preamble is 401C0004
  • A response to the D8 command with status info
  • A response to the E9 command with config info
  • A response to the EB command with the auto on/off schedule and what’s enabled
  • A “confirmation” response to a “write” command from the app (message to the machine starting with “W”). This includes the string “OK” if it succeeded.

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

lmdirect-0.2.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

lmdirect-0.2.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file lmdirect-0.2.0.tar.gz.

File metadata

  • Download URL: lmdirect-0.2.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

File hashes

Hashes for lmdirect-0.2.0.tar.gz
Algorithm Hash digest
SHA256 acc772eb4dd82744053e95c0404ae12c89d4bcc68dbdef02cc29ef7a8dfec5a9
MD5 0b142f7caee5d51142f539d6048b85ac
BLAKE2b-256 0e6566334c07059ad8b871bf9dd650dc7547c3a26b67818f7bf0fb09fad237a8

See more details on using hashes here.

File details

Details for the file lmdirect-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: lmdirect-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

File hashes

Hashes for lmdirect-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ea3c50d854f1fa25fc274ce799f0190e2eb524603b23535e026aa1b729ccc68
MD5 5b05e3394831f96af2723cb2494fbf8d
BLAKE2b-256 49ed0d2b06ce96774fc440127090cb802f4c333294afe2d26a26992a7984bf94

See more details on using hashes here.

Supported by

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