# amosyuen/ha-tplink-deco architecture

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

- Interactive diagram: https://gitdiagram.com/amosyuen/ha-tplink-deco
- Repository: https://github.com/amosyuen/ha-tplink-deco

## Overview

TP-Link Deco is a Home Assistant custom integration for locally polling Deco mesh systems. Users configure an entry, after which the integration polls device, client, performance, wireless, and supported mobile-data status and exposes it through Home Assistant entities. Users can adjust or pause polling, request actions and diagnostics, download system logs, and optionally forward new log lines to syslog. The excerpts show selected API, coordinator, service, and forwarding behavior; some platform wiring and subsystems are documented or indexed but not fully sampled.

Main entry points: [`custom_components/tplink_deco/api.py`](https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/api.py) (Deco API client), [`custom_components/tplink_deco/__init__.py`](https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/__init__.py) (Entry setup), [`custom_components/tplink_deco/coordinator.py`](https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/coordinator.py) (Status coordinators), [`custom_components/tplink_deco/syslog_forwarder.py`](https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/syslog_forwarder.py) (Syslog forwarding)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Setup and Control"]
  node_config["Entry configuration<br/>[config_flow.py]"]
  node_setup_entry["Entry setup<br/>[__init__.py]"]
  node_controls["Polling controls<br/>[switch.py]"]
  node_settings["Integration settings<br/>[const.py]"]
  node_platform_controls["Entity controls<br/>[button.py]"]
  node_select["Interval selector<br/>[select.py]"]
end

subgraph group_polling["Polling and Entities"]
  node_pollers["Status coordinators<br/>[coordinator.py]"]
  node_device_data["Mesh and client data<br/>[coordinator.py]"]
  node_tracker["Client tracking<br/>[device_tracker.py]"]
  node_sensors["Status sensors<br/>[sensor.py]"]
  node_wireless["WiFi status<br/>[wireless.py]"]
  node_binary["WiFi entities<br/>[binary_sensor.py]"]
  node_mobile["Mobile usage<br/>[mobile.py]"]
  node_device_info["Device registry info<br/>[device.py]"]
end

subgraph group_api["Deco API"]
  node_api["Deco API client<br/>[api.py]"]
  node_exceptions["API error types<br/>[exceptions.py]"]
end

subgraph group_logs["Logs and Diagnostics"]
  node_diagnostics["Coordinator diagnostics<br/>[diagnostics.py]"]
  node_services["Log download action<br/>[services.py]"]
  node_system_log["Log levels<br/>[system_log.py]"]
  node_forwarder["Syslog forwarding"]
end

node_user(("Home Assistant user"))
node_ha(("Home Assistant"))
node_router(("Deco mesh"))
node_syslog_server(("Syslog server<br/>external system"))

node_user -->|"configures entry"| node_config
node_config -.->|"sets up"| node_setup_entry
node_setup_entry -.->|"creates coordinators"| node_pollers
node_setup_entry -->|"creates coordinator"| node_mobile
node_setup_entry -->|"creates coordinator"| node_wireless
node_user -->|"controls polling"| node_controls
node_user -->|"sets interval"| node_select
node_pollers -->|"requests mesh data"| node_api
node_api -->|"queries locally"| node_router
node_pollers -->|"updates models"| node_device_data
node_device_data -->|"provides client state"| node_tracker
node_pollers -->|"provides readings"| node_sensors
node_wireless -->|"fetches WiFi status"| node_api
node_wireless -->|"provides network state"| node_binary
node_mobile -->|"fetches usage"| node_api
node_sensors -->|"reads usage"| node_mobile
node_sensors -->|"creates device metadata"| node_device_info
node_user -->|"requests refresh"| node_platform_controls
node_user -->|"requests diagnostics"| node_diagnostics
node_user -->|"downloads log"| node_services
node_services -->|"retrieves system log"| node_api
node_services -->|"selects log level"| node_system_log
node_setup_entry -.->|"starts optional forwarding"| node_forwarder
node_forwarder -->|"downloads log"| node_api
node_forwarder -->|"sends log lines"| node_syslog_server
node_forwarder -->|"filters log level"| node_system_log
node_api -->|"raises API errors"| node_exceptions

