# martinstafford/daikin_d3net architecture

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

- Interactive diagram: https://gitdiagram.com/martinstafford/daikin_d3net
- Repository: https://github.com/martinstafford/daikin_d3net

## Overview

1. **What this repository is**
   - A Home Assistant custom integration for Daikin DIII-Net systems, specifically the DTA116A51 DIII-Net/Modbus adapter.
   - It sits between Home Assistant and a Daikin HVAC bus, translating Home Assistant entity actions and state updates into Modbus traffic.

2. **Top-level architecture**
   - The repo is split into two main layers:
     - `custom_components/daikin_d3net/`: Home Assistant integration code.
     - `custom_components/daikin_d3net/d3net/`: protocol and gateway logic for talking to the Daikin/Modbus adapter.
   - This separation is important: Home Assistant concerns stay in the entity/config modules, while bus communication and encoding live in the `d3net` subpackage.

3. **Home Assistant integration entrypoints**
   - `__init__.py` is the integration bootstrap point.
   - `config_flow.py` handles UI-based setup in Home Assistant, so the integration is configured through the frontend rather than static YAML.
   - `manifest.json` defines the integration metadata, dependencies, and runtime identity used by Home Assistant.

4. **Core protocol layer**
   - `d3net/gateway.py` is the likely central communication abstraction for talking to the adapter and enumerating devices on the DIII-Net bus.
   - `d3net/encoding.py` handles protocol-specific conversion between Modbus/register values and Daikin DIII-Net concepts.
   - `d3net/const.py` holds low-level protocol constants shared by the gateway and encoding logic.

5. **External hardware boundary**
   - The external system is a Daikin HVAC installation on DIII-Net, accessed through a DTA116A51 adapter and a Modbus gateway.
   - The README states support for:
     - Modbus TCP
     - Modbus RTU over TCP
   - The integration does not claim support for hot water functions, and the DCPA01 is explicitly not supported.

6. **Entity model exposed to Home Assistant**
   - The integration exposes multiple Home Assistant entity platforms:
     - `climate.py` for the main HVAC control/state entity per unit
     - `sensor.py` for telemetry/read-only values
     - `binary_sensor.py` for boolean status flags
     - `switch.py` for on/off controls
     - `select.py` for mode/preset-style discrete choices
     - `number.py` for numeric settings
     - `button.py` for one-shot actions
   - This indicates a fairly rich device model, not just a single thermostat entity.

7. **Data flow through the integration**
   - Home Assistant starts the integration and loads configuration.
   - The integration creates a gateway connection to the DTA116A51/Modbus side.
   - The gateway enumerates units attached to the DIII-Net bus.
   - Entity platforms then expose each discovered unit as Home Assistant entities and use the shared gateway/protocol layer to read or update state.

8. **Primary exposed device concept**
   - The README says it “enumerates units attached to DIII-Net bus” and “provides Climate entities for each.”
   - That suggests the climate entity is the canonical representation of each HVAC unit, with the other platforms layering additional controls and telemetry around it.

9. **Localization and UX support**
   - `strings.json` and `translations/en.json` provide Home Assistant UI text and translations.
   - This matters architecturally because the integration is meant to be installed and configured interactively inside Home Assistant, not as a low-level library.

10. **Packaging and distribution**
   - `hacs.json` shows it is designed for HACS distribution as a custom repository.
   - `.github/workflows/validate.yml` and `release.yml` indicate CI for validation and release packaging, which is typical for Home Assistant custom integrations.

11. **Hardware/documentation boundary**
   - `hardware.md` and the images folder document a DIY hardware implementation and show integration/device screenshots.
   - These are supporting materials rather than runtime components, but they clarify that the repo’s runtime boundary ends at the adapter and HVAC network.

12. **How to draw the architecture**
   - Draw Home Assistant as the host.
   - Inside it, place the `daikin_d3net` integration with config flow, entity platforms, and shared constants.
   - Behind that, place the `d3net` protocol/gateway layer.
   - Outside the integration boundary, place the DTA116A51 adapter / Modbus TCP or RTU-over-TCP gateway, then the Daikin DIII-Net bus with attached HVAC units.

