Major updates: - Complete Rust rewrite (pilot-v2/) with working MQTT client - Fixed MQTT event loop deadlock (background task pattern) - Battery telemetry for Linux (auto-detected via /sys/class/power_supply) - Home Assistant auto-discovery for all sensors and switches - Comprehensive documentation (AVANCEMENT.md, CLAUDE.md, roadmap) - Docker test environment with Mosquitto broker - Helper scripts for development and testing Features working: ✅ MQTT connectivity with LWT ✅ YAML configuration with validation ✅ Telemetry: CPU, memory, IP, battery (Linux) ✅ Commands: shutdown, reboot, sleep, screen (dry-run tested) ✅ HA discovery and integration ✅ Allowlist and cooldown protection Ready for testing on real hardware. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2.8 KiB
2.8 KiB
Architecture v2 (Rust)
Vue d'ensemble
- Binaire Rust unique par OS (Linux/Windows).
- Modules separes pour MQTT, telemetry, commands, HA discovery.
- Backends OS selectionnes via YAML.
Diagramme ASCII
[config.yaml] -> [runtime] -> [mqtt client] <-> [broker] | |-> discovery/status/capabilities | |-> publish states | |-> receive commands | +-> [telemetry providers] +-> [commands providers] +-> [ha discovery] +-> [platform backends]
Structure du projet (reference)
pilot-v2/
Cargo.toml
src/
main.rs
lib.rs
config/
mqtt/
ha/
telemetry/
commands/
platform/
linux/
windows/
runtime/
security/
Contrat MQTT (stable)
Base topic: pilot/<device>/...
Topics
pilot/<device>/availability: online/offline (LWT recommande)pilot/<device>/status: JSON (version, os, uptime, last_error, backends)pilot/<device>/capabilities: JSON (features actives)pilot/<device>/state/<name>: capteurs et etats systemepilot/<device>/cmd/<action>/set: commandes
QoS / retain
- Discovery: retain=true, qos=1
- States: retain configurable (defaut true), qos=0 ou 1 selon config
- Commands: retain=false, qos=0
- Availability: retain=true (LWT possible), qos=1
Home Assistant discovery
- Prefix:
homeassistant - Discovery payloads conformes HA (device_info, unique_id, state_topic, availability_topic, command_topic).
- Lien discovery -> topics v2 (state/cmd).
Schema JSON (exemples)
- status:
{ "version": "2.0.0", "os": "linux", "uptime_s": 1234, "last_error": "", "backends": {"power":"logind", "screen":"gnome_busctl"} }
- capabilities:
{ "telemetry": ["cpu_usage","cpu_temp","memory"], "commands": ["shutdown","reboot","sleep","screen"], "gpu": false }
Flux MQTT (Mermaid)
Telemetry:
flowchart LR
subgraph Agent
T[Telemetry Providers] --> M[MQTT Client]
end
M -->|state/<name>| B[Broker MQTT]
M -->|status/capabilities| B
M -->|availability| B
B -->|Discovery| H[Home Assistant]
Commandes:
flowchart LR
H[Home Assistant] -->|cmd/<action>/set| B[Broker MQTT]
B -->|cmd/<action>/set| M[MQTT Client]
M --> C[Command Handlers]
C --> P[Platform Backend]
P -->|result/state| M
M -->|state/<name>| B
Traits internes
TelemetryProvider: read() -> map name->valuePowerControl: shutdown/reboot/sleep/hibernateScreenControl: screen_on/screen_off
Plateformes
- Linux: logind/polkit ou sudoers, gnome busctl ou x11 xset.
- Windows: winapi_session ou external_tool (limite service vs session).