> [!IMPORTANT]
> This is a community project and is not affiliated with or endorsed by La Marzocco.

# La Marzocco Round Controller

This repository contains a standalone ESP32-S3 firmware project for a round external La Marzocco controller.

The aim is a dedicated hardware controller with BLE/cloud control, an on-device UI, recipe presets, and a local setup portal with Wi-Fi firmware updates. It can also bridge supported BLE scales to a Linea Mini through an experimental controller-hosted scale adapter.

Recent changes are listed in the [changelog](CHANGELOG.md).

## Project status

The project is usable today, but it is still much closer to an actively developed community build than to a polished 1.0 release.

Today the strongest areas are:

- ESP32 controller bring-up on the targeted round hardware
- BLE control for the core day-to-day controller actions
- cloud-backed setup, machine selection, BLE/cloud fallback, and prebrewing management

## BLE scale support

The controller can connect to a physical BLE scale and present a compatible
virtual Acaia scale, normally `LUNAR-C`, to the machine. The adapter runs on the
ESP32 itself, so a phone app or a computer does not need to stay open to relay
measurements. Select the scale once in the local portal; the controller then
handles source reconnection and retries missing machine registrations.

| Scale | Driver | Current validation |
| --- | --- | --- |
| Legacy Mini-USB Acaia Lunar | `acaia_legacy` | Weight reception, the Mini scale link and one off/on reconnection tested on hardware; initialization and control-confirmation failures remain under investigation. |
| Acaia Lunar 2021 / USB-C, standard Acaia firmware | `acaia_2021` | Experimental; published BLE transport and commands covered by synthetic host tests. No hardware test yet. See the [Lunar 2021 beta guide](docs/controller/LUNAR_2021_BETA_TEST.md). |
| BOOKOO Mini | `bookoo_mini` | Experimental beta; protocol tests use synthetic fixtures, with no hardware validation yet. |
| BOOKOO Ultra | `bookoo_ultra` | Experimental beta; protocol tests use synthetic fixtures, with no hardware validation yet. |
| Other scales / other Acaia protocols | Additional driver required | The shared driver interface supports extending the adapter; each protocol needs implementation and hardware validation. |

The adapter translates tare/timer operations and forwards fresh weight and
battery data. A dimmed scale icon shows the physical-scale connection; full
brightness requires fresh readings and a subscribed machine scale link.
A small gold `∞`, `1` or `2` at the bright icon's lower-right corner shows the
selected BBW mode when that mode is known.
An optional persistent connection log records initialization and failures with
NTP timestamps for diagnosis without USB. BBW-capable machines also expose
mode and both dose targets in the controller UI and recipe presets.

Scale support is **experimental and disabled by default**. Persistent location
calibration and automatic weight-stop precision still need validation. The
current firmware has been installed and a fresh legacy Lunar/Mini scale link
verified. Longer reconnect and tare/timer regression tests remain pending.
The scale bridge depends on the machine's native BBW capability.

