# quangtrung89vp/lumentree architecture

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

- Interactive diagram: https://gitdiagram.com/quangtrung89vp/lumentree
- Repository: https://github.com/quangtrung89vp/lumentree

## Overview

Lumentree is a Home Assistant integration for monitoring hybrid solar inverters. The principal workflow is device-ID setup and authentication, followed by MQTT-based live telemetry and HTTP-based historical statistics, which Home Assistant exposes as sensor entities. Statistics also support cached historical backfill and user-triggered maintenance services. The supplied tree omits the referenced API, MQTT, aggregator, coordinator, cache, and entity implementation modules; those nodes and links are based on README claims or setup code, with paths left null where no source path is present.

Main entry points: [`__init__.py`](https://github.com/quangtrung89vp/lumentree/blob/main/__init__.py) (Integration setup), [`config_flow.py`](https://github.com/quangtrung89vp/lumentree/blob/main/config_flow.py) (Config flow), [`sensor (1).py`](https://github.com/quangtrung89vp/lumentree/blob/main/sensor%20(1).py) (Live sensors), [`const.py`](https://github.com/quangtrung89vp/lumentree/blob/main/const.py) (Integration constants)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Setup"]
  node_config["Config flow<br/>[config_flow.py]"]
  node_api["HTTP API client"]
  node_setup_runtime["Integration setup<br/>[__init__.py]"]
  node_device_api["Device API"]
  node_constants["Integration constants<br/>[const.py]"]
end

subgraph group_live["Live telemetry"]
  node_mqtt_client["MQTT client"]
  node_broker["Lumentree broker"]
  node_live_entities["Live sensors<br/>[sensor &#40;1&#41;.py]"]
  node_binary_entities["Status sensors<br/>[binary_sensor.py]"]
end

subgraph group_history["Statistics"]
  node_aggregator["Stats aggregator"]
  node_stats_api["Historical API"]
  node_disk_cache[("History cache")]
  node_coordinators["Stats coordinators"]
  node_stats_entities["Stats sensors"]
  node_services["Backfill services<br/>[__init__.py]"]
end

subgraph group_ha["Home Assistant"]
  node_ha_runtime["Home Assistant"]
  node_diagnostics["Diagnostics<br/>[diagnostics.py]"]
end

node_user(("Integrator"))
node_inverter(("Inverter"))

node_user -->|"starts setup"| node_config
node_config -->|"authenticates"| node_api
node_api -->|"requests device info"| node_device_api
node_config -->|"creates entry"| node_ha_runtime
node_ha_runtime -->|"sets up entry"| node_setup_runtime
node_setup_runtime -->|"fetches device info"| node_api
node_setup_runtime -->|"connects"| node_mqtt_client
node_mqtt_client -->|"subscribes"| node_broker
node_inverter -->|"publishes telemetry"| node_broker
node_broker -->|"delivers messages"| node_mqtt_client
node_mqtt_client -->|"dispatches updates"| node_live_entities
node_ha_runtime -->|"forwards platform"| node_live_entities
node_ha_runtime -->|"forwards platform"| node_binary_entities
node_setup_runtime -->|"creates"| node_aggregator
node_aggregator -->|"fetches history"| node_stats_api
node_aggregator -->|"reads and writes"| node_disk_cache
node_setup_runtime -->|"creates"| node_coordinators
node_coordinators -->|"requests statistics"| node_aggregator
node_ha_runtime -->|"forwards platform"| node_stats_entities
node_coordinators -->|"provides updates"| node_stats_entities
node_ha_runtime -->|"registers services"| node_services
node_services -->|"runs backfill"| node_aggregator
node_services -->|"maintains cache"| node_disk_cache
node_ha_runtime -->|"requests diagnostics"| node_diagnostics
node_setup_runtime -->|"uses settings"| node_constants

click node_config "https://github.com/quangtrung89vp/lumentree/blob/main/config_flow.py"
click node_setup_runtime "https://github.com/quangtrung89vp/lumentree/blob/main/__init__.py"
click node_live_entities "https://github.com/quangtrung89vp/lumentree/blob/main/sensor%20(1).py"
click node_binary_entities "https://github.com/quangtrung89vp/lumentree/blob/main/binary_sensor.py"
click node_services "https://github.com/quangtrung89vp/lumentree/blob/main/__init__.py"
click node_diagnostics "https://github.com/quangtrung89vp/lumentree/blob/main/diagnostics.py"
click node_constants "https://github.com/quangtrung89vp/lumentree/blob/main/const.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_api,node_setup_runtime,node_device_api,node_constants toneBlue
class node_mqtt_client,node_broker,node_live_entities,node_binary_entities toneAmber
class node_aggregator,node_stats_api,node_disk_cache,node_coordinators,node_stats_entities,node_services toneMint
class node_ha_runtime,node_diagnostics toneRose
class node_user,node_inverter toneIndigo
```

## Components

### Setup

- [Config flow](https://github.com/quangtrung89vp/lumentree/blob/main/config_flow.py): `config_flow.py`
- **HTTP API client**
- [Integration setup](https://github.com/quangtrung89vp/lumentree/blob/main/__init__.py): `__init__.py`
- **Device API**
- [Integration constants](https://github.com/quangtrung89vp/lumentree/blob/main/const.py): `const.py`

### Live telemetry

- **MQTT client**
- **Lumentree broker**
- [Live sensors](https://github.com/quangtrung89vp/lumentree/blob/main/sensor%20(1).py): `sensor (1).py`
- [Status sensors](https://github.com/quangtrung89vp/lumentree/blob/main/binary_sensor.py): `binary_sensor.py`

### Statistics

- **Stats aggregator**
- **Historical API**
- **History cache**
- **Stats coordinators**
- **Stats sensors**
- [Backfill services](https://github.com/quangtrung89vp/lumentree/blob/main/__init__.py): `__init__.py`

### Home Assistant

- **Home Assistant**
- [Diagnostics](https://github.com/quangtrung89vp/lumentree/blob/main/diagnostics.py): `diagnostics.py`

### Other components

- **Integrator**
- **Inverter**

## Connections

- Integrator → Config flow: starts setup
- Config flow → HTTP API client: authenticates
- HTTP API client → Device API: requests device info
- Config flow → Home Assistant: creates entry
- Home Assistant → Integration setup: sets up entry
- Integration setup → HTTP API client: fetches device info
- Integration setup → MQTT client: connects
- MQTT client → Lumentree broker: subscribes
- Inverter → Lumentree broker: publishes telemetry
- Lumentree broker → MQTT client: delivers messages
- MQTT client → Live sensors: dispatches updates
- Home Assistant → Live sensors: forwards platform
- Home Assistant → Status sensors: forwards platform
- Integration setup → Stats aggregator: creates
- Stats aggregator → Historical API: fetches history
- Stats aggregator → History cache: reads and writes
- Integration setup → Stats coordinators: creates
- Stats coordinators → Stats aggregator: requests statistics
- Home Assistant → Stats sensors: forwards platform
- Stats coordinators → Stats sensors: provides updates
- Home Assistant → Backfill services: registers services
- Backfill services → Stats aggregator: runs backfill
- Backfill services → History cache: maintains cache
- Home Assistant → Diagnostics: requests diagnostics
- Integration setup → Integration constants: uses settings
