La Marzocco GS/3 & Linea Mini support

Decoded some more parts around the heating and pump states. The commands are simply memory reads and writes with 16bit address and 16bit length, so I dumped the entire address space (some accessible, some not) and found an interesting tidbit. Starting at address 0x0100 is the following:

0100: 5A4753xxxxxxxxxxxx00000000000000 Machine Serial Number (ZGSxxxxxx)
0110: 00xxxxxxxxxxxxxxxx2Dxxxxxxxx2Dxx GUID (username)
0120: xxxxxx2Dxxxxxxxx2Dxxxxxxxxxxxxxx GUID (username)
0130: xxxxxxxxxx00xxxxxxxxxxxxxxxxxxxx GUID (username) / password
0140: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx00 password
0150: 6D717474733A2F2F636C6F75642D6D71 mqtts://cloud-mqtt.relayr.io
0160: 74742E72656C6179722E696F00000000 tt.relayr.io
0170: 0000000000FFFFFFFFFFFFFFFFFFFFFF

I can connect to the MQTT broker using the GUID as the username and the long string that follows as password @ port 8883, but it immediately disconnects. Changing the username or password fails initial authorization, so Iā€™m pretty sure those are correct. Iā€™ve tried using different client IDs (the GUID, machine serial number, Z + serial number (as in the memory dump), others) with no luck. I havenā€™t checked if the machine is actually connecting to this broker or not.

I added a couple of commands to the dev version of the test app to read arbitrary memory:

10 aaaallll issues a single ā€œreadā€ command, where aaaa is the 16-bit address to start at and llll is a 16-bit length. The machine wonā€™t return large chunks of data, so you have to read a bit at a time. An example is 10 0100001F, which reads the first 32 bytes of the memory region above

11 xx reads an entire 256byte block of memory, where xx is the upper 8-bits of an address range. An example is 11 00 to read and dump the first 256bytes of the memory space.

Thereā€™s a lot of repetition in the memory, some regions get no response at all, and some appear to echo back the command in the response data. Itā€™s weird. I found the memory region that represents the contents of the front display of my GS/3: STAND-BY 10 12p :slight_smile:

Lovelace support is coming along:

The top two are the existing water heater card: https://github.com/rsnodgrass/water-heater-card
The bottom one is based on the time-picker-card, with lots of customization: https://github.com/rccoleman/lovelace-lamarzocco-config-card

Itā€™s pretty close to having all the functionality that I would want at a glance. Anything you guys are looking for? I could do something similar for prebrew.

Edit:

Now with ā€œdoseā€ support, too!

Screen Shot 2021-01-29 at 9.30.28 AM

1 Like

Hey plonx, Would you be able to share more details on how you got your mini into HomeKit? Iā€™m pretty new to the home-assistant ecosystemā€¦ Any additional details you can share would be greatly appreciated!

Hi,

I just made an account so I could let youā€™ll know that I really like this project and what you guys are doing.
I donā€™t know anything about programming or coding, but I do have homebridge running for HomeKit. I miss the integration in HomeKit for my Linea Mini. Is that what youā€™re building or am I confusing things?
If there is something for me to contribute or test please let me know.

Michael de Waard

My goal here was to allow Home Assistant to see the current status of the machine and control it. With that done, you can then use HA automations, scripts, voice control, and Lovelace UI capabilities to interact with it. Since La Marzocco doesnā€™t provide a direct interface to HA or Alexa/GA, either using the high-level REST API that plonx mentioned or the integration that Iā€™ve developed can help bridge the gap. I could easily expose my GS3 as an Alexa device and turn it on or off by speaking to an Echo/Dot/etc., for instance.

I donā€™t personally use HomeKit, so perhaps plonx can describe what heā€™s done there.

Unfortunately, both methods require retrieving the client_id and client_secret thatā€™s used to communicate with the La Marzocco server, and thatā€™s not very user-friendly. I simplified the process as much as I could here, but I expect that itā€™ll be a significant stumbling block for ā€œnormalā€ users.

assuming you have a HomeKit hub (e.g. Apple TV, HomePod) hereā€™s a basic overview, let me know if you need more details on any of the steps!

  1. Install and set up home assistant
  2. Install and set up the La Marzocco integration
  3. Install and set up the HomeKit Bridge integration
  4. Add your HomeKit bridge to your HomeKit hub
  5. Add your La Marzocco device to the HomeKit bridge integration
1 Like

Has the integration been reliable for you? Some of the changes that Iā€™ve made recently are an attempt to make it more resilient to connection issues, but itā€™s been pretty solid for me.

Itā€™s rock solid for me. No issues.

1 Like

