# lodzen/cremalink-ha architecture

> Architecture diagram of the GitHub repository lodzen/cremalink-ha, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lodzen/cremalink-ha
- Repository: https://github.com/lodzen/cremalink-ha

## Overview

Cremalink HA bridges configured coffee machines into Home Assistant: users select a device map and local or cloud connection, the integration creates and configures a Cremalink device, then polls monitoring data and exposes sensors and controls. The README documents both local add-on and cloud modes. The integration source is sampled; the add-on implementation and Cremalink dependency are not, so their internal behavior is represented only as external services.

Main entry points: [`custom_components/cremalink_ha/__init__.py`](https://github.com/lodzen/cremalink-ha/blob/main/custom_components/cremalink_ha/__init__.py) (Integration setup), [`custom_components/cremalink_ha/coordinator.py`](https://github.com/lodzen/cremalink-ha/blob/main/custom_components/cremalink_ha/coordinator.py) (Polling coordinator), [`custom_components/cremalink_ha/config_flow.py`](https://github.com/lodzen/cremalink-ha/blob/main/custom_components/cremalink_ha/config_flow.py) (Configuration flow), [`custom_components/cremalink_ha/switch.py`](https://github.com/lodzen/cremalink-ha/blob/main/custom_components/cremalink_ha/switch.py) (Power switch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Setup and discovery"]
  node_config["Configuration flow<br/>[config_flow.py]"]
  node_maps["Device maps<br/>[config_flow.py]"]
end

subgraph group_connection["Device connectivity"]
  node_entry["Integration setup<br/>[__init__.py]"]
  node_cremalink["Cremalink library"]
  node_addon["Server add-on"]
  node_cloud["Cremalink cloud"]
end

subgraph group_runtime["Monitoring and control"]
  node_device["Configured device<br/>[__init__.py]"]
  node_coordinator["Polling coordinator<br/>[coordinator.py]"]
  node_sensors["Status entities<br/>[sensor.py]"]
  node_binary["Condition entities<br/>[binary_sensor.py]"]
  node_switch["Power switch<br/>[switch.py]"]
  node_buttons["Brew commands<br/>[button.py]"]
end

node_user(("Home Assistant user"))
node_machine["Coffee machine"]
node_ha(("Home Assistant"))

node_user -->|"configures"| node_config
node_config -->|"lists maps"| node_maps
node_config -->|"checks health"| node_addon
node_config -.->|"authenticates and discovers"| node_cloud
node_config -->|"creates entry"| node_entry
node_entry -->|"resolves map"| node_maps
node_entry -->|"creates and configures"| node_cremalink
node_cremalink -->|"connects locally"| node_addon
node_cremalink -.->|"connects to cloud"| node_cloud
node_addon -->|"bridges connection"| node_machine
node_cloud -.->|"provides device access"| node_machine
node_entry -->|"starts polling"| node_coordinator
node_coordinator -->|"gets monitor data"| node_device
node_entry -->|"forwards platform setup"| node_sensors
node_entry -->|"forwards platform setup"| node_binary
node_entry -->|"forwards platform setup"| node_switch
node_entry -->|"forwards platform setup"| node_buttons
node_sensors -->|"reads state"| node_coordinator
node_binary -->|"reads state"| node_coordinator
node_switch -->|"sends power command"| node_device
node_buttons -->|"sends brew command"| node_device
node_switch -->|"requests refresh"| node_coordinator
node_buttons -->|"requests refresh"| node_coordinator
node_sensors -->|"exposes readings"| node_ha
node_binary -->|"exposes conditions"| node_ha
node_switch -->|"exposes power control"| node_ha
node_buttons -->|"exposes commands"| node_ha

click node_config "https://github.com/lodzen/cremalink-ha/blob/main/custom_components/cremalink_ha/config_flow.py"
click node_maps "https://github.com/lodzen/cremalink-ha/blob/main/custom_components/cremalink_ha/config_flow.py"
click node_entry "https://github.com/lodzen/cremalink-ha/blob/main/custom_components/cremalink_ha/__init__.py"
click node_addon "https://github.com/lodzen/cremalink-ha/tree/main/addons/cremalink-server"
click node_device "https://github.com/lodzen/cremalink-ha/blob/main/custom_components/cremalink_ha/__init__.py"
click node_coordinator "https://github.com/lodzen/cremalink-ha/blob/main/custom_components/cremalink_ha/coordinator.py"
click node_sensors "https://github.com/lodzen/cremalink-ha/blob/main/custom_components/cremalink_ha/sensor.py"
click node_binary "https://github.com/lodzen/cremalink-ha/blob/main/custom_components/cremalink_ha/binary_sensor.py"
click node_switch "https://github.com/lodzen/cremalink-ha/blob/main/custom_components/cremalink_ha/switch.py"
click node_buttons "https://github.com/lodzen/cremalink-ha/blob/main/custom_components/cremalink_ha/button.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_config,node_maps,node_user toneBlue
class node_entry,node_cremalink,node_addon,node_cloud toneAmber
class node_device,node_coordinator,node_sensors,node_binary,node_switch,node_buttons toneMint
class node_machine,node_ha toneIndigo
```

## Components

### Setup and discovery

- [Configuration flow](https://github.com/lodzen/cremalink-ha/blob/main/custom_components/cremalink_ha/config_flow.py): `custom_components/cremalink_ha/config_flow.py`
- [Device maps](https://github.com/lodzen/cremalink-ha/blob/main/custom_components/cremalink_ha/config_flow.py): `custom_components/cremalink_ha/config_flow.py`

### Device connectivity

- [Integration setup](https://github.com/lodzen/cremalink-ha/blob/main/custom_components/cremalink_ha/__init__.py): `custom_components/cremalink_ha/__init__.py`
- **Cremalink library**
- [Server add-on](https://github.com/lodzen/cremalink-ha/tree/main/addons/cremalink-server): `addons/cremalink-server`
- **Cremalink cloud**

### Monitoring and control

- [Configured device](https://github.com/lodzen/cremalink-ha/blob/main/custom_components/cremalink_ha/__init__.py): `custom_components/cremalink_ha/__init__.py`
- [Polling coordinator](https://github.com/lodzen/cremalink-ha/blob/main/custom_components/cremalink_ha/coordinator.py): `custom_components/cremalink_ha/coordinator.py`
- [Status entities](https://github.com/lodzen/cremalink-ha/blob/main/custom_components/cremalink_ha/sensor.py): `custom_components/cremalink_ha/sensor.py`
- [Condition entities](https://github.com/lodzen/cremalink-ha/blob/main/custom_components/cremalink_ha/binary_sensor.py): `custom_components/cremalink_ha/binary_sensor.py`
- [Power switch](https://github.com/lodzen/cremalink-ha/blob/main/custom_components/cremalink_ha/switch.py): `custom_components/cremalink_ha/switch.py`
- [Brew commands](https://github.com/lodzen/cremalink-ha/blob/main/custom_components/cremalink_ha/button.py): `custom_components/cremalink_ha/button.py`

### Other components

- **Home Assistant user**
- **Coffee machine**
- **Home Assistant**

## Connections

- Home Assistant user → Configuration flow: configures
- Configuration flow → Device maps: lists maps
- Configuration flow → Server add-on: checks health
- Configuration flow → Cremalink cloud: authenticates and discovers
- Configuration flow → Integration setup: creates entry
- Integration setup → Device maps: resolves map
- Integration setup → Cremalink library: creates and configures
- Cremalink library → Server add-on: connects locally
- Cremalink library → Cremalink cloud: connects to cloud
- Server add-on → Coffee machine: bridges connection
- Cremalink cloud → Coffee machine: provides device access
- Integration setup → Polling coordinator: starts polling
- Polling coordinator → Configured device: gets monitor data
- Integration setup → Status entities: forwards platform setup
- Integration setup → Condition entities: forwards platform setup
- Integration setup → Power switch: forwards platform setup
- Integration setup → Brew commands: forwards platform setup
- Status entities → Polling coordinator: reads state
- Condition entities → Polling coordinator: reads state
- Power switch → Configured device: sends power command
- Brew commands → Configured device: sends brew command
- Power switch → Polling coordinator: requests refresh
- Brew commands → Polling coordinator: requests refresh
- Status entities → Home Assistant: exposes readings
- Condition entities → Home Assistant: exposes conditions
- Power switch → Home Assistant: exposes power control
- Brew commands → Home Assistant: exposes commands