click node_config "https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/config_flow.py"
click node_setup_entry "https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/__init__.py"
click node_controls "https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/switch.py"
click node_settings "https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/const.py"
click node_api "https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/api.py"
click node_pollers "https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/coordinator.py"
click node_device_data "https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/coordinator.py"
click node_tracker "https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/device_tracker.py"
click node_sensors "https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/sensor.py"
click node_wireless "https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/wireless.py"
click node_binary "https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/binary_sensor.py"
click node_mobile "https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/mobile.py"
click node_device_info "https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/device.py"
click node_platform_controls "https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/button.py"
click node_select "https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/select.py"
click node_diagnostics "https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/diagnostics.py"
click node_services "https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/services.py"
click node_system_log "https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/system_log.py"
click node_forwarder "https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/syslog_forwarder.py"
click node_exceptions "https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/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_setup_entry,node_controls,node_settings,node_platform_controls,node_select,node_user toneBlue
class node_pollers,node_device_data,node_tracker,node_sensors,node_wireless,node_binary,node_mobile,node_device_info toneAmber
class node_api,node_exceptions,node_syslog_server toneMint
class node_diagnostics,node_services,node_system_log,node_forwarder toneRose
class node_ha,node_router toneIndigo
```

## Components

### Setup and Control

- [Entry configuration](https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/config_flow.py): `custom_components/tplink_deco/config_flow.py`
- [Entry setup](https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/__init__.py): `custom_components/tplink_deco/__init__.py`
- [Polling controls](https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/switch.py): `custom_components/tplink_deco/switch.py`
- [Integration settings](https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/const.py): `custom_components/tplink_deco/const.py`
- [Entity controls](https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/button.py): `custom_components/tplink_deco/button.py`
- [Interval selector](https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/select.py): `custom_components/tplink_deco/select.py`

### Polling and Entities

- [Status coordinators](https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/coordinator.py): `custom_components/tplink_deco/coordinator.py`
- [Mesh and client data](https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/coordinator.py): `custom_components/tplink_deco/coordinator.py`
- [Client tracking](https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/device_tracker.py): `custom_components/tplink_deco/device_tracker.py`
- [Status sensors](https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/sensor.py): `custom_components/tplink_deco/sensor.py`
- [WiFi status](https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/wireless.py): `custom_components/tplink_deco/wireless.py`
- [WiFi entities](https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/binary_sensor.py): `custom_components/tplink_deco/binary_sensor.py`
- [Mobile usage](https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/mobile.py): `custom_components/tplink_deco/mobile.py`
- [Device registry info](https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/device.py): `custom_components/tplink_deco/device.py`

### Deco API

- [Deco API client](https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/api.py): `custom_components/tplink_deco/api.py`
- [API error types](https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/exceptions.py): `custom_components/tplink_deco/exceptions.py`

### Logs and Diagnostics

- [Coordinator diagnostics](https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/diagnostics.py): `custom_components/tplink_deco/diagnostics.py`
- [Log download action](https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/services.py): `custom_components/tplink_deco/services.py`
- [Log levels](https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/system_log.py): `custom_components/tplink_deco/system_log.py`
- [Syslog forwarding](https://github.com/amosyuen/ha-tplink-deco/blob/main/custom_components/tplink_deco/syslog_forwarder.py): `custom_components/tplink_deco/syslog_forwarder.py`

### Other components

- **Home Assistant user**
- **Home Assistant**
- **Deco mesh**
- **Syslog server**: external system

## Connections

- Home Assistant user → Entry configuration: configures entry (evidence: `README.md`)
- Entry configuration → Entry setup: sets up (evidence: `custom_components/tplink_deco/config_flow.py`)
- Entry setup → Status coordinators: creates coordinators (evidence: `custom_components/tplink_deco/__init__.py`)
- Entry setup → Mobile usage: creates coordinator (evidence: `custom_components/tplink_deco/__init__.py`)
- Entry setup → WiFi status: creates coordinator (evidence: `custom_components/tplink_deco/__init__.py`)
- Home Assistant user → Polling controls: controls polling (evidence: `README.md`)
- Home Assistant user → Interval selector: sets interval (evidence: `README.md`)
- Status coordinators → Deco API client: requests mesh data (evidence: `custom_components/tplink_deco/coordinator.py`)
- Deco API client → Deco mesh: queries locally (evidence: `README.md`)
- Status coordinators → Mesh and client data: updates models (evidence: `custom_components/tplink_deco/coordinator.py`)
- Mesh and client data → Client tracking: provides client state (evidence: `custom_components/tplink_deco/device_tracker.py`)
- Status coordinators → Status sensors: provides readings (evidence: `custom_components/tplink_deco/sensor.py`)
- WiFi status → Deco API client: fetches WiFi status (evidence: `custom_components/tplink_deco/wireless.py`)
- WiFi status → WiFi entities: provides network state (evidence: `custom_components/tplink_deco/binary_sensor.py`)
- Mobile usage → Deco API client: fetches usage (evidence: `custom_components/tplink_deco/mobile.py`)
- Status sensors → Mobile usage: reads usage (evidence: `custom_components/tplink_deco/sensor.py`)
- Status sensors → Device registry info: creates device metadata (evidence: `custom_components/tplink_deco/sensor.py`)
- Home Assistant user → Entity controls: requests refresh (evidence: `README.md`)
- Home Assistant user → Coordinator diagnostics: requests diagnostics (evidence: `README.md`)
- Home Assistant user → Log download action: downloads log (evidence: `custom_components/tplink_deco/services.py`)
- Log download action → Deco API client: retrieves system log (evidence: `custom_components/tplink_deco/services.py`)
- Log download action → Log levels: selects log level (evidence: `custom_components/tplink_deco/services.py`)
- Entry setup → Syslog forwarding: starts optional forwarding (evidence: `custom_components/tplink_deco/__init__.py`)
- Syslog forwarding → Deco API client: downloads log (evidence: `custom_components/tplink_deco/syslog_forwarder.py`)
- Syslog forwarding → Syslog server: sends log lines (evidence: `README.md`)
- Syslog forwarding → Log levels: filters log level (evidence: `custom_components/tplink_deco/syslog_forwarder.py`)
- Deco API client → API error types: raises API errors (evidence: `custom_components/tplink_deco/api.py`)