Main entry points: [`custom_components/daikin_d3net/__init__.py`](https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/__init__.py) (Bootstrap), [`custom_components/daikin_d3net/d3net/gateway.py`](https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/d3net/gateway.py) (Gateway), [`custom_components/daikin_d3net/climate.py`](https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/climate.py) (Climate), [`custom_components/daikin_d3net/sensor.py`](https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/sensor.py) (Sensors)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_home_assistant["Home Assistant integration"]
  node_ha_bootstrap["Bootstrap<br/>integration entrypoint<br/>[__init__.py]"]
  node_ha_config_flow["Setup flow<br/>config flow<br/>[config_flow.py]"]
  node_ha_climate["Climate<br/>primary entity platform<br/>[climate.py]"]
  node_ha_sensor["Sensors<br/>telemetry platform<br/>[sensor.py]"]
  node_ha_binary_sensor["Binary sensors<br/>status platform<br/>[binary_sensor.py]"]
  node_ha_switch["Switches<br/>control platform<br/>[switch.py]"]
  node_ha_select["Selects<br/>discrete control platform<br/>[select.py]"]
  node_ha_number["Numbers<br/>numeric control platform<br/>[number.py]"]
  node_ha_button["Buttons<br/>action platform<br/>[button.py]"]
  node_ha_const["Integration consts<br/>integration constants<br/>[const.py]"]
end

subgraph group_protocol["D3-Net protocol"]
  node_d3_gateway["Gateway<br/>bus connection<br/>[gateway.py]"]
  node_d3_encoding["Encoding<br/>protocol codec<br/>[encoding.py]"]
  node_d3_proto_const["Proto consts<br/>protocol constants<br/>[const.py]"]
end

subgraph group_external["External hardware"]
  node_dta_adapter[("DTA116A51<br/>modbus adapter")]
  node_d3_bus(("DIII-Net bus<br/>hvac field bus"))
  node_hvac_units["HVAC units<br/>field devices"]
end

subgraph group_support["Support files"]
  node_translations["UI text<br/>localization assets<br/>[strings.json]"]
  node_release_ci["CI/CD<br/>workflow automation<br/>[validate.yml]"]
end

node_ha_bootstrap -->|"setup"| node_ha_config_flow
node_ha_bootstrap -->|"loads"| node_ha_climate
node_ha_bootstrap -->|"loads"| node_ha_sensor
node_ha_bootstrap -->|"loads"| node_ha_binary_sensor
node_ha_bootstrap -->|"loads"| node_ha_switch
node_ha_bootstrap -->|"loads"| node_ha_select
node_ha_bootstrap -->|"loads"| node_ha_number
node_ha_bootstrap -->|"loads"| node_ha_button
node_ha_bootstrap -->|"connects"| node_d3_gateway
node_ha_bootstrap -->|"uses"| node_ha_const
node_ha_bootstrap -->|"publishes"| node_translations
node_ha_climate -->|"reads/writes"| node_d3_gateway
node_ha_sensor -->|"reads"| node_d3_gateway
node_ha_binary_sensor -->|"reads"| node_d3_gateway
node_ha_switch -->|"writes"| node_d3_gateway
node_ha_select -->|"writes"| node_d3_gateway
node_ha_number -->|"writes"| node_d3_gateway
node_ha_button -->|"acts"| node_d3_gateway
node_d3_gateway -->|"encodes"| node_d3_encoding
node_d3_gateway -->|"uses"| node_d3_proto_const
node_d3_encoding -->|"uses"| node_d3_proto_const
node_d3_gateway -->|"modbus"| node_dta_adapter
node_dta_adapter -->|"bridges"| node_d3_bus
node_d3_bus -->|"connects"| node_hvac_units
node_release_ci -.->|"validates"| node_ha_bootstrap

