cremalink package
Cremalink: A Python library for interacting with De’Longhi coffee machines.
This top-level package exposes the primary user-facing classes and functions for easy access, including the main Client, the Device model, and factory functions for creating device instances.
- class cremalink.Client(token_path: str, *, logger: Logger | None = None)[source]
Bases:
objectClient for interacting with the Ayla IoT cloud platform. Manages authentication (access and refresh tokens) and device discovery.
- create_datapoint(dsn: str, name: str, value) dict[source]
Write one datapoint via the cloud channel — the app’s announce path.
Verified endpoint (
AylaProperty.createDatapointCloud/createDatapointEndpoint, Coffee Link 4.9.6; DECODED.md):POST apiv1/dsns/{dsn}/properties/{name}/datapoints.jsonwith{"datapoint": {"value": ...}}andx-ayla-source: Mobile. This is the channel that carriesdevice_connectedto the machine’s cloud uplink — independent of the LANlocal_regmodule, so it is the recovery lever when the LAN session is dead (research.md R17). Whether a wedged datapoint engine processes it is unverified — callers should treat it as a probe, not a fix.
- fetch_properties(dsn: str) dict[str, str | None][source]
Every datapoint of a device in ONE request —
{name: value}.This is the Coffee Link app’s property-store sync (
syncPropertiesfetch-all; research.md R11,captures/cloud_fetch.json). Values are the cloud’s last-published copies (protocol.md §13 staleness lesson) — fine for factory descriptors and menu order, not for a brew’s live recipe values.
- get_device(dsn: str, device_map_path: str | None = None)[source]
Retrieves a specific cloud device by its DSN.
- get_lan_config(dsn: str) dict[source]
Fetch LAN connectivity details for a device (FR-006).
Ported from
delonghi_coffee’sapi.get_lan_config— same Ayla platform, same account. Never raises just because LAN is disabled; returnslan_enabled: Falsewith the other fieldsNoneinstead (FR-008).
- get_serial_number(dsn: str) str | None[source]
Fetch the raw
d270_serialnumberproperty for a device.Used as an input to model detection (FR-004); returns
Noneif the property is absent rather than raising, so callers can safely fall through to the next detection tier.
- list_account_devices() list[dict][source]
Discover coffee-machine devices on the account (cloud-assisted onboarding).
Unlike
get_devices()(kept unchanged for backward compatibility), this re-fetches/devices.jsonand returns one enriched dict per coffee-machine device only — non-coffee appliances (e.g. a Pinguino A/C on the same account) are excluded, not just flagged (FR-002).
- class cremalink.Device(transport: DeviceTransport, dsn: str | None = None, model: str | None = None, nickname: str | None = None, ip: str | None = None, lan_key: str | None = None, scheme: str | None = None, is_online: bool | None = None, last_seen: str | None = None, firmware: str | None = None, serial: str | None = None, coffee_count: int | None = None, command_map: dict[str, ~typing.Any]=<factory>, property_map: dict[str, ~typing.Any]=<factory>, monitor_profile: MonitorProfile = <factory>, extra: dict[str, ~typing.Any]=<factory>, machine_profile: MachineProfile | None = None, n_profiles: int = 1, capabilities: dict[str, ~typing.Any]=<factory>, setting_levels: dict[str, int]=<factory>, statistics_source: str = 'native', statistics_datapoints: list[str] = <factory>, settings_datapoints: list[str] = <factory>, catalog_datapoints: list[str] = <factory>, monitor_bits: dict[str, list[str]]=<factory>, model_ref: dict[str, ~typing.Any]=<factory>, model_name: str | None = None, recipe_beverage_order: list[int] = <factory>, response_timeout: float = 8.0, response_poll: float = 0.25, write_confirm_seconds: float = 45.0, profile_poll_seconds: float = 30.0, app_id_refresh_seconds: float = 240.0, app_id_confirm_seconds: float = 10.0, app_id_confirm_poll: float = 3.0, app_id_confirm_own_seconds: float = 5.0, app_id_refresh_min_seconds: float = 60.0)[source]
Bases:
objectRepresents a coffee machine, providing methods to control and monitor it.
This class holds the device’s state (e.g., IP, model) and uses a DeviceTransport object to handle the actual communication. Device-specific capabilities are loaded from a “device map” file.
- transport
The transport object responsible for communication.
- monitor_profile
Configuration for parsing monitor data.
- PARAM_CURRENT_PROFILE: ClassVar[int] = 1006
Param behind striker
d286_mach_sett_profile— on striker it is the live selected-profile register (f2()asserts the envelope param id). On the Soul it answers0x95but does NOT track0xA9selections — verified 2026-10-25: display on profile 2 while the register still read 0. On non-striker it is only a boot-state hint, never truth (DECODED.md §335).
- app_id_confirm_own_seconds: float = 5.0
a machine that still holds it republishes nothing, so the wait only costs time (seen live: no answer within 10 s). Real confirmations took 3–5 s.
- Type:
Shorter wait when the cloud already shows our id
- app_id_confirm_seconds: float = 10.0
How long to wait for the machine to confirm a registration, and the spacing of the checks while waiting (the app checks once after a few seconds; a few spaced reads keep the request count low).
- app_id_refresh_min_seconds: float = 60.0
Inside the refresh window an explicit refresh frame is sent at most this often; every frame carrying our id extends the registration too (a command sent with an app’s id kept that registration alive).
- app_id_refresh_seconds: float = 240.0
App-id registration (
app_device_connected, striker machines): the machine drops a registration ~300 s after the last refresh, so a registration older than this is renewed instead of refreshed.
- bean_systems() list[BeanSystem][source]
Configured BeanAdapt slots with their user-assigned names.
Reads the republished
d25X_beansystem_Nblobs — the sameba f0frames the app’sU(index)/0xBAslot reads produce (protocol.md §11 — on LAN the answers republish thed25xproperties rather than answeringdata_response). Frame layout per DECODEDG0/loadBeanSystems: id @[4], name UTF-16BE @[5..44] zero-stripped, flag bytes before the CRC (01 01= configured+selected,00 00= empty slot — research.md R10). Unconfigured/undecodable slots are skipped.
- beverage_catalog(*, fetch_priority: bool = True) list[Beverage][source]
Brewable beverages for the selector, priority-ordered.
Built from the app’s model table (static — zero machine requests) filtered to the union of the profile’s drink-menu order and the command-map brew entries. The menu order costs one cached GET per profile; pass
fetch_priority=False(standby / startup) to use only what is already cached, falling back to command-map order. Labels are resolved by callers (command-mapname→Beverage.name→Beverage <id>).
- brew(beverage_id: int, recipe: bytes | None = None, profile_slot: int | None = None, accessory: int = 0, *, overrides: Mapping[int, int] | None = None, action: int | None = None, params: RecipeParams | None = None) Any[source]
Start brewing
beverage_id— optionally with param overrides.profile_slot=Noneresolves to the last 0xA9-acked profile (current_profile);recipe=Nonefetches the profile-scoped recipe bytes from the republisheda6f0property — both per the FR-001 coherence rule (frame names its profile, recipe must be that profile’s).do()uses the same live-recipe path, taking beverage id, action and trailer from the stored frame and falling back to the captured recipe when the machine does not republish one.overrides({param_id: raw_value}) is a one-off brew: the values are merged into the recipe TLVs and the machine’s stored recipe is untouched (the0x83PREPARE_BEVERAGEpath — noSAVE_BEVERAGEwrite; research.md R1–R2). Overrides are validated againstrecipe_params()bounds; management tags and params absent from the recipe are rejected (ValueError). Passingparams(a priorrecipe_params()result) skips the second machine read and builds the frame straight from itsvaluesmap. Bean-system beverages (0xC8–0xCD) sendaction | 0x80and read the selected bean’sbs_recipedatapoint (research.md R10).
- custom_recipe_names() dict[int, str][source]
Custom recipe names by beverage id, as the last cloud seed saw them.
- declared_catalog() RecipeCatalogue[source]
The advisory catalogue declared by the app’s model table.
Uses
model_ref.recipe_declaration(anappModelIdwhose table entry stands in for this model) or elsemodel_ref.appModelId. Empty when the table declares no recipes.
- do(drink_name: str) Any[source]
Executes a command by its friendly name (e.g., ‘espresso’).
Map entries are decoded fields, not captured frames:
power(standby/wake/session_refresh) builds viabuild_power.beverage_identries build viabuild_brew. With arecipe_datapointthe recipe is fetched live from the machine’s republished profile-scoped property (0xA6) and the brew fails closed if it is unavailable; entries without one use their storedrecipehex (models with no recipe catalogue), and a recipe-less stop frame uses the default recipe.Entries holding only a raw
commandhex are sent verbatim.
Built frames go through the session gate.
- Parameters:
drink_name – The name of the command to execute, as defined in the command_map.
- Returns:
The response from the transport.
- Raises:
ValueError – If the command name is not found in the device map.
ConnectionError – If no recipe is available for a brew entry.
- favorite_beverages(profile_slot: int | None = None) list[int] | None[source]
The profile’s favourite drinks in favourite order, or
None.Read from the cloud snapshot (
dNNN_favorite_priority_<p>, family0xAC) together with the catalogue seed — no machine request.Nonemeans unknown (no such datapoint, or no snapshot yet); an empty list means the profile has no favourites.
- firmware_info() dict[str, str][source]
Firmware versions — machine datapoint plus cloud module data.
machine: the machine’s own firmware (software_versiondatapoint, e.g.Striker_cb_demo 1.1.0 Oct 18 2022);wifi_moduleandwifi_module_updated_at: the Wi-Fi module’s firmware and when the cloud last updated it (cloud transport only). Keys whose value is unknown are left out.On LAN the datapoint lands in the server’s property store only after the machine republishes it, so a miss triggers one
request_propertyround-trip — verified: the Soul answers asoftware_versionGET with the same string the cloud mirrors (protocol.md §14.7, captures/lan_software_version.json). Cloud transports cannot request properties and read the store only.
- classmethod from_map(transport: DeviceTransport, device_map_path: str | None = None, *, event_logger: Logger | None = None, **kwargs) Device[source]
Factory method to create a Device instance with a loaded device map.
If device_map_path is not provided, it attempts to find one using the device’s model.
- Parameters:
transport – The communication transport to use.
device_map_path – Optional path to the device map JSON file.
**kwargs – Additional attributes to set on the Device instance.
- Returns:
A configured Device instance.
- get_commands() list[str][source]
Returns a list of all available command names from the device map.
- get_monitor() MonitorView[source]
Retrieves and parses monitoring data into a structured, human-readable view.
- Returns:
A MonitorView instance containing parsed status information.
- get_monitor_frame() MonitorFrame | None[source]
Decodes the raw monitor data into a MonitorFrame for low-level analysis.
- Returns:
A MonitorFrame if decoding is successful, otherwise None.
- get_monitor_snapshot() MonitorSnapshot[source]
Retrieves the latest raw monitoring data from the transport.
- get_profiles() list[ProfileSlot][source]
Read the occupied profile slots (
a4f0blobs, profile-scoped).The blobs are republished as
dNNN_profiles_*(Soul) ordNNN_profile_name*(striker/ECAM452 over the cloud, which has no response mailbox for the0xA4fallback).
- get_property(name: str) Any[source]
Fetches a single property by its alias or technical name.
- Parameters:
name – The alias or name of the property to fetch.
- Returns:
The value of the requested property.
- get_property_aliases() list[str][source]
Returns a list of all available property aliases from the device map.
- get_setting_bits(*, refresh: bool = True) dict[str, bool | None][source]
Read boolean bit settings as
{key: on/off}(param0x003F).Same read strategy as
get_settings(): republisheddNNN95-blobs first,0x95mailbox read for params without one. Capability-gated settings the map marks unsupported are omitted; unreadable params yieldNone— never a fabricatedFalse.refresh=Falseharvests only what is already in the property store — norequest_propertyGETs and no0x95fallback. Used by the HA coordinator’s tracking poll:get_settingsrefreshes the store first, then this reads param0x003Foff it without queuing a second GET round (protocol.md §14.11 — republisheddNNNis the WiFi read channel).
- get_settings(*, hints: Collection[str] | None = None, keys: Collection[str] | None = None) dict[str, int | None][source]
Read writable settings as
{key: raw_option_index}.Republished
dNNN95-blobs are read first; settings without a stored blob fall back to a0x95mailbox read. Capability- gated settings the map marks unsupported are omitted.hintsnarrows the re-requested datapoints to names containing one of the hint substrings (datapoint_hintsemantics) — the HA coordinator passes the entity-backed hints so the periodic refresh queues ~3 GETs instead of the full six (observed 2026-10-30: the full lane burst-starved interactive commands on the one-command-per-poll drain).keysnarrows the evaluated settings to the given map keys — entities refreshing a single setting pass their own key so sibling keys don’t each sink into a seconds-long0x95fallback.
- get_statistics() StatisticsReport[source]
Fetch the machine’s usage statistics.
statistics_source == "native"maps page the0xA2table via the response mailbox;"cloud_counters"maps resolve logical counters against the transport’s property snapshot.
- machine_profile: MachineProfile | None = None
- model_name: str | None = None
Display name from the device map (
model_namekey) — e.g. “PrimaDonna Soul”.Nonefor maps that do not name the model.
- monitor_bits: dict[str, list[str]]
exclude(bits the model does not have) anddisabled_by_default(bits that may exist but are unverified). Empty = every documented bit applies.- Type:
Per-model monitor-bit policy from the device map
- monitor_profile: MonitorProfile
- profile_poll_seconds: float = 30.0
Min seconds between param-0x03EE current-profile reads — callers may hook this to a ~1 s monitor cycle, far too chatty for a register that only changes on a profile switch.
- read_catalog(*, settle: float = 0.5) RecipeCatalogue[source]
Build the recipe catalogue.
Machines that publish recipe datapoints are read per-name and parsed; maps without
catalog_datapoints(striker models) get the model-table declaration instead.
- recipe_params(beverage_id: int, *, profile_slot: int | None = None, catalog: RecipeCatalogue | None = None) RecipeParams[source]
Effective parameters + bounds for
(profile, beverage).Costs at most two machine reads and no catalogue sweep (protocol.md §13/§14.12, research.md R11): the recipe’s
0xB0bounds (one GET, cached for the process) and the profile’s live0xA6/bs_recipevalues. A fullcatalog(fromread_catalog()) may be supplied; itsa6f0profile records then serve as the values source. BeanAdapt beverages always live-readbs_recipe— the 6 bean slots share bev id0xC8. Falls back to0xB0defaults (or the command-map stored recipe) withsource="default"— never raises on a failed machine read.ValueErroronly for a beverage neither the model table nor the command map knows.
- recipe_priority_loaded(profile_slot: int | None = None) bool[source]
Whether the profile’s drink-menu order has been read already.
- refresh_current_profile(*, force: bool = False) int | None[source]
Refresh
current_profile— striker reads0x03EE, non-striker keeps the last-asserted profile.On striker the register is read back whenever it is stale. On non-striker the app never asks the machine for the profile —
0xA9is told-never-asked and0x03EEdoes not follow panel/app selects, so the read only seeds the initial state (whencurrent_profileis still 0/unknown) and can never overwrite a selection this process asserted or confirmed. Throttled toprofile_poll_seconds; the read runs under the session gate (§14.8).
- resolve_property(alias: str, default: str | None = None) str[source]
Translates a property alias to its technical name using the property_map.
- Parameters:
alias – The property alias to resolve.
default – A default value to return if the alias is not found.
- Returns:
The resolved technical name, or the alias/default if not found.
- seed_catalog_from_properties(properties: Mapping[str, Any]) int[source]
Fill the descriptor + menu-order caches from a bulk snapshot.
propertiesis{datapoint name: base64 value}— the cloudproperties.jsonfetch (the app’s one-shot store sync, research.md R11). Only this map’scatalog_datapointsare considered and only the slow-changing families are taken:0xB0factory descriptors and0xA8menu orders. Per-profile0xA6recipe values are deliberately NOT seeded — the cloud copy can be stale (protocol.md §13) and a stale value would brew the wrong amount; those stay a live read. Returns the number of descriptors seeded (0 → the caller keeps the lazy LAN path).
- select_bean_system(slot: int) bool[source]
Switch the BeanAdapt bean system (session-gated
0xB9).0xB9is on protocol.md §13’s untested write list — it goes through the same gated path as the verified0xA9profile select:device_connectedannounce (_send_gated) →0D 06 B9 F0 <slot>→ optional<ok>ack (h.m(ok=(b5==0)), DECODED dispatcher). Like0xA9on non-striker the app has no read-back for the select — a nack-free send counts as applied; an explicit nack returnsFalse.
- select_profile(index: int) bool[source]
Switch the active profile (session-gated
0xA9).Wakes a standby machine first. On striker a matching positive ack is required (the
a9ack path updatesEcamMachine.B). On non-striker the app treats0xA9as fire-and-retry — its connect storm sends it ~11× and the 2026-10-14 cloud capture shows zero acks, while the machine still applies the selection (DECODED.md “Current profile — never fetched on non-striker”). There is no machine-side read-back on Soul: after a nack-free send the asserted index becomes the truth, matching the app’sUserData.USER_PROFILE_SELECTEDmodel.
- selected_bean_slot() int | None[source]
The machine’s currently selected BeanAdapt slot (1–6).
Bean-name blobs (
d25X_beansystem_N,ba f0family) end with two flag bytes: captured values mark the configured+selected bean01 01(byte 49 = configured, byte 50 = selected) vs00 00empty slots (research.md R10). Returns the flagged slot, else the first configured one, else None.
- send_command(command: str) Any[source]
Encodes and sends a raw hex command to the device via the transport.
- Parameters:
command – The hex command string to send.
- Returns:
The response from the transport.
- send_frame(frame: bytes) Any[source]
Encode a protocol frame (timestamp + optional app-id trailer) and send it via the transport’s command channel.
- session_refresh() Any[source]
Refresh the write-gate session.
Non-striker machines re-announce
device_connected; striker machines send the84 0f 03 02refresh frame.
- set_setting(key: str, option_index: int) bool[source]
Write a writable setting (session-gated
0x90+ ack/read-back).Follows protocol.md §14.5:
device_connectedannounce (via_send_gated()) →0x90. §14.5 woke the machine for its test; by product decision this library never wakes it — configuration writes are attempted in standby as well: the machine processesdata_requestwhilein_standby(§14.8 —0xA2reads were answered there) and the official app exposes config changes in standby (only profile selection is gated). §14.5 confirmed the commits on the machine’s display and recorded no ack for them, so the ack is treated as optional: the write counts as committed when a read-back — mailbox answer or the republisheddNNNbacking property — shows the new value. An unconfirmed write is retried once with a fresh session announce — the machine rate-limits and drops frames under load (observed 2026-10-14).Returns
Truewhen the write is confirmed andFalsewhen the machine nacked it or reports a different value. RaisesValueErrorfor unknown keys/options andTimeoutErrorwhen neither an ack nor a read-back arrives.
- set_setting_bit(key: str, on: bool) bool[source]
Flip a boolean flag inside a shared param word (
0x90write).Reads the param’s current u32 first — the flag is merged so unrelated bits survive (the app’s
f0write does exactly this; protocol.md §14.8). Standby does not block configuration writes: the machine processesdata_requestwhilein_standbyand the app exposes these toggles there. An unreadable base value aborts withTimeoutError— a blind write could clobber other settings. ReturnsTrueon confirmed state,Falsewhen the machine reports a different value.
- setting_levels: dict[str, int]
How many levels of a writable setting the model offers (map key
setting_levels, e.g.{"temperature": 3}); unlisted settings offer theirdefault_levels(or every option).
- setting_options(key: str) dict[int, str][source]
The options of a writable setting this model offers (index -> label).
The map’s
setting_levelscaps how many levels count, like the app, which offers as many coffee temperatures as the machine reports in param 194 (three on the Eletta Explore, four on the Soul).
- transport: DeviceTransport
- write_confirm_seconds: float = 45.0
Post-write confirmation window — longer than
response_timeoutbecause the machine can commit0x90writes sluggishly under load (the app’s own re-read waits ~2 s; we budget generously and poll the republished property meanwhile). Over the cloud the republished value of a committed write took up to ~21 s to show (ECAM452), so a shorter window reported accepted writes as failed and resent them. A confirmed write still returns as soon as seen.
- class cremalink.EmbeddedLocalServer(dsn: str, device_ip: str, lan_key: str, device_map_path: str | None = None, *, advertised_ip: str | None = None, monitor_poll_interval: float = 5.0, nudger_poll_interval: float = 1.0, cloud_token_path: str | None = None, event_logger: Logger | None = None, preferred_port: int = 10280, port_fallback_range: int = 50, bind_host: str = '0.0.0.0')[source]
Bases:
objectIn-process host for a single device’s cremalink local LAN server.
See
specs/002-embedded-local-server/contracts/embedded-server-api.mdfor the full behavioral contract.- log(event: str, details: dict | None = None, *, level: int = 20) None[source]
Route an integration-owned event through this server’s log path.
- log_telemetry(event: str, details: dict, *, level: int = 20) None[source]
Forward telemetry through the HA logger without buffering it.
- set_machine_asleep(asleep: bool) None[source]
Tell the server jobs the machine’s sleep state.
The consumer (HA coordinator) knows the monitor status; in standby the monitor/nudger jobs drop to their standby cadence so a sleeping machine is not polled every few seconds.
- async start() None[source]
Resolve advertised IP + a free port, then start serving.
- Raises:
RuntimeError – if already starting/running.
OSError – if no port in the fallback range could be bound.
- class cremalink.LocalServer(settings: ServerSettings)[source]
Bases:
objectA wrapper class that encapsulates the aiohttp application runner.
- class cremalink.ServerSettings(_case_sensitive: bool | None = None, _nested_model_default_partial_update: bool | None = None, _env_prefix: str | None = None, _env_prefix_target: EnvPrefixTarget | None = None, _env_file: DotenvType | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_file_depth: int | None = None, _env_ignore_empty: bool | None = None, _env_nested_delimiter: str | None = None, _env_nested_max_split: int | None = None, _env_parse_none_str: str | None = None, _env_parse_enums: bool | None = None, _cli_prog_name: str | None = None, _cli_parse_args: bool | list[str] | tuple[str, ...] | None = None, _cli_settings_source: CliSettingsSource[Any] | None = None, _cli_parse_none_str: str | None = None, _cli_hide_none_type: bool | None = None, _cli_avoid_json: bool | None = None, _cli_enforce_required: bool | None = None, _cli_use_class_docs_for_groups: bool | None = None, _cli_show_env_vars: bool | None = None, _cli_exit_on_error: bool | None = None, _cli_prefix: str | None = None, _cli_flag_prefix_char: str | None = None, _cli_implicit_flags: bool | Literal['dual', 'toggle'] | None = None, _cli_ignore_unknown_args: bool | None = None, _cli_kebab_case: bool | Literal['all', 'no_enums'] | None = None, _cli_shortcuts: Mapping[str, str | list[str]] | None = None, _secrets_dir: PathType | None = None, _build_sources: tuple[tuple[PydanticBaseSettingsSource, ...], dict[str, Any]] | None = None, *, SERVER_SETTINGS_PATH: str = '', SERVER_IP: str = '127.0.0.1', SERVER_PORT: int = 10280, ADVERTISED_IP: str | None = None, NUDGER_POLL_INTERVAL: Annotated[float, Gt(gt=0)] = 1.0, MONITOR_POLL_INTERVAL: Annotated[float, Gt(gt=0)] = 5.0, MONITOR_POLL_INTERVAL_STANDBY: Annotated[float, Gt(gt=0)] = 30.0, NUDGER_POLL_INTERVAL_STANDBY: Annotated[float, Gt(gt=0)] = 30.0, NUDGER_RENUDGE_SECONDS: Annotated[float, Gt(gt=0)] = 10.0, COMMANDS_POLL_ACTIVE_SECONDS: Annotated[float, Gt(gt=0)] = 4.0, SESSION_KEEPALIVE_INTERVAL_SECONDS: float = 20.0, SESSION_PROBE_TIMEOUT_SECONDS: float = 4.0, SESSION_SILENCE_RESET_SECONDS: float = 900.0, SESSION_REGISTER_TIMEOUT_SECONDS: float = 5.0, CLOUD_TOKEN_PATH: str | None = None, CLOUD_WAKE_THRESHOLD: Annotated[int, Ge(ge=1)] = 3, CLOUD_WAKE_INTERVAL_SECONDS: Annotated[float, Gt(gt=0)] = 60.0, QUEUE_MAX_SIZE: int = 200, LOG_RING_SIZE: int = 200, DEVICE_REGISTER_VERIFY: bool = False, DEVICE_REGISTER_CA_PATH: str | None = None, DEVICE_REGISTER_TIMEOUT: float = 10.0, ENABLE_DEVICE_REGISTER: bool = True, ENABLE_NUDGER_JOB: bool = True, ENABLE_MONITOR_JOB: bool = True, ENABLE_SESSION_JOB: bool = True, FIXED_RANDOM_2: str | None = None, FIXED_TIME_2: str | None = None)[source]
Bases:
BaseSettingsDefines the application’s settings, which can be loaded from environment variables or a .env file. This provides a centralized and type-safe way to configure the server’s behavior.
- model_config = {'arbitrary_types_allowed': True, 'case_sensitive': False, 'cli_avoid_json': False, 'cli_enforce_required': False, 'cli_exit_on_error': True, 'cli_flag_prefix_char': '-', 'cli_hide_none_type': False, 'cli_ignore_unknown_args': False, 'cli_implicit_flags': False, 'cli_kebab_case': False, 'cli_parse_args': None, 'cli_parse_none_str': None, 'cli_prefix': '', 'cli_prog_name': None, 'cli_shortcuts': None, 'cli_show_env_vars': False, 'cli_use_class_docs_for_groups': False, 'enable_decoding': True, 'env_file': '.env', 'env_file_depth': 0, 'env_file_encoding': 'utf-8', 'env_ignore_empty': False, 'env_nested_delimiter': None, 'env_nested_max_split': None, 'env_parse_enums': None, 'env_parse_none_str': None, 'env_prefix': '', 'env_prefix_target': 'variable', 'extra': 'ignore', 'json_file': None, 'json_file_encoding': None, 'nested_model_default_partial_update': False, 'populate_by_name': True, 'protected_namespaces': ('model_validate', 'model_dump', 'settings_cached', 'settings_clear_cache', 'settings_customise_sources'), 'secrets_case_sensitive': None, 'secrets_dir': None, 'secrets_dir_max_size': None, 'secrets_dir_missing': None, 'secrets_nested_delimiter': None, 'secrets_nested_subdir': None, 'secrets_prefix': None, 'toml_file': None, 'validate_default': True, 'yaml_config_section': None, 'yaml_file': None, 'yaml_file_encoding': None}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- cremalink.authenticate_cloud(email: str, password: str, language: str = 'en') CloudToken[source]
Performs the multi-step authentication flow to obtain a refresh token for the Ayla IoT cloud platform.
This function executes the following steps: 1. Authorize: Initiates the authorization process to obtain a context parameter. 2. Get IDs: Retrieves necessary IDs (ucid, gmid, gmid_ticket) for the login process. 3. Login: Authenticates the user with their email and password, along with risk context information, to obtain a login token. 4. Get User Info: Fetches user information using the login token to obtain UID, UIDSignature, and signatureTimestamp. 5. Consent: Simulates the user consent process to obtain a signature for the authorization continue step. 6. Authorization Continue: Continues the authorization process using the context, login token, and consent signature to obtain an authorization code. 7. IDP Token: Exchanges the authorization code for an IDP token. 8. Exchange for Ayla: Uses the IDP token to sign in to the Ayla cloud and obtain a refresh token.
- Parameters:
- Returns:
An instance of CloudToken containing the obtained refresh token.
- Return type:
- cremalink.create_app(settings: ServerSettings | None = None, device_adapter: DeviceAdapter | None = None, logger=None) Application[source]
Application factory for the aiohttp server.
Initializes all components (state, settings, adapter, jobs) and wires up the API routes and startup/cleanup handlers.
- Returns:
A configured aiohttp Application instance.
- cremalink.create_cloud_device(dsn: str, access_token: str, device_map_path: str | None = None, event_logger: Logger | None = None, token_refresher: Callable[[], str] | None = None) Device[source]
Creates a Device instance configured for cloud-based communication.
This factory sets up a CloudTransport, which communicates with the device via the manufacturer’s cloud services, requiring an access token.
- Parameters:
dsn – The Device Serial Number.
access_token – The authentication token for the cloud service.
device_map_path – Optional path to a device-specific command map file.
- Returns:
A Device instance configured with a CloudTransport.
- cremalink.create_local_device(dsn: str, lan_key: str, device_ip: str | None, server_host: str, server_port: int = 10280, device_scheme: str = 'http', auto_configure: bool = True, device_map_path: str | None = None, event_logger: Logger | None = None) Device[source]
Creates a Device instance configured for local network communication.
This factory sets up a LocalTransport which requires details about the local network environment, including the device’s IP and the local server’s address.
- Parameters:
dsn – The Device Serial Number.
lan_key – The key for authenticating on the local network.
device_ip – The IP address of the coffee machine.
server_host – The hostname or IP address of the local proxy server.
server_port – The port of the local proxy server.
device_scheme – The communication protocol to use with the device (e.g., ‘http’).
auto_configure – If True, the transport will be configured automatically.
device_map_path – Optional path to a device-specific command map file.
- Returns:
A Device instance configured with a LocalTransport.
- cremalink.detect_model_id(raw_serial: str | None, cloud_metadata: dict[str, Any] | None, oem_model: str | None) str | None[source]
Resolve a discovered device to an existing cremalink device-map id.
- Parameters:
raw_serial – The device’s raw serial number string, if known.
cloud_metadata – Additional cloud-reported fields (e.g.
product_name,model), if any.oem_model – The Ayla
oem_model/modelidentifier, if known.
- Returns:
A valid cremalink device-map id, or
Noneif no detection tier yielded a recognized model. Never returns a guessed or default id.
- cremalink.device_map(model_id: str) str[source]
Finds the absolute path to a device map file for a given model ID.
This function handles packaged resources, extracting them to a temporary directory if they are not directly accessible on the filesystem.
- Parameters:
model_id – The model ID of the device.
- Returns:
The absolute path to the device map JSON file as a string.
- Raises:
DeviceMapNotFoundError – If the map for the given model ID doesn’t exist.
- cremalink.log_event(logger: Logger, event: str, details: dict | None = None, *, diagnostic_sensitive_values: tuple[str | None, ...] = (), operational_sensitive_values: tuple[str | None, ...] = (), level: int = 20, telemetry: bool = False) None[source]
Emit one record with separate operational and diagnostic details.
Subpackages
- cremalink.clients package
- cremalink.core package
- cremalink.crypto package
- cremalink.devices package
- cremalink.domain package
DeviceDevice.transportDevice.dsnDevice.modelDevice.nicknameDevice.ipDevice.lan_keyDevice.schemeDevice.is_onlineDevice.last_seenDevice.firmwareDevice.serialDevice.coffee_countDevice.command_mapDevice.property_mapDevice.monitor_profileDevice.extraDevice.PARAM_CURRENT_PROFILEDevice.app_id_confirm_own_secondsDevice.app_id_confirm_pollDevice.app_id_confirm_secondsDevice.app_id_refresh_min_secondsDevice.app_id_refresh_secondsDevice.bean_systems()Device.beverage_catalog()Device.brew()Device.brew_entry()Device.capabilitiesDevice.catalog_datapointsDevice.coffee_countDevice.command_mapDevice.configure()Device.current_profileDevice.custom_recipe_names()Device.declared_catalog()Device.do()Device.dsnDevice.extraDevice.favorite_beverages()Device.firmwareDevice.firmware_info()Device.from_map()Device.get_commands()Device.get_monitor()Device.get_monitor_frame()Device.get_monitor_snapshot()Device.get_profiles()Device.get_properties()Device.get_property()Device.get_property_aliases()Device.get_setting_bits()Device.get_settings()Device.get_statistics()Device.health()Device.ipDevice.is_onlineDevice.lan_keyDevice.last_seenDevice.machine_profileDevice.modelDevice.model_nameDevice.model_refDevice.monitor_bitsDevice.monitor_profileDevice.n_profilesDevice.nicknameDevice.profile_poll_secondsDevice.property_mapDevice.read_catalog()Device.recipe_beverage_orderDevice.recipe_params()Device.recipe_priority_loaded()Device.refresh_current_profile()Device.refresh_monitor()Device.resolve_property()Device.response_pollDevice.response_timeoutDevice.schemeDevice.seed_catalog_from_properties()Device.select_bean_system()Device.select_profile()Device.selected_bean_slot()Device.selected_profileDevice.send_command()Device.send_frame()Device.serialDevice.session_refresh()Device.set_setting()Device.set_setting_bit()Device.setting_levelsDevice.setting_options()Device.settings_datapointsDevice.standby()Device.statistics_datapointsDevice.statistics_sourceDevice.stop_brew()Device.transportDevice.wake()Device.write_confirm_seconds
create_cloud_device()create_local_device()detect_model_id()- Submodules
- cremalink.ecam package
BeverageBrewActionMachineProfilePowerCommandProfileSlotRecipeCatalogueSessionGateStatisticEntryStatisticsReportWritableSettinganswer_flag()answer_id()blob_family()brew_param_included()build_bean_system()build_brew()build_catalog()build_factory_descriptor()build_monitor_request()build_power()build_priority_list()build_profile_names()build_profile_select()build_read()build_read_block()build_read_param()build_read_params()build_recipe_names()build_recipe_values()build_statistics_page()build_striker_handshake()build_write_param()catalog_beverage_ids()counter_breakdown()decode_a2_page()decode_blob()encode_for_transport()fingerprint()interpret()is_sync_timeout()parse_a9_ack()parse_counter_value()parse_profile_names()parse_settings()parse_simple_ack()parse_tlv()parse_triples()parse_water_volume_liters()parse_write_ack()profile_from_map()resolve_cloud_breakdowns()resolve_cloud_counters()trim_frame()verify_frame()- Submodules
- cremalink.ecam.answers module
- cremalink.ecam.builder module
BREW_DROP_TAGSBrewActionDEFAULT_RECIPEPowerCommandREQUEST_NAMESbrew_param_included()build_bean_select()build_bean_system()build_brew()build_brew_params()build_factory_descriptor()build_handshake_blob()build_monitor_request()build_power()build_priority_list()build_profile_names()build_profile_select()build_read()build_read_block()build_read_param()build_read_params()build_recipe_names()build_recipe_values()build_statistics_page()build_striker_handshake()build_write_param()describe_request_frame()encode_for_transport()merge_recipe_params()trim_frame()verify_frame()
- cremalink.ecam.catalog module
- cremalink.ecam.machine_profiles module
- cremalink.ecam.monitor_bits module
- cremalink.ecam.params module
- cremalink.ecam.profiles module
- cremalink.ecam.session module
- cremalink.ecam.settings module
- cremalink.ecam.statistics module
- cremalink.local_server_app package
EmbeddedLocalServerEmbeddedLocalServer.advertised_ipEmbeddedLocalServer.bound_portEmbeddedLocalServer.event_loggerEmbeddedLocalServer.get_recent_events()EmbeddedLocalServer.log()EmbeddedLocalServer.log_telemetry()EmbeddedLocalServer.set_machine_asleep()EmbeddedLocalServer.start()EmbeddedLocalServer.stateEmbeddedLocalServer.stop()
ServerSettingsServerSettings.advertised_ipServerSettings.cloud_token_pathServerSettings.cloud_wake_interval_secondsServerSettings.cloud_wake_thresholdServerSettings.commands_poll_active_secondsServerSettings.device_register_ca_pathServerSettings.device_register_timeoutServerSettings.device_register_verifyServerSettings.enable_device_registerServerSettings.enable_monitor_jobServerSettings.enable_nudger_jobServerSettings.enable_session_jobServerSettings.fixed_random_2ServerSettings.fixed_time_2ServerSettings.log_ring_sizeServerSettings.model_configServerSettings.monitor_poll_intervalServerSettings.monitor_poll_interval_standbyServerSettings.nudger_poll_intervalServerSettings.nudger_poll_interval_standbyServerSettings.nudger_renudge_secondsServerSettings.queue_max_sizeServerSettings.server_ipServerSettings.server_portServerSettings.server_settings_pathServerSettings.session_keepalive_interval_secondsServerSettings.session_probe_timeout_secondsServerSettings.session_register_timeout_secondsServerSettings.session_silence_reset_seconds
create_app()- Submodules
- cremalink.local_server_app.api module
- cremalink.local_server_app.config module
- cremalink.local_server_app.device_adapter module
- cremalink.local_server_app.embedded module
- cremalink.local_server_app.jobs module
- cremalink.local_server_app.logging module
- cremalink.local_server_app.models module
- cremalink.local_server_app.protocol module
- cremalink.local_server_app.state module
- cremalink.parsing package
- cremalink.resources package
- cremalink.transports package