Start with the [scale setup and troubleshooting guide](docs/controller/SCALE_ADAPTER.md),
the [BOOKOO beta test guide](docs/controller/BOOKOO_BETA_TEST.md), or the
[firmware implementation notes](firmware/esp32/README.md#experimental-ble-scale-adapter).

## Firmware updates over Wi-Fi

Install a controller application `.bin` from **Firmware → Install Firmware**
in the local portal. The page shows upload progress, validates the image and
restarts the controller. An update uses the inactive firmware slot, retaining
the current image until validation finishes. Startup confirmation and rollback
allow a failed new image to return to the previous working version.

Existing controllers need a **one-time USB migration** before wireless updates
are available. The migration helper backs up the complete flash, preserves the
settings and log regions, and verifies them after writing. See the
[firmware update and migration guide](docs/controller/FIRMWARE_UPDATES.md).
The first migration and startup have been tested on hardware; an actual Wi-Fi
upload and rollback on the controller still need validation.

## Support development

If you want to help fund hardware testing, you can support the project here:
[PayPal.Me](https://paypal.me/kaspizzo)

Current scale testing focuses on reliable reconnects, persistent location
calibration, tare/timer behavior and Brew by Weight accuracy, including real
BOOKOO hardware coverage.

## What is in this repo

- `firmware/esp32/`
  ESP-IDF firmware for a JC3636K718-style round ESP32-S3 controller board.
- `docs/controller/`
  Flashing, setup, bring-up, and implementation notes for the controller hardware.

## Current controller capabilities

The current ESP32 firmware supports:

- round on-device UI on the `360x360` display
- default text header (`la marzocco`) instead of a bundled vendor logo
- switchable on-device controller language (`English` default, optional `Deutsch`)
- physical outer ring input
- local haptic and LED-ring feedback
- local Wi-Fi/cloud setup portal with Wi-Fi scan
- setup portal sections for overview, controller settings, network, cloud, recipes, scale adapter, advanced settings, firmware updates, and diagnostics
- firmware upload over Wi-Fi with progress, validation, restart and startup rollback after the one-time USB migration
- optional local SVG upload for a custom controller header logo
- setup AP QR code and captive-portal style onboarding
- machine selection via La Marzocco cloud account
- connectivity-aware status icons for BLE fallback versus cloud machine reachability
- conditional USB and low-battery/charging indicators on the on-device status bar
- an experimental BLE scale adapter with legacy Acaia Lunar, Lunar 2021 / USB-C beta and BOOKOO Mini/Ultra beta drivers
- separate dimmed/bright scale indicators for physical-scale and machine scale connections
- a gold `∞`, `1` or `2` beside the connected scale icon for the selected BBW mode
- opt-in persistent connection diagnostics with NTP time and portal download
- BLE control for:
  - coffee boiler temperature
  - steam boiler `Off / 1 / 2 / 3` level control from the controller screen
  - standby
- cloud-backed prebrewing mode and timing changes
- cloud-backed brew-by-weight mode and dose changes when the selected machine reports BBW support
- on-device recovery actions for `Clear web password` and `Reset network`
- periodic machine value refresh while the controller stays online
- recipe presets for:
  - coffee boiler temperature
  - prebrewing on-time
  - prebrewing off-time
  - brew-by-weight mode and dose targets when BBW is available

The currently targeted hardware is a JC3636K718-style ESP32-S3 round controller board with:

- ST77916 display
- CST816S touch
- outer rotary ring
- WS2812 LED ring
- DRV2605L haptics

## Controller screenshots

Representative controller UI screenshots are published as PNG files under `docs/controller/images/`.
The full gallery is in [`docs/controller/SCREENSHOTS.md`](docs/controller/SCREENSHOTS.md).
The published defaults intentionally show the text header, not an official La Marzocco logo.
The main examples below show the local fallback state with BLE active and a crossed Wi-Fi icon while the selected machine is not yet reachable through cloud. The gallery also includes connected scale and BBW-mode examples.

| Coffee Boiler | Presets | Setup |
| --- | --- | --- |
| ![Coffee Boiler screen](docs/controller/images/boiler.png) | ![Preset screen](docs/controller/images/preset-view.png) | ![Setup screen](docs/controller/images/first-setup.png) |

Local controller setup portal preview:

<img src="docs/controller/images/controller-setup-portal.png" alt="Local controller setup portal preview" width="720">

## Quick start

If you want to flash the controller:

1. Read the flashing guide in [`docs/controller/FLASHING_CONTROLLER.md`](docs/controller/FLASHING_CONTROLLER.md)
2. On macOS, the beginner-friendly walkthrough is [`docs/controller/FLASHING_CONTROLLER_MAC.md`](docs/controller/FLASHING_CONTROLLER_MAC.md)
3. Read the setup flow in [`docs/controller/SETUP_GUIDE.md`](docs/controller/SETUP_GUIDE.md)
4. For firmware-specific notes, see [`firmware/esp32/README.md`](firmware/esp32/README.md)
5. For scale selection, reconnect behavior and connection logging, see [`docs/controller/SCALE_ADAPTER.md`](docs/controller/SCALE_ADAPTER.md)
6. For controller UI screenshots, see [`docs/controller/SCREENSHOTS.md`](docs/controller/SCREENSHOTS.md)
7. For Wi-Fi firmware updates and the required one-time USB migration, see [`docs/controller/FIRMWARE_UPDATES.md`](docs/controller/FIRMWARE_UPDATES.md)

## Setup notes

- On first boot without stored Wi-Fi credentials, and again after a full factory reset, the controller opens `Setup` automatically and starts its own setup AP.
- In that state the setup screen shows a QR code for the controller AP plus the AP name, password, and local setup IP so onboarding can start directly on a phone.
- After home Wi-Fi is saved, the controller immediately tries to join that network. Once connected, the setup portal stays available again via the on-device setup gesture and the configured `http://<hostname>.local/` address.
- On later boots with stored Wi-Fi, the controller retries the saved network automatically. If the STA link drops repeatedly, reconnect uses exponential backoff and the setup AP is brought back as a recovery path while background retries continue.
- The browser setup portal is currently split into `Overview`, `Controller`, `Network`, `Cloud`, `Recipes`, `Scale Adapter`, `Advanced`, `Firmware`, and `Diagnostics`.
- A crossed Wi-Fi icon means the controller has account/network context but the selected machine is not currently reachable through cloud. BLE control can still stay active in that state.
- BBW mode and dose-target settings use the cloud. The scale adapter's measurement stream uses BLE between the physical scale, controller and machine. While the machine scale link is established, controller commands use cloud fallback because the normal owner BLE link is released.
- The cloud login path expects a direct La Marzocco account email/password. Accounts created only through Apple or Google sign-in are not expected to work with the current controller login flow.
- A possible workaround for Apple/Google-only accounts is to create a second La Marzocco account with a normal email/password login and grant that account access in the official app. Treat this as a best-effort workaround, not a guaranteed fix.
- Main gestures are: swipe down for `Presets`, swipe up for `Setup`, and long-press on the setup screen to open `Recovery` for `Clear web password` or `Reset network`.

## Security model and known limitations

- Firmware updates can be installed over Wi-Fi from the local portal after the
  one-time USB migration to the two-slot OTA layout. See the
  [firmware update and migration guide](docs/controller/FIRMWARE_UPDATES.md).
- The setup AP and captive portal are local onboarding/recovery tools, not hardened hostile-network services.
- The home-network portal assumes a trusted LAN unless you enable the optional portal admin password.
- If you deliberately keep the LAN portal open, anyone on that same LAN can use it to change controller settings.
- The captive DNS implementation is intentionally minimal and mainly exists to trigger common portal flows; some clients still need the manual fallback URL `http://192.168.4.1/`.
- Wi-Fi credentials, cloud credentials, machine binding, and related tokens are stored locally on the controller for normal operation.
- BBW configuration and controller commands while the machine scale link is established depend on cloud availability; scale communication itself uses local BLE.
- The project still targets a narrow JC3636K718-style hardware family rather than a broad controller matrix.

## Developer tools

Most desktop-side inspector tooling is maintained separately and is not part of this repository.
A small cloud-dashboard debug helper lives here for controller reverse-engineering:

- [`tools/debug/run_cloud_dashboard_debug.sh`](tools/debug/run_cloud_dashboard_debug.sh)
- [`docs/controller/CLOUD_DASHBOARD_DEBUG.md`](docs/controller/CLOUD_DASHBOARD_DEBUG.md)

These tools are useful if you want to:

- inspect cloud dashboard responses on a desktop machine
- inspect settings, statistics, schedule, and dashboard websocket responses
- bootstrap machine selection and BLE token retrieval
- expose a BMP controller screenshot route through the portal `Diagnostics` section
- compare controller behaviour with a Python-side reference client
- debug BLE/cloud behaviour outside the embedded firmware loop
- build a normalized inventory of which fields are already mapped to the controller and which are still unused

They are developer-facing utilities, not part of the end-user firmware.

## License

Unless stated otherwise, the source code and project documentation in this repository are licensed under Apache-2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE).

The firmware in this repository builds and flashes without any vendor package or proprietary board bundle.
Official La Marzocco logos are not bundled in the repository or used as shipped controller defaults. Compatibility is described textually, and any custom logo upload is user-provided and stored locally on the controller.

## Known limitations

- The controller firmware currently targets one specific round ESP32-S3 hardware family.
- BLE and cloud behaviour still depends on La Marzocco's app, machine firmware, and backend behaviour.
- The current cloud onboarding flow depends on a direct La Marzocco email/password login and does not provide a dedicated path for Apple/Google-created accounts.
- The setup flow and firmware have been exercised on a real device, but the project should still be treated as community firmware rather than an appliance-grade release.
- The repository includes developer tooling that is useful for debugging but not intended as polished end-user UX.

## Why this fork exists

The upstream `pylamarzocco` project already solved a large part of the protocol and behaviour work around La Marzocco cloud and BLE interactions. This repository extends that foundation into a dedicated hardware controller:

- adding a standalone ESP32 controller firmware
- adding local setup and machine pairing flows
- adapting control paths to a real round hardware device

## Acknowledgements

This repository builds directly on community work that came before it.

- The main upstream software foundation is [`zweckj/pylamarzocco`](https://github.com/zweckj/pylamarzocco)
- Early reverse-engineering context from the public community thread by Plonx and others was important for the broader La Marzocco connectivity work
- The controller firmware bring-up also benefited from vendor documentation and demo code for the JC3636K718 hardware family

See [`ACKNOWLEDGEMENTS.md`](ACKNOWLEDGEMENTS.md) for the fuller attribution note and [`PUBLISHING.md`](PUBLISHING.md) for the release checklist.
