Cloudflare Worker exposing a REST API for fetching status and stats from a La Marzocco machine.
One-click deploy with Cloudflare:
- Install dependencies.
npm install- Create KV namespaces.
wrangler kv namespace create lamarzocco- Create local config files (to avoid modifying tracked files).
cp .dev.vars.example .dev.vars
cp wrangler.toml wrangler.local.toml-
Update
wrangler.local.tomlwith your KV namespace ID. -
Set at least these local values in
.dev.vars:LM_EMAILandLM_PASSWORD. -
Start local development.
wrangler dev --config wrangler.local.toml- Set production secrets and deploy.
wrangler secret put LM_EMAIL
wrangler secret put LM_PASSWORD
wrangler deploy --config wrangler.local.toml| Method | Path | Description | Availability |
|---|---|---|---|
GET |
/stats |
Aggregated coffee/flush/backflush stats, recent espressos, and period totals. | Always |
GET |
/status |
Machine status widgets (state, doses, scale, image URL). | Always |
GET |
/openapi.json |
OpenAPI 3.0 schema for this worker. | ENABLE_SWAGGER=true |
GET |
/docs |
Swagger UI powered by /openapi.json. |
ENABLE_SWAGGER=true |
Key response data:
/stats: totals, recent espressos, last backflush timestamp, and 24h/7d/30d/60d/90d/365d totals./status: machine state, brew-by-weight doses, scale connectivity/battery, and machine image URL.
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
KV |
Binding (KV namespace) | Yes | None | Stores installation keys and auth token cache. |
LM_EMAIL |
Secret / env var | Yes | None | La Marzocco app email used for sign-in. |
LM_PASSWORD |
Secret / env var | Yes | None | La Marzocco app password used for sign-in. |
LM_MACHINE_ID |
Env var | No | Auto-select when possible | Machine serial number. Set this if your account has multiple machines. |
LM_TIMEZONE |
Env var | No | UTC |
IANA timezone used when calculating period windows. |
LM_LAST_COFFEE_DAYS |
Env var | No | 365 |
Number of days to fetch in the recent espresso list query. |
LM_INSTALLATION_ID |
Secret / env var | No | Auto-generated | Fixed installation ID. If unset, one is generated and cached in KV. |
LM_API_BASE |
Env var | No | https://lion.lamarzocco.io/api/customer-app |
Override API base URL. |
ENABLE_SWAGGER |
Env var | No | false |
Set to true to expose /docs and /openapi.json. |
| Command | Description |
|---|---|
npm run lint |
Run ESLint checks. |
npm run typecheck |
Run TypeScript type checking. |
npm test |
Run test suite. |
npm run deploy |
Deploy using tracked Wrangler config. |
wrangler deploy --config wrangler.local.toml |
Deploy with local, untracked config. |