This commit is contained in:
Mateusz Gruszczyński
2026-09-18 10:27:39 +02:00
parent 7d9e6c8189
commit 3ffb02595e
28 changed files with 610 additions and 480 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
REGISTRY=repo.example.com
IMAGE_NAME=gree-controller
DISTRO=alpine
RUST_VERSION=1.89
RUST_VERSION=1.98.1
BUILD_PLATFORMS=linux/amd64,linux/arm64
BUILDER=gree-controller-multiarch
BUILDER_CONFIG=
+5 -3
View File
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1.7
ARG RUST_VERSION=1.89
ARG RUST_VERSION=1.98.1
ARG XX_VERSION=1.9.0
# Cross-compilation helpers. Builder stages always run on BUILDPLATFORM, so an
@@ -16,11 +16,12 @@ RUN apt-get update \
# Fetch Rust dependencies before TARGETPLATFORM enters the cache chain, so the
# same registry/git cache is reused by amd64 and arm64 builds.
COPY Cargo.toml Cargo.lock ./
COPY Cargo.toml ./
RUN --mount=type=cache,id=gree-controller-cargo-registry,target=/usr/local/cargo/registry \
--mount=type=cache,id=gree-controller-cargo-git,target=/usr/local/cargo/git \
mkdir -p src \
&& printf 'fn main() {}\n' > src/main.rs \
&& cargo generate-lockfile \
&& cargo fetch --locked \
&& rm -rf src
@@ -56,11 +57,12 @@ WORKDIR /src
RUN apk add --no-cache clang lld llvm file pkgconf
# Keep dependency fetching architecture-independent here as well.
COPY Cargo.toml Cargo.lock ./
COPY Cargo.toml ./
RUN --mount=type=cache,id=gree-controller-cargo-registry,target=/usr/local/cargo/registry \
--mount=type=cache,id=gree-controller-cargo-git,target=/usr/local/cargo/git \
mkdir -p src \
&& printf 'fn main() {}\n' > src/main.rs \
&& cargo generate-lockfile \
&& cargo fetch --locked \
&& rm -rf src
+4 -2
View File
@@ -2,6 +2,8 @@
This directory contains the OCI build, Home Assistant add-on repository source, custom integration and repository synchronization tooling.
The packaged controller includes its HTTP/WebSocket API and built-in Swagger documentation at `/api-docs` (`/api-docs/openapi.json` for OpenAPI 3.1).
## Configuration
Create the local build/repository configuration once:
@@ -20,7 +22,7 @@ Important variables:
REGISTRY=repo.example.com
IMAGE_NAME=gree-controller
DISTRO=alpine
RUST_VERSION=1.89
RUST_VERSION=1.98.1
BUILD_PLATFORMS=linux/amd64,linux/arm64
BUILDER=gree-controller-multiarch
BUILDER_CONFIG=
@@ -40,7 +42,7 @@ INTEGRATION_DOMAIN=gree_controller
./build.sh push
```
The project version comes only from root `Cargo.toml`. `render` synchronizes it to `Cargo.lock`, add-on `config.yaml` and the custom integration `manifest.json`, and sets the OCI image from `.env`.
The project version comes only from root `Cargo.toml`. `render` synchronizes it to add-on `config.yaml` and the custom integration `manifest.json`, and sets the OCI image from `.env`. The container build generates `Cargo.lock` from the exact direct dependency versions in `Cargo.toml` before fetching and compiling dependencies.
For the Home Assistant package, TCP `8787` is an intentional fixed host-network/ingress port contract. `build.sh render` verifies `config.yaml`, `run.sh`, the watchdog URL and Docker image metadata stay consistent. The runtime also compares the Supervisor-reported ingress port before starting. Standalone installations remain free to use any `GREE_CONTROLLER_BIND` port.
+6 -16
View File
@@ -32,7 +32,6 @@ VERSION="$(awk -F '"' '/^version = "/ {print $2; exit}' "$PROJECT_ROOT/Cargo.tom
IMAGE_REPO="${REGISTRY%/}/${IMAGE_NAME#/}"
IMAGE_TAG="${IMAGE_REPO}:${VERSION}"
CONFIG="$SCRIPT_DIR/repository/$ADDON_DIR/config.yaml"
LOCKFILE="$PROJECT_ROOT/Cargo.lock"
INTEGRATION_MANIFEST="$SCRIPT_DIR/home-assistant/custom_components/$INTEGRATION_DOMAIN/manifest.json"
REPOSITORY_CONFIG="$SCRIPT_DIR/repository/repository.yaml"
RUN_SCRIPT="$SCRIPT_DIR/run.sh"
@@ -44,18 +43,16 @@ DOCKERFILE="$SCRIPT_DIR/Dockerfile"
render_metadata() {
command -v python3 >/dev/null 2>&1 || { echo "python3 is required" >&2; exit 1; }
python3 - "$CONFIG" "$LOCKFILE" "$INTEGRATION_MANIFEST" "$REPOSITORY_CONFIG" "$VERSION" "$IMAGE_REPO" "$HA_REPO_URL" <<'PY'
python3 - "$CONFIG" "$INTEGRATION_MANIFEST" "$REPOSITORY_CONFIG" "$VERSION" "$IMAGE_REPO" "$HA_REPO_URL" <<'PY'
from pathlib import Path
import re
import sys
config = Path(sys.argv[1])
lockfile = Path(sys.argv[2])
manifest = Path(sys.argv[3])
repository = Path(sys.argv[4])
version = sys.argv[5]
image = sys.argv[6]
repo_url = sys.argv[7]
manifest = Path(sys.argv[2])
repository = Path(sys.argv[3])
version = sys.argv[4]
image = sys.argv[5]
repo_url = sys.argv[6]
lines = config.read_text(encoding="utf-8").splitlines()
out = []
@@ -70,13 +67,6 @@ for line in lines:
out.append(line)
config.write_text("\n".join(out) + "\n", encoding="utf-8")
lock = lockfile.read_text(encoding="utf-8")
pattern = r'(\[\[package\]\]\nname = "gree-controller"\nversion = ")[^"]+("\n)'
updated, count = re.subn(pattern, rf'\g<1>{version}\g<2>', lock, count=1)
if count != 1:
raise SystemExit("Could not find gree-controller package version in Cargo.lock")
lockfile.write_text(updated, encoding="utf-8")
import json
data = json.loads(manifest.read_text(encoding="utf-8"))
data["version"] = version
+2
View File
@@ -8,6 +8,8 @@ ha-addon/home-assistant/custom_components/gree_controller/
It creates HA entities for physical units, thermostat zones, whole-house controls and climate groups, while sending every command to the standalone Rust controller. Home Assistant therefore remains a client and UDP/AES GREE communication stays outside HA.
The controller exposes the API used by the integration and Web UI under `/api/*` and `/ws`; interactive Swagger documentation is available at `/api-docs`, with OpenAPI JSON at `/api-docs/openapi.json`.
The climate proxy supports power/turn on/off, HVAC modes, target temperature, fan mode, granular vertical louver positions and granular horizontal louver positions. `off`/`on` remain the first two swing modes for compatibility, followed by fixed positions and the supported vertical partial-swing ranges. The card UI translates those modes using the Home Assistant language while the underlying mode IDs (for example `fixed_upper`) remain unchanged for services, scripts and automations.
Automation plan:
@@ -1,7 +1,7 @@
{
"domain": "gree_controller",
"name": "GREE Controller",
"version": "0.15.2",
"version": "0.15.4",
"config_flow": true,
"integration_type": "hub",
"iot_class": "local_polling",
@@ -1,5 +1,18 @@
# Changelog
## 0.15.4
- Updates the Rust dependency stack to current major/minor releases, including Axum 0.8, Reqwest 0.13, Rusqlite 0.40, Rand 0.10, AES 0.9, AES-GCM 0.11, Base64 0.23, SHA-2 0.11, Tower HTTP 0.7 and utoipa-swagger-ui 9.
- Migrates Axum route parameters and WebSocket text frames, Rand APIs, RustCrypto AES/AES-GCM APIs and Reqwest TLS configuration for the new dependency versions.
- Updates the Home Assistant add-on Rust builder to Rust 1.98.1.
- Pins direct Rust dependencies to exact updated releases; container builds generate a fresh lockfile before fetching and compiling with `--locked`.
- Uses `ring` as the single Rustls crypto provider across Reqwest and the direct MQTT TLS client, avoiding the Rustls provider ambiguity introduced by Reqwest 0.13.
## 0.15.3
- Simplifies the built-in Swagger API documentation: removes the embedded release-history changelog, starts with all endpoint groups collapsed and hides the global Schemas section.
- Documents the HTTP/WebSocket API, Swagger UI (`/api-docs`) and OpenAPI document (`/api-docs/openapi.json`) in the main documentation and Home Assistant add-on package.
## 0.15.2
- Adds a dedicated Visual Flow action for changing exactly one GREE unit function without modifying unrelated settings.
@@ -59,6 +59,10 @@ Broadcast zwykle nie przechodzi przez router. Sterowanie unicast może działać
| `public_chart_base_url` | opcjonalny bazowy URL publicznych linków Custom Chart; puste = automatyczne główne IPv4 hosta HA + `:8787` |
| `log_level` | `error`, `warn`, `info`, `debug`, `trace` |
### API i dokumentacja API
Aplikacja udostępnia HTTP API pod `/api/*` oraz WebSocket pod `/ws`. Interaktywna dokumentacja Swagger jest dostępna pod `/api-docs`, a dokument OpenAPI 3.1 pod `/api-docs/openapi.json`. Te same ścieżki działają przez ingress Home Assistant; bezpośredni dostęp na porcie `8787` podlega regułom `app_token`.
### Home Assistant API
Dodatek korzysta automatycznie z wewnętrznego proxy Home Assistant Core (`http://supervisor/core/api/`) i tokenu `SUPERVISOR_TOKEN` przekazywanego przez Supervisor. Gdy token jest wykryty, UI pokazuje automatyczną autoryzację i ukrywa ręczne pola URL/token. Dopiero nieudany `Test HA` odblokowuje awaryjny ręczny fallback. Token Supervisor jest używany tylko w pamięci procesu i nie jest zapisywany w SQLite.
@@ -125,6 +129,10 @@ Broadcast normally does not cross routers. Unicast control may work through rout
| `public_chart_base_url` | optional base URL for public Custom Chart links; empty = primary HA host IPv4 + `:8787` automatically |
| `log_level` | `error`, `warn`, `info`, `debug`, `trace` |
### API and API documentation
The application exposes its HTTP API under `/api/*` and WebSocket under `/ws`. Interactive Swagger documentation is available at `/api-docs`, with the OpenAPI 3.1 document at `/api-docs/openapi.json`. The same paths work through Home Assistant ingress; direct access on port `8787` follows the configured `app_token` rules.
### Home Assistant API
The add-on automatically uses the internal Home Assistant Core proxy (`http://supervisor/core/api/`) and the runtime `SUPERVISOR_TOKEN` provided by Supervisor. When the token is detected, the UI shows automatic authorization and hides manual URL/token fields. A failed `Test HA` unlocks the optional manual fallback. The Supervisor token is used only at runtime and is not stored in SQLite.
@@ -1,6 +1,6 @@
# GREE Controller
Local GREE HVAC controller packaged as a Home Assistant add-on, with Web UI, local API, UDP discovery/control, `amd64` and `aarch64` support, ingress, and database backup from `/data/gree-controller.db`.
Local GREE HVAC controller packaged as a Home Assistant add-on, with Web UI, HTTP/WebSocket API, built-in Swagger API documentation, UDP discovery/control, `amd64` and `aarch64` support, ingress, and database backup from `/data/gree-controller.db`.
![Home Assistant OS + GREE + VLAN topology](https://git.linuxiarz.pl/gru/gree-controller-ha-addon/raw/branch/master/gree-controller/topology-ha-vlan-gree-en.png)
@@ -8,6 +8,8 @@ For VLAN deployments, configure VLAN interfaces on the Home Assistant OS host. T
Full documentation: [DOCS.md](./DOCS.md).
The controller exposes `/api/*` and `/ws`. Interactive API documentation is available at `/api-docs`, with the OpenAPI 3.1 document at `/api-docs/openapi.json`. The same paths work through Home Assistant ingress; direct access on port `8787` follows the configured `app_token` rules.
The same Git repository also contains the optional `custom_components/gree_controller` integration. It is distributed with the repository but is not installed automatically with the add-on.
Repository: https://git.linuxiarz.pl/gru/gree-controller-ha-addon/
@@ -1,7 +1,7 @@
name: "GREE Controller"
version: "0.15.2"
version: "0.15.4"
slug: "gree_controller"
description: "Local GREE HVAC controller with Web UI and Home Assistant integration"
description: "Local GREE HVAC controller with Web UI, API, Swagger API docs and Home Assistant integration"
url: "https://git.linuxiarz.pl/gru/gree-controller-ha-addon/"
arch:
- amd64