# haier-ha/ha_haier_home architecture

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

- Interactive diagram: https://gitdiagram.com/haier-ha/ha_haier_home
- Repository: https://github.com/haier-ha/ha_haier_home
- Video tour (about a minute): https://gitdiagram.com/haier-ha/ha_haier_home/video

## Overview

Haier Home is a Home Assistant integration for authorizing Haier accounts and exposing supported air conditioners and cloud scenes. The main workflow is account setup and home selection, fetching device metadata, constructing device models, then presenting climate controls and synchronized scenes; coordinator-managed WebSocket updates refresh state and route commands. The graph reflects the README and sampled source; some wiring for scenes, config flow, and cloud API methods is documented but not shown in excerpts.

Main entry points: [`custom_components/haier_home/haier/coordinator.py`](https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/haier/coordinator.py) (State Coordinator), [`custom_components/haier_home/__init__.py`](https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/__init__.py) (Integration Setup), [`custom_components/haier_home/config_flow.py`](https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/config_flow.py) (Account Wizard), [`custom_components/haier_home/climate.py`](https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/climate.py) (Climate Platform)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Account Setup"]
  node_config["Account Wizard<br/>[config_flow.py]"]
  node_oauth["OAuth2 Flow<br/>[oauth2.py]"]
  node_credentials["App Credentials"]
  node_flowtext["Flow Text<br/>[flow_i18n.py]"]
  node_entry["Integration Setup<br/>[__init__.py]"]
end

subgraph group_runtime["Cloud Runtime"]
  node_http["REST Client<br/>[http_client.py]"]
  node_coordinator["State Coordinator<br/>[coordinator.py]"]
  node_websocket["WebSocket Client"]
  node_debouncer["Command Debouncer"]
  node_cache[("Persistent Cache<br/>[storage.py]")]
end

subgraph group_entities["Home Assistant Entities"]
  node_baseentity["Device Entity Base<br/>[entity.py]"]
  node_climate["Climate Platform<br/>[climate.py]"]
  node_scenes["Scene Platform<br/>[scene.py]"]
end

subgraph group_domain["Device Domain"]
  node_device["Device Models<br/>[device.py]"]
  node_extensions["PID Extensions"]
end

node_user(("Home Assistant User"))
node_ha(("Home Assistant"))
node_cloud(("Haier Cloud"))

node_user -->|"configures"| node_config
node_config -->|"loads translations"| node_flowtext
node_config -->|"uses credentials"| node_credentials
node_config -->|"authorizes account"| node_oauth
node_oauth -->|"exchanges tokens"| node_cloud
node_config -->|"creates entry"| node_entry
node_entry -->|"fetches account data"| node_http
node_http -->|"requests REST data"| node_cloud
node_entry -->|"reads and writes"| node_cache
node_entry -->|"builds devices"| node_device
node_entry -->|"starts runtime"| node_coordinator
node_entry -->|"forwards platform setup"| node_climate
node_entry -->|"forwards platform setup"| node_scenes
node_coordinator -->|"loads cloud data"| node_http
node_coordinator -->|"manages connection"| node_websocket
node_websocket -->|"syncs messages"| node_cloud
node_websocket -->|"delivers pushes"| node_coordinator
node_coordinator -->|"updates state"| node_device
node_coordinator -->|"debounces commands"| node_debouncer
node_coordinator -->|"sends commands"| node_http
node_climate -->|"extends"| node_baseentity
node_scenes -->|"uses runtime state"| node_coordinator
node_climate -->|"reads state; sends controls"| node_coordinator
node_baseentity -->|"reads attributes"| node_device
node_baseentity -->|"dispatches commands"| node_coordinator
node_climate -.->|"selects PID overrides"| node_extensions
node_ha -->|"displays entities"| node_climate
node_ha -->|"displays entities"| node_scenes