I updated the Lovelace card docs and will get it added to the default HACS list. For now, you can add the repo manually in HACS or install manually, as described in the instructions.

It needs at least v0.7.4 of the integration (released almost a week ago), so make sure thatā€™s installed before trying to use the card. One of the benefits of using the card is that itā€™s much, much faster than using the mobile app.

Edit: Updated the card again - it no longer requires an entity_id to be specified because it finds the right one automatically. It makes the card really easy to use with a config like this:

            - type: 'custom:lamarzocco-config-card'
              card_type: dose
              name: Dose

Itā€™s now possible to add and configure the card via the Lovelace UI ā€œ+ Add Cardā€ interface, and the card preview updates automatically as the config is changed.

Any thoughts on how the client Id & secret are provisioned to the app? Iā€™m no expert on this topic, but I thought these values would be issued to the app prior to distribution, and so be consistent for every user.

Iā€™ve wondered the same thing. Maybe theyā€™re identical for all users, or for an app family, or app version. It could also be calculated and provisioned during initial pairing. I havenā€™t tried repairing to check.

Here are the first 10 characters of my client_id: 4_2d2impyk
And client_secret: 1m52x65srm

Same as others?

From https://www.md5hashgenerator.com/

client_id: d3381eba71f5e247ff2c098c83b070e0
client_secret: 2893abd3fb176a124637a3d0d66c2bc6

Iā€™m using the latest version of the iOS app.

Havenā€™t checked yet - project for next weekend ;).

I guess - given that you can connect to multiple machines - that provisioning must happen either before distribution or on first run.

My client ID is the same as yours. I have a Linea Mini.

The client secret starts the same but differs. Hash is: be732024a32697788ee4d44b12f8ad21

Well, thatā€™sā€¦curious. I wonder if itā€™s based on the Bluetooth or Wifi MAC address, where the OUI would lend some similarity. It doesnā€™t look like any sort of hash that Iā€™m familiar with, and itā€™s not base64. I just rechecked my secret and I posted the correct hash for my value. If youā€™re comfortable with it, would you mind exchanging client_secret values via DM? Token access is still further protected with email/password, and Iā€™m really curious if itā€™s possible to decode it by analyzing the differences. If not, thatā€™s cool.

Iā€™m dying to know how the client_id and client_secret are encoded, and Iā€™ve been staring at them hoping for inspiration.

  • The ā€œ4_ā€ that starts the client_id seems to be some sort of preamble that isnā€™t matched in the client_secret
  • If you strip the ā€œ4_ā€ in the client_id, both strings are 50 characters, which is a weird length
  • Both appear to start with a character sequence with some variety, including numbers and letters that donā€™t appear in the latter portion of the string
  • Thatā€™s followed by a sequence with a very limited character set and what appears to be some small repetitive sequences
  • I intuitively broke it up in 12 characters followed by 38, but that may not be accurate or meaningful.
  • After the first sequence, the remaining sequence (38 or ?) characters are drawn from the same 9 characters in both strings: w, k, s, g, c, o, 0, 4, 8
  • The character frequency isnā€™t consistent between the two

With the limited character set, I canā€™t believe that this the output of any hash, encryption, or common encoding, but thereā€™s no obvious pattern that I can see.

I feel like the answer isā€¦rightā€¦thereā€¦

Just got around to checking this myself, client id is 4_2d2impykbv0g44oc88kogw000s8wgwwgws80ccowkcg0wk8o8w

client secret hash is
2893abd3fb176a124637a3d0d66c2bc6

Happy to DM the secret - canā€™t for the life of me figure out how tho.

I just messaged you.

Since @derekchoate and I have identical values, maybe it is based on the app. Iā€™m using the iOS version. Which are you using?

I donā€™t know why I didnā€™t think of this before, but I just downloaded the Android APK and the client_id and secret are sitting right in the Javascript in plaintext:

./assets/www/build/main.js:

CLIENT_ID:ā€œ4_2d2impykbv0g44oc88kogw000s8wgwwgws80ccowkcg0wk8o8wā€,CLIENT_SECRET:ā€œ1m52x65srmysk4owk0ww4ok84sw484ww0gsoo0kc0gs4gcwkkoā€

Thatā€™s the same secret that I retrieved via my iOS app, so Iā€™m curious why @mrvautin ended up with a different hash. Thereā€™s also a Google API key and a Mixpanel token in there.

Iā€™m tempted to just hardcode the client_id and client_secret in the integration now that it appears to be built into the app, but Iā€™d like to clear up why we donā€™t all see the same values first.

The only difference is that I have a Linea Mini and you have a GS3. Maybe thatā€™s it?