click node_ha_bootstrap "https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/__init__.py"
click node_ha_config_flow "https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/config_flow.py"
click node_ha_climate "https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/climate.py"
click node_ha_sensor "https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/sensor.py"
click node_ha_binary_sensor "https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/binary_sensor.py"
click node_ha_switch "https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/switch.py"
click node_ha_select "https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/select.py"
click node_ha_number "https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/number.py"
click node_ha_button "https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/button.py"
click node_d3_gateway "https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/d3net/gateway.py"
click node_d3_encoding "https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/d3net/encoding.py"
click node_d3_proto_const "https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/d3net/const.py"
click node_ha_const "https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/const.py"
click node_translations "https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/strings.json"
click node_release_ci "https://github.com/martinstafford/daikin_d3net/blob/main/.github/workflows/validate.yml"

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_ha_bootstrap,node_ha_config_flow,node_ha_climate,node_ha_sensor,node_ha_binary_sensor,node_ha_switch,node_ha_select,node_ha_number,node_ha_button,node_ha_const toneBlue
class node_d3_gateway,node_d3_encoding,node_d3_proto_const toneAmber
class node_dta_adapter,node_d3_bus,node_hvac_units toneMint
class node_translations,node_release_ci toneRose
```

## Components

### Home Assistant integration

Entry points, setup, and entity platforms exposed to Home Assistant.

- [Bootstrap](https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/__init__.py): integration entrypoint · Loads the integration and wires Home Assistant lifecycle hooks. · `custom_components/daikin_d3net/__init__.py`
- [Setup flow](https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/config_flow.py): config flow · Frontend configuration flow used to create and manage the integration. · `custom_components/daikin_d3net/config_flow.py`
- [Climate](https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/climate.py): primary entity platform · Canonical HVAC control and state entity for each discovered unit. · `custom_components/daikin_d3net/climate.py`
- [Sensors](https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/sensor.py): telemetry platform · Read-only measurements and status values exposed to Home Assistant. · `custom_components/daikin_d3net/sensor.py`
- [Binary sensors](https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/binary_sensor.py): status platform · Boolean flags representing device and system states. · `custom_components/daikin_d3net/binary_sensor.py`
- [Switches](https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/switch.py): control platform · On/off controls for supported device functions. · `custom_components/daikin_d3net/switch.py`
- [Selects](https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/select.py): discrete control platform · Mode and preset style choice entities. · `custom_components/daikin_d3net/select.py`
- [Numbers](https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/number.py): numeric control platform · Numeric settings exposed as adjustable entities. · `custom_components/daikin_d3net/number.py`
- [Buttons](https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/button.py): action platform · One-shot actions such as commands or maintenance operations. · `custom_components/daikin_d3net/button.py`
- [Integration consts](https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/const.py): integration constants · Shared integration identifiers and configuration constants. · `custom_components/daikin_d3net/const.py`

### D3-Net protocol

Shared gateway and encoding logic for the Daikin/Modbus adapter.

- [Gateway](https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/d3net/gateway.py): bus connection · Connects to the adapter, discovers units, and mediates read/write traffic. · `custom_components/daikin_d3net/d3net/gateway.py`
- [Encoding](https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/d3net/encoding.py): protocol codec · Converts between Modbus register data and Daikin DIII-Net values. · `custom_components/daikin_d3net/d3net/encoding.py`
- [Proto consts](https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/d3net/const.py): protocol constants · Low-level protocol values shared across gateway and encoding layers. · `custom_components/daikin_d3net/d3net/const.py`

### External hardware

Adapter, bus, and HVAC units outside the integration boundary.

- **DTA116A51**: modbus adapter · External Daikin DIII-Net to Modbus adapter used as the hardware boundary.
- **DIII-Net bus**: hvac field bus · Daikin bus carrying commands and state for attached equipment.
- **HVAC units**: field devices · Attached Daikin indoor/outdoor units exposed to Home Assistant.

### Support files

Translation, packaging, and release support artifacts.

- [UI text](https://github.com/martinstafford/daikin_d3net/blob/main/custom_components/daikin_d3net/strings.json): localization assets · Home Assistant strings and English translations for frontend setup. · `custom_components/daikin_d3net/strings.json`
- [CI/CD](https://github.com/martinstafford/daikin_d3net/blob/main/.github/workflows/validate.yml): workflow automation · Validation and release workflows for packaging and repository checks. · `.github/workflows/validate.yml`

## Connections

- Bootstrap → Setup flow: setup · Bootstrapped integration exposes frontend configuration.
- Bootstrap → Climate: loads · Initializes the climate platform and other entities.
- Bootstrap → Sensors: loads · Initializes telemetry entities.
- Bootstrap → Binary sensors: loads · Initializes boolean status entities.
- Bootstrap → Switches: loads · Initializes switch entities.
- Bootstrap → Selects: loads · Initializes select entities.
- Bootstrap → Numbers: loads · Initializes number entities.
- Bootstrap → Buttons: loads · Initializes button entities.
- Bootstrap → Gateway: connects · Creates the shared gateway used by all platforms.
- Bootstrap → Integration consts: uses · Uses integration constants and identifiers.
- Bootstrap → UI text: publishes · Exposes localized UI strings to Home Assistant.
- Climate → Gateway: reads/writes · Primary entity exchanges state and commands through the gateway.
- Sensors → Gateway: reads · Telemetry entities query device state through the gateway.
- Binary sensors → Gateway: reads · Status flags are derived from gateway state.
- Switches → Gateway: writes · Switch actions are translated into gateway commands.
- Selects → Gateway: writes · Discrete choices map to protocol updates.
- Numbers → Gateway: writes · Numeric adjustments propagate through the gateway.
- Buttons → Gateway: acts · One-shot actions invoke gateway operations.
- Gateway → Encoding: encodes · Gateway relies on the codec for register and value translation.
- Gateway → Proto consts: uses · Gateway consumes shared protocol constants.
- Encoding → Proto consts: uses · Codec uses shared low-level protocol values.
- Gateway → DTA116A51: modbus · Gateway communicates with the external adapter over Modbus.
- DTA116A51 → DIII-Net bus: bridges · Adapter bridges Modbus traffic onto the Daikin field bus.
- DIII-Net bus → HVAC units: connects · Bus carries data to and from attached HVAC units.
- CI/CD → Bootstrap: validates · CI validates integration structure and packaging.
