cremalink.transports.base module

This module defines the abstract base protocol for device communication transports.

class cremalink.transports.base.DeviceTransport(*args, **kwargs)[source]

Bases: Protocol

A protocol defining the standard interface for all device transports.

A transport is responsible for the low-level details of communicating with a coffee machine, whether it’s over a local network (HTTP) or via the cloud. This class uses typing.Protocol to allow for structural subtyping, meaning any class that implements these methods will be considered a valid transport.

configure() None[source]

Performs any necessary setup or configuration for the transport. This could include authentication, connection setup, etc.

get_monitor() Any[source]

Retrieves the current monitoring status data from the device.

Returns:

The raw monitoring data.

get_properties() Any[source]

Fetches a set of properties from the device.

Returns:

A collection of device properties.

get_property(name: str) Any[source]

Fetches a single, specific property from the device.

Parameters:

name – The name of the property to retrieve.

Returns:

The value of the requested property.

health() Any[source]

Performs a health check to verify connectivity with the device.

Returns:

A status indicating the health of the connection.

refresh_monitor() Any[source]

Requests the device to send an updated monitoring status.

send_command(command: str) Any[source]

Sends a command to the device.

Parameters:

command – The command payload to be sent.

Returns:

The response from the device, with the format depending on the transport implementation.

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

(Optional) Provides the transport with device-specific command and property maps.

This can be used by transports that need to perform lookups or translations.

Parameters:
  • command_map – A dictionary mapping command aliases to their details.

  • property_map – A dictionary mapping property aliases to their details.