cremalink.transports.local.transport module

This module provides the LocalTransport class, which handles communication with a coffee machine over the local network (LAN) via a proxy server.

class cremalink.transports.local.transport.LocalTransport(dsn: str, lan_key: str, device_ip: str | None, server_host: str = '127.0.0.1', server_port: int = 10280, device_scheme: str = 'http', auto_configure: bool = False, command_map: dict[str, Any] | None = None, property_map: dict[str, Any] | None = None)[source]

Bases: DeviceTransport

A transport for communicating with a device on the local network.

This transport does not connect to the device directly. Instead, it sends requests to a local proxy server (cremalink.local_server), which then forwards them to the coffee machine. This architecture simplifies direct device communication and authentication.

configure() → None[source]

Configures the local proxy server with the device’s connection details. This must be called before other methods can be used.

get_monitor() → Any[source]

Retrieves and parses the device’s monitoring data.

get_properties() → PropertiesSnapshot[source]

Retrieves all device properties from the local proxy server.

get_property(name: str) → Any[source]

Retrieves a single property value from the local proxy server.

The server-side lookup already covers both the bulk snapshot and the per-name datapoint store — no need for a /get_properties round-trip (which would also re-queue the bulk GET) per probe.

health() → str[source]

Checks the health of the local proxy server.

pop_response() → bytes | None[source]

Returns the oldest unconsumed data_response frame as raw bytes.

refresh_monitor() → None[source]

Requests a refresh of the monitoring data via the local proxy server.

request_property(name: str) → dict[str, Any][source]

Queues a GET for a single named datapoint on the device.

send_command(command: str, alternative_property: str | None = None) → dict[str, Any][source]

Sends a command to the device via the local proxy server.

alternative_property overrides the configured command datapoint (e.g. striker app_data_request); it is sent as a single-property write carrying the command string.

set_mappings(command_map: dict[str, Any], property_map: dict[str, Any]) → None[source]

Sets the command and property maps and re-configures the server if needed. If the name of the monitoring property changes, the server is reconfigured.

wait_datapoint(since: int, timeout: float) → int[source]

Blocks server-side until a datapoint lands after since.

Generation-counter wait — the caller re-harvests when the returned seq differs. Used instead of polling get_property into 404s while a republish is in flight (~5 s for recipes).

write_property(name: str, value: Any) → dict[str, Any][source]

Queues a single named property write on the device.