cremalink.ecam.catalog module
Machine recipe catalogue — parse the recipe-bearing blob families.
Ported from delonghi_coffeelink’s catalog.py (same authorial
grammar, pure Python — no HA, no I/O).
Every recipe-bearing datapoint is a self-describing binary blob:
d0 <len> <family 2B> [<profile 1B>] <bevid 1B> <TLV params…> <crc16>
The CRC is the same CRC16 AUG-CCITT the command builder uses, so a blob can be proved intact before anything is derived from it. Families:
family |
meaning |
|---|---|
|
factory descriptor — the capability schema (min/default/max) |
|
per-profile instance — the current value of each parameter |
|
a per-profile ordered short list of beverage ids |
|
profile names (UTF-16BE, user-entered) |
|
custom-recipe slot names |
|
bean-system names |
Rules that make it parseable without per-beverage special cases:
TLV: tags
0x01,0x09and0x0Fcarry a 16-bit big-endian value, every other tag carries 8 bits. In ab0f0descriptor the same tags carry a triple (min, default, max).Parse by family, never by property name. Datapoint numbering differs per model; the blob header is identical.
Deliberate refusals (a beverage that lies is worse than one missing):
A blob failing any gate (prefix, declared length, CRC) is unreadable, never absent.
A TLV walk leaving a trailing byte returns
None— a partial parse could build a wrong brew command, so the whole walk is refused.a8f0lists are per-profile recency orderings, NOT the brewable set.
- class cremalink.ecam.catalog.Beverage(bev_id: int, kind: str, declared: bool = False, ranges: dict = <factory>, profiles: dict = <factory>, in_priority_list: bool | None = None, priority_position: dict = <factory>, defined: bool | None = None, profiles_differ: bool = False, off_default: dict | None = None, source_properties: tuple = (), name: str | None = None, ingredients: tuple[int, ...]=(), use_for_custom: bool | None = None)[source]
Bases:
objectOne catalogue beverage.
- cremalink.ecam.catalog.CUSTOM_SLOT_IDS = frozenset({230, 231, 232, 233, 234, 235})
Beverage-id ranges that are not one of the built-in drinks.
- class cremalink.ecam.catalog.RecipeCatalogue(fingerprint: tuple, source: str, beverages: dict[int, ~cremalink.ecam.catalog.Beverage], priority_lists: dict[int, list[int]], names: dict[str, dict[int, str]], stats: dict, favorite_lists: dict[int, list[int]] = <factory>)[source]
Bases:
objectThe parsed recipe catalogue — advisory only; brew never depends on it.
- cremalink.ecam.catalog.TEXT_BLOB_FAMILIES = frozenset({b'\xa4\xf0', b'\xaa\xf0', b'\xba\xf0'})
Families carrying user-entered names — diagnostics redact their content.
- cremalink.ecam.catalog.WIDE_TAGS = frozenset({1, 9, 15})
TLV tags whose value is 16-bit big-endian; every other tag is 8-bit.
- cremalink.ecam.catalog.blob_family(value: Any) bytes | None[source]
The family bytes of a machine blob, read without decoding all of it.
- cremalink.ecam.catalog.build_catalog(properties: dict) RecipeCatalogue[source]
Build the machine’s beverage catalogue from property values.
- cremalink.ecam.catalog.build_declared_catalog(model: str | None) RecipeCatalogue[source]
Build an advisory catalogue from the app’s model table.
Carries what the table declares — beverage ids, names and the parameter ids each drink uses — and nothing the machine alone knows: no min/default/max ranges and no per-profile values. Use it when the machine publishes no recipe datapoints (striker models) or to cross-check a machine-built catalogue with
diff_declared().
- cremalink.ecam.catalog.catalog_beverage_ids(catalog: RecipeCatalogue | None) set[int][source]
Every beverage id the machine declared, whatever its kind.
- cremalink.ecam.catalog.decode_blob(value: Any) dict | None[source]
Classify one datapoint value as a machine blob, or
None.Three gates:
0xd0prefix, declared length, CRC. The length gate isdeclared <= len(raw): the machine appends a 4-byte timestamp to some datapoints, and strict equality misgrades those live channels as truncated.
- cremalink.ecam.catalog.decode_custom_names(payload: bytes) dict[int, str][source]
Slot → name from an
aa f0custom-recipe names payload.Layout (ECAM452 cloud
d053_custom_name_13/d054_custom_name_46):<first slot> <last slot>then per slot 20 bytes UTF-16BE name and one icon byte. Slots without a readable name are skipped.
- cremalink.ecam.catalog.decode_text(payload: bytes) str | None[source]
Decode the first UTF-16BE name in a text blob payload.
- cremalink.ecam.catalog.diff_declared(machine: RecipeCatalogue, declared: RecipeCatalogue) dict[source]
Compare a machine-built catalogue with the model-table declaration.
A non-empty result flags model-map drift (wrong
recipe_declarationor a firmware that changed the drink set) — not a catalogue failure.
- cremalink.ecam.catalog.fingerprint(properties: dict) tuple[source]
A change-detection key over catalogue datapoints, and only those.
- cremalink.ecam.catalog.iter_blobs(properties: dict) Iterator[tuple[str, dict]][source]
Yield
(property_name, decoded_blob)for every machine blob.Blobs inside a JSON bundle datapoint are yielded one by one as
<property_name>/<key>.
- cremalink.ecam.catalog.load_model_declaration(model: str | None) dict | None[source]
The app’s own recipe declaration for an
appModelId, orNone.Source:
MachinesModels.json(Coffee Link 4.9.6) — shipped asresources/model_recipes.jsonfor the Wi-Fi families only (PD_SOUL,PD_SOUL_BETTER,STRIKER_BEST).STRIKER_GOODdeclares no recipes in the table, so it has no entry.