click node_config "https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/config_flow.py"
click node_oauth "https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/haier/oauth2.py"
click node_credentials "https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/application_credentials.py"
click node_flowtext "https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/haier/flow_i18n.py"
click node_entry "https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/__init__.py"
click node_http "https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/haier/http_client.py"
click node_coordinator "https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/haier/coordinator.py"
click node_websocket "https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/haier/websocket_client.py"
click node_debouncer "https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/haier/command_debouncer.py"
click node_cache "https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/haier/storage.py"
click node_device "https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/device.py"
click node_extensions "https://github.com/haier-ha/ha_haier_home/tree/main/custom_components/haier_home/extend"
click node_baseentity "https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/entity.py"
click node_climate "https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/climate.py"
click node_scenes "https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/scene.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_oauth,node_credentials,node_flowtext,node_entry,node_user toneBlue
class node_http,node_coordinator,node_websocket,node_debouncer,node_cache toneAmber
class node_baseentity,node_climate,node_scenes toneMint
class node_device,node_extensions toneRose
class node_ha,node_cloud toneIndigo
```

## Components

### Account Setup

- [Account Wizard](https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/config_flow.py): `custom_components/haier_home/config_flow.py`
- [OAuth2 Flow](https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/haier/oauth2.py): `custom_components/haier_home/haier/oauth2.py`
- [App Credentials](https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/application_credentials.py): `custom_components/haier_home/application_credentials.py`
- [Flow Text](https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/haier/flow_i18n.py): `custom_components/haier_home/haier/flow_i18n.py`
- [Integration Setup](https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/__init__.py): `custom_components/haier_home/__init__.py`

### Cloud Runtime

- [REST Client](https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/haier/http_client.py): `custom_components/haier_home/haier/http_client.py`
- [State Coordinator](https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/haier/coordinator.py): `custom_components/haier_home/haier/coordinator.py`
- [WebSocket Client](https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/haier/websocket_client.py): `custom_components/haier_home/haier/websocket_client.py`
- [Command Debouncer](https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/haier/command_debouncer.py): `custom_components/haier_home/haier/command_debouncer.py`
- [Persistent Cache](https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/haier/storage.py): `custom_components/haier_home/haier/storage.py`

### Home Assistant Entities

- [Device Entity Base](https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/entity.py): `custom_components/haier_home/entity.py`
- [Climate Platform](https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/climate.py): `custom_components/haier_home/climate.py`
- [Scene Platform](https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/scene.py): `custom_components/haier_home/scene.py`

### Device Domain

- [Device Models](https://github.com/haier-ha/ha_haier_home/blob/main/custom_components/haier_home/device.py): `custom_components/haier_home/device.py`
- [PID Extensions](https://github.com/haier-ha/ha_haier_home/tree/main/custom_components/haier_home/extend): `custom_components/haier_home/extend`

### Other components

- **Home Assistant User**
- **Home Assistant**
- **Haier Cloud**

## Connections

- Home Assistant User → Account Wizard: configures
- Account Wizard → Flow Text: loads translations
- Account Wizard → App Credentials: uses credentials
- Account Wizard → OAuth2 Flow: authorizes account
- OAuth2 Flow → Haier Cloud: exchanges tokens
- Account Wizard → Integration Setup: creates entry
- Integration Setup → REST Client: fetches account data
- REST Client → Haier Cloud: requests REST data
- Integration Setup → Persistent Cache: reads and writes
- Integration Setup → Device Models: builds devices
- Integration Setup → State Coordinator: starts runtime
- Integration Setup → Climate Platform: forwards platform setup
- Integration Setup → Scene Platform: forwards platform setup
- State Coordinator → REST Client: loads cloud data
- State Coordinator → WebSocket Client: manages connection
- WebSocket Client → Haier Cloud: syncs messages
- WebSocket Client → State Coordinator: delivers pushes
- State Coordinator → Device Models: updates state
- State Coordinator → Command Debouncer: debounces commands
- State Coordinator → REST Client: sends commands
- Climate Platform → Device Entity Base: extends
- Scene Platform → State Coordinator: uses runtime state
- Climate Platform → State Coordinator: reads state; sends controls
- Device Entity Base → Device Models: reads attributes
- Device Entity Base → State Coordinator: dispatches commands
- Climate Platform → PID Extensions: selects PID overrides
- Home Assistant → Climate Platform: displays entities
- Home Assistant → Scene Platform: displays entities
