# jlopez77/deyeinverterha architecture

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

- Interactive diagram: https://gitdiagram.com/jlopez77/deyeinverterha
- Repository: https://github.com/jlopez77/deyeinverterha

## Overview

This is a Home Assistant custom integration for reading Deye hybrid-inverter metrics over Modbus TCP and exposing them as device-linked sensors. The main workflow is UI configuration and connection validation, periodic register acquisition, definition-driven parsing, then sensor publication. The graph also captures the legacy aggregate and installed-power production sensors, plus per-metric metadata for energy statistics and diagnostic statuses. Source excerpts show the runtime wiring; broader metric coverage and Energy dashboard use are documented in the README.

Main entry points: [`custom_components/deye_inverter/sensor.py`](https://github.com/jlopez77/deyeinverterha/blob/main/custom_components/deye_inverter/sensor.py) (Sensor platform), [`custom_components/deye_inverter/InverterData.py`](https://github.com/jlopez77/deyeinverterha/blob/main/custom_components/deye_inverter/InverterData.py) (Inverter client), [`custom_components/deye_inverter/coordinator.py`](https://github.com/jlopez77/deyeinverterha/blob/main/custom_components/deye_inverter/coordinator.py) (Update coordinator), [`custom_components/deye_inverter/config_flow.py`](https://github.com/jlopez77/deyeinverterha/blob/main/custom_components/deye_inverter/config_flow.py) (Config flow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Configuration"]
  node_config_flow["Config flow<br/>[config_flow.py]"]
  node_integration_setup["Entry setup<br/>[__init__.py]"]
end

subgraph group_acquisition["Data acquisition"]
  node_coordinator["Update coordinator<br/>[coordinator.py]"]
  node_modbus_client["Inverter client<br/>[InverterData.py]"]
end

subgraph group_interpretation["Metric interpretation"]
  node_parser["Register parser"]
  node_register_config["Register constants<br/>[const.py]"]
  node_metric_definitions["Metric definitions<br/>[DYRealTime.txt]"]
end

subgraph group_publication["Home Assistant sensors"]
  node_descriptions["Sensor descriptions"]
  node_sensor_platform["Sensor platform<br/>[sensor.py]"]
  node_sensor_entities["Inverter sensors<br/>[sensor.py]"]
end

node_user(("Integrator"))
node_ha_ui["Home Assistant UI"]
node_solarman["PySolarmanV5"]
node_inverter["Deye inverter"]
node_ha_entities["Home Assistant entities"]

node_user -->|"configures"| node_ha_ui
node_ha_ui -->|"starts setup"| node_config_flow
node_config_flow -->|"tests connection"| node_modbus_client
node_config_flow -.->|"creates entry"| node_integration_setup
node_integration_setup -->|"creates"| node_coordinator
node_coordinator -->|"fetches data"| node_modbus_client
node_modbus_client -->|"reads registers"| node_solarman
node_inverter -->|"serves Modbus"| node_modbus_client
node_modbus_client -->|"parses registers"| node_parser
node_parser -->|"uses blocks"| node_register_config
node_parser -->|"loads definitions"| node_metric_definitions
node_integration_setup -->|"forwards platform"| node_sensor_platform
node_sensor_platform -->|"gets coordinator"| node_coordinator
node_sensor_platform -->|"builds descriptions"| node_descriptions
node_descriptions -->|"derives metadata"| node_metric_definitions
node_descriptions -->|"checks read ranges"| node_register_config
node_sensor_platform -->|"creates entities"| node_sensor_entities
node_sensor_entities -->|"reads metrics"| node_coordinator
node_sensor_platform -->|"adds entities"| node_ha_entities

click node_config_flow "https://github.com/jlopez77/deyeinverterha/blob/main/custom_components/deye_inverter/config_flow.py"
click node_integration_setup "https://github.com/jlopez77/deyeinverterha/blob/main/custom_components/deye_inverter/__init__.py"
click node_coordinator "https://github.com/jlopez77/deyeinverterha/blob/main/custom_components/deye_inverter/coordinator.py"
click node_modbus_client "https://github.com/jlopez77/deyeinverterha/blob/main/custom_components/deye_inverter/InverterData.py"
click node_parser "https://github.com/jlopez77/deyeinverterha/blob/main/custom_components/deye_inverter/InverterDataParser.py"
click node_register_config "https://github.com/jlopez77/deyeinverterha/blob/main/custom_components/deye_inverter/const.py"
click node_metric_definitions "https://github.com/jlopez77/deyeinverterha/blob/main/custom_components/deye_inverter/DYRealTime.txt"
click node_descriptions "https://github.com/jlopez77/deyeinverterha/blob/main/custom_components/deye_inverter/entity_descriptions.py"
click node_sensor_platform "https://github.com/jlopez77/deyeinverterha/blob/main/custom_components/deye_inverter/sensor.py"
click node_sensor_entities "https://github.com/jlopez77/deyeinverterha/blob/main/custom_components/deye_inverter/sensor.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_flow,node_integration_setup,node_ha_ui toneBlue
class node_coordinator,node_modbus_client toneAmber
class node_parser,node_register_config,node_metric_definitions toneMint
class node_descriptions,node_sensor_platform,node_sensor_entities toneRose
class node_user,node_solarman,node_inverter,node_ha_entities toneIndigo
```

## Components

### Configuration

- [Config flow](https://github.com/jlopez77/deyeinverterha/blob/main/custom_components/deye_inverter/config_flow.py): `custom_components/deye_inverter/config_flow.py`
- [Entry setup](https://github.com/jlopez77/deyeinverterha/blob/main/custom_components/deye_inverter/__init__.py): `custom_components/deye_inverter/__init__.py`

### Data acquisition

- [Update coordinator](https://github.com/jlopez77/deyeinverterha/blob/main/custom_components/deye_inverter/coordinator.py): `custom_components/deye_inverter/coordinator.py`
- [Inverter client](https://github.com/jlopez77/deyeinverterha/blob/main/custom_components/deye_inverter/InverterData.py): `custom_components/deye_inverter/InverterData.py`

### Metric interpretation

- [Register parser](https://github.com/jlopez77/deyeinverterha/blob/main/custom_components/deye_inverter/InverterDataParser.py): `custom_components/deye_inverter/InverterDataParser.py`
- [Register constants](https://github.com/jlopez77/deyeinverterha/blob/main/custom_components/deye_inverter/const.py): `custom_components/deye_inverter/const.py`
- [Metric definitions](https://github.com/jlopez77/deyeinverterha/blob/main/custom_components/deye_inverter/DYRealTime.txt): `custom_components/deye_inverter/DYRealTime.txt`

### Home Assistant sensors

- [Sensor descriptions](https://github.com/jlopez77/deyeinverterha/blob/main/custom_components/deye_inverter/entity_descriptions.py): `custom_components/deye_inverter/entity_descriptions.py`
- [Sensor platform](https://github.com/jlopez77/deyeinverterha/blob/main/custom_components/deye_inverter/sensor.py): `custom_components/deye_inverter/sensor.py`
- [Inverter sensors](https://github.com/jlopez77/deyeinverterha/blob/main/custom_components/deye_inverter/sensor.py): `custom_components/deye_inverter/sensor.py`

### Other components

- **Integrator**
- **Home Assistant UI**
- **PySolarmanV5**
- **Deye inverter**
- **Home Assistant entities**

## Connections

- Integrator → Home Assistant UI: configures (evidence: `README.md`)
- Home Assistant UI → Config flow: starts setup (evidence: `README.md`)
- Config flow → Inverter client: tests connection (evidence: `custom_components/deye_inverter/config_flow.py`)
- Config flow → Entry setup: creates entry
- Entry setup → Update coordinator: creates (evidence: `custom_components/deye_inverter/__init__.py`)
- Update coordinator → Inverter client: fetches data (evidence: `custom_components/deye_inverter/coordinator.py`)
- Inverter client → PySolarmanV5: reads registers (evidence: `custom_components/deye_inverter/InverterData.py`)
- Deye inverter → Inverter client: serves Modbus (evidence: `README.md`)
- Inverter client → Register parser: parses registers (evidence: `custom_components/deye_inverter/InverterData.py`)
- Register parser → Register constants: uses blocks (evidence: `custom_components/deye_inverter/InverterDataParser.py`)
- Register parser → Metric definitions: loads definitions (evidence: `custom_components/deye_inverter/InverterDataParser.py`)
- Entry setup → Sensor platform: forwards platform (evidence: `custom_components/deye_inverter/__init__.py`)
- Sensor platform → Update coordinator: gets coordinator (evidence: `custom_components/deye_inverter/sensor.py`)
- Sensor platform → Sensor descriptions: builds descriptions (evidence: `custom_components/deye_inverter/sensor.py`)
- Sensor descriptions → Metric definitions: derives metadata (evidence: `custom_components/deye_inverter/entity_descriptions.py`)
- Sensor descriptions → Register constants: checks read ranges (evidence: `custom_components/deye_inverter/entity_descriptions.py`)
- Sensor platform → Inverter sensors: creates entities (evidence: `custom_components/deye_inverter/sensor.py`)
- Inverter sensors → Update coordinator: reads metrics (evidence: `custom_components/deye_inverter/sensor.py`)
- Sensor platform → Home Assistant entities: adds entities (evidence: `custom_components/deye_inverter/sensor.py`)
