cremalink.clients package

This package provides high-level client interfaces for interacting with the cremalink system.

The Client class from the cloud module is exposed as the primary entry point for this package.

class cremalink.clients.Client(token_path: str, *, logger: Logger | None = None)[source]

Bases: object

Client 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.json with {"datapoint": {"value": ...}} and x-ayla-source: Mobile. This is the channel that carries device_connected to the machine’s cloud uplink — independent of the LAN local_reg module, 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 (syncProperties fetch-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.

Parameters:
  • dsn (str) – The Device Serial Number of the desired device.

  • device_map_path (str | None) – Optional path to a device-specific command map file.

Returns:

An instance of CloudDevice if found, otherwise None.

Return type:

CloudDevice | None

get_devices()[source]

Retrieves a list of Device Serial Numbers (DSNs) for all registered devices.

Returns:

A list of DSNs.

Return type:

list[str]

get_lan_config(dsn: str) → dict[source]

Fetch LAN connectivity details for a device (FR-006).

Ported from delonghi_coffee’s api.get_lan_config — same Ayla platform, same account. Never raises just because LAN is disabled; returns lan_enabled: False with the other fields None instead (FR-008).

get_serial_number(dsn: str) → str | None[source]

Fetch the raw d270_serialnumber property for a device.

Used as an input to model detection (FR-004); returns None if 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.json and 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).

Returns:

Each with dsn, product_name, oem_model, lan_enabled, connection_status.

Return type:

list[dict]

refresh_access_token() → str[source]

Fetch a new access token with the stored refresh token.

The refresh token rotates and is written back to token_path. Handed to cloud transports, which call it on HTTP 401.

Submodules