# bebbssos/ha-defa-power architecture

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

- Interactive diagram: https://gitdiagram.com/bebbssos/ha-defa-power
- Repository: https://github.com/bebbssos/ha-defa-power

## Overview

This is a Home Assistant integration for DEFA Power and eRange EV chargers. Users configure CloudCharge credentials, after which the integration discovers chargepoints and connectors, polls charger data, and exposes entities and actions for monitoring and control. The graph separates setup, data coordination, Home Assistant entities/actions, and the CloudCharge API. Several capabilities are documented in the README but their implementation details were not sampled; those branches are included without inventing internal call paths.

Main entry points: [`custom_components/defa_power/cloudcharge_api/client.py`](https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/cloudcharge_api/client.py) (API client), [`custom_components/defa_power/coordinator.py`](https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/coordinator.py) (Data coordinators), [`custom_components/defa_power/__init__.py`](https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/__init__.py) (Entry setup), [`custom_components/defa_power/services.py`](https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/services.py) (Services and schedules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Setup and runtime"]
  node_config["Configuration flow<br/>[config_flow.py]"]
  node_integration["Entry setup<br/>[__init__.py]"]
  node_runtime["Runtime data<br/>[models.py]"]
  node_devices["Device metadata<br/>[devices.py]"]
end

subgraph group_coordination["Charger data"]
  node_coordinators["Data coordinators<br/>[coordinator.py]"]
end

subgraph group_ha_features["Home Assistant features"]
  node_sensors["Sensors<br/>[sensor.py]"]
  node_binary_sensors["Binary sensors<br/>[binary_sensor.py]"]
  node_numbers["Current and eco controls<br/>[number.py]"]
  node_switches["Switch controls<br/>[switch.py]"]
  node_selects["Selection controls<br/>[select.py]"]
  node_buttons["Charger actions<br/>[button.py]"]
  node_services["Services and schedules<br/>[services.py]"]
  node_diagnostics["Diagnostics<br/>[diagnostics.py]"]
  node_anonymizer["ID anonymizer<br/>[id_anonymizer.py]"]
end

subgraph group_cloudcharge["CloudCharge API"]
  node_api_client["API client<br/>[client.py]"]
  node_api_models["API data models<br/>[models.py]"]
  node_api_errors["API exceptions<br/>[exceptions.py]"]
end

node_user(("Home Assistant user"))
node_ha(("Home Assistant"))
node_cloudcharge_service(("CloudCharge service"))

node_user -->|"configures"| node_config
node_ha -->|"loads entry"| node_integration
node_config -->|"authenticates"| node_api_client
node_integration -->|"creates client"| node_api_client
node_integration -->|"initializes"| node_coordinators
node_integration -->|"creates devices"| node_devices
node_integration -->|"stores runtime"| node_runtime
node_integration -->|"sets up services"| node_services
node_coordinators -->|"fetches data"| node_api_client
node_api_client -->|"sends requests"| node_cloudcharge_service
node_api_client -->|"uses typed data"| node_api_models
node_api_client -->|"raises errors"| node_api_errors
node_sensors -->|"reads updates"| node_coordinators
node_binary_sensors -->|"reads updates"| node_coordinators
node_numbers -->|"reads updates"| node_coordinators
node_numbers -->|"sets values"| node_api_client
node_switches -->|"reads updates"| node_coordinators
node_switches -->|"controls charger"| node_api_client
node_selects -->|"reads updates"| node_coordinators
node_selects -->|"sets options"| node_api_client
node_buttons -->|"refreshes data"| node_coordinators
node_buttons -->|"sends commands"| node_api_client
node_user -->|"invokes actions"| node_services
node_services -->|"controls charger"| node_api_client
node_services -->|"refreshes data"| node_coordinators
node_diagnostics -->|"anonymizes IDs"| node_anonymizer
node_diagnostics -->|"reports runtime"| node_runtime
node_api_client -->|"manages schedules"| node_cloudcharge_service

click node_config "https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/config_flow.py"
click node_integration "https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/__init__.py"
click node_runtime "https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/models.py"
click node_devices "https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/devices.py"
click node_coordinators "https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/coordinator.py"
click node_sensors "https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/sensor.py"
click node_binary_sensors "https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/binary_sensor.py"
click node_numbers "https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/number.py"
click node_switches "https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/switch.py"
click node_selects "https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/select.py"
click node_buttons "https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/button.py"
click node_services "https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/services.py"
click node_diagnostics "https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/diagnostics.py"
click node_anonymizer "https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/utils/id_anonymizer.py"
click node_api_client "https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/cloudcharge_api/client.py"
click node_api_models "https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/cloudcharge_api/models.py"
click node_api_errors "https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/cloudcharge_api/exceptions.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_integration,node_runtime,node_devices,node_user toneBlue
class node_coordinators toneAmber
class node_sensors,node_binary_sensors,node_numbers,node_switches,node_selects,node_buttons,node_services,node_diagnostics,node_anonymizer toneMint
class node_api_client,node_api_models,node_api_errors toneRose
class node_ha,node_cloudcharge_service toneIndigo
```

## Components

### Setup and runtime

- [Configuration flow](https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/config_flow.py): `custom_components/defa_power/config_flow.py`
- [Entry setup](https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/__init__.py): `custom_components/defa_power/__init__.py`
- [Runtime data](https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/models.py): `custom_components/defa_power/models.py`
- [Device metadata](https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/devices.py): `custom_components/defa_power/devices.py`

### Charger data

- [Data coordinators](https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/coordinator.py): `custom_components/defa_power/coordinator.py`

### Home Assistant features

- [Sensors](https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/sensor.py): `custom_components/defa_power/sensor.py`
- [Binary sensors](https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/binary_sensor.py): `custom_components/defa_power/binary_sensor.py`
- [Current and eco controls](https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/number.py): `custom_components/defa_power/number.py`
- [Switch controls](https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/switch.py): `custom_components/defa_power/switch.py`
- [Selection controls](https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/select.py): `custom_components/defa_power/select.py`
- [Charger actions](https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/button.py): `custom_components/defa_power/button.py`
- [Services and schedules](https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/services.py): `custom_components/defa_power/services.py`
- [Diagnostics](https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/diagnostics.py): `custom_components/defa_power/diagnostics.py`
- [ID anonymizer](https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/utils/id_anonymizer.py): `custom_components/defa_power/utils/id_anonymizer.py`

### CloudCharge API

- [API client](https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/cloudcharge_api/client.py): `custom_components/defa_power/cloudcharge_api/client.py`
- [API data models](https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/cloudcharge_api/models.py): `custom_components/defa_power/cloudcharge_api/models.py`
- [API exceptions](https://github.com/bebbssos/ha-defa-power/blob/main/custom_components/defa_power/cloudcharge_api/exceptions.py): `custom_components/defa_power/cloudcharge_api/exceptions.py`

### Other components

- **Home Assistant user**
- **Home Assistant**
- **CloudCharge service**

## Connections

- Home Assistant user → Configuration flow: configures (evidence: `README.md`)
- Home Assistant → Entry setup: loads entry (evidence: `custom_components/defa_power/__init__.py`)
- Configuration flow → API client: authenticates (evidence: `custom_components/defa_power/config_flow.py`)
- Entry setup → API client: creates client (evidence: `custom_components/defa_power/__init__.py`)
- Entry setup → Data coordinators: initializes (evidence: `custom_components/defa_power/__init__.py`)
- Entry setup → Device metadata: creates devices (evidence: `custom_components/defa_power/__init__.py`)
- Entry setup → Runtime data: stores runtime (evidence: `custom_components/defa_power/__init__.py`)
- Entry setup → Services and schedules: sets up services (evidence: `custom_components/defa_power/__init__.py`)
- Data coordinators → API client: fetches data (evidence: `custom_components/defa_power/coordinator.py`)
- API client → CloudCharge service: sends requests (evidence: `custom_components/defa_power/cloudcharge_api/client.py`)
- API client → API data models: uses typed data (evidence: `custom_components/defa_power/cloudcharge_api/client.py`)
- API client → API exceptions: raises errors (evidence: `custom_components/defa_power/cloudcharge_api/client.py`)
- Sensors → Data coordinators: reads updates (evidence: `custom_components/defa_power/sensor.py`)
- Binary sensors → Data coordinators: reads updates (evidence: `custom_components/defa_power/binary_sensor.py`)
- Current and eco controls → Data coordinators: reads updates (evidence: `custom_components/defa_power/number.py`)
- Current and eco controls → API client: sets values (evidence: `custom_components/defa_power/number.py`)
- Switch controls → Data coordinators: reads updates (evidence: `custom_components/defa_power/switch.py`)
- Switch controls → API client: controls charger (evidence: `custom_components/defa_power/switch.py`)
- Selection controls → Data coordinators: reads updates (evidence: `custom_components/defa_power/select.py`)
- Selection controls → API client: sets options (evidence: `custom_components/defa_power/select.py`)
- Charger actions → Data coordinators: refreshes data (evidence: `custom_components/defa_power/button.py`)
- Charger actions → API client: sends commands (evidence: `custom_components/defa_power/button.py`)
- Home Assistant user → Services and schedules: invokes actions (evidence: `README.md`)
- Services and schedules → API client: controls charger (evidence: `custom_components/defa_power/services.py`)
- Services and schedules → Data coordinators: refreshes data (evidence: `custom_components/defa_power/services.py`)
- Diagnostics → ID anonymizer: anonymizes IDs (evidence: `custom_components/defa_power/diagnostics.py`)
- Diagnostics → Runtime data: reports runtime (evidence: `custom_components/defa_power/diagnostics.py`)
- API client → CloudCharge service: manages schedules (evidence: `README.md`)
