cremalink.domain.factory module

This module provides factory functions for creating Device instances.

These factories simplify the process of instantiating a Device by handling the setup of the appropriate communication transport (LocalTransport or CloudTransport) and the subsequent creation of the Device object itself.

cremalink.domain.factory.create_cloud_device(dsn: str, access_token: str, device_map_path: 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.domain.factory.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) 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.