Files
pilot/docs/tests_mqtt.md
Gilles Soulier c5381b7112 Pilot v2: Core implementation + battery telemetry
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>
2025-12-30 06:23:00 +01:00

50 lines
2.0 KiB
Markdown

<!-- Document de tests manuels MQTT pour valider le flux de bout en bout. -->
# Tests MQTT (manuel)
## Pre-requis
- Broker MQTT accessible
- Config YAML valide
- Lancement de `pilot-v2`
- Outil de test: `scripts/mqtt_send.py` (optionnel)
## Checklist
- Availability: `pilot/<device>/availability` publie `online`.
- Status: `pilot/<device>/status` publie un JSON valide, mis a jour sur le heartbeat.
- Capabilities: `pilot/<device>/capabilities` publie un JSON valide.
- Telemetrie: `pilot/<device>/state/cpu_usage` / `memory_*` / `ip_address`.
- Power state: `pilot/<device>/state/power_state` (on/off/sleep/unknown/idle).
- Commandes:
- `pilot/<device>/cmd/shutdown/set` payload `OFF` -> action (dry_run si active).
- `pilot/<device>/cmd/reboot/set` payload `OFF` -> action (dry_run si active).
- `pilot/<device>/cmd/sleep/set` payload `OFF` -> action (dry_run si active).
- `pilot/<device>/cmd/screen/set` payload `ON`/`OFF`.
- Etats commandes:
- `pilot/<device>/state/shutdown` -> `ON` ou `OFF`.
- `pilot/<device>/state/reboot` -> `ON` ou `OFF`.
- `pilot/<device>/state/sleep` -> `ON` ou `OFF`.
- `pilot/<device>/state/screen` -> `ON` ou `OFF`.
- HA discovery: entites visibles dans Home Assistant.
## Exemples d'envoi
```
python3 scripts/mqtt_send.py --host 127.0.0.1 --port 1883 --device monpc --action shutdown --value OFF
python3 scripts/mqtt_send.py --host 127.0.0.1 --port 1883 --device monpc --action screen --value ON
```
## Checklist pas a pas
1. Lancer le binaire (ou `scripts/run_pilot.sh`).
2. Verifier `availability`:
- Topic: `pilot/<device>/availability`
3. Verifier `status`:
- Topic: `pilot/<device>/status`
4. Verifier telemetrie:
- Topic: `pilot/<device>/state/cpu_usage`
5. Envoyer une commande OFF:
- `python3 scripts/mqtt_send.py --device <device> --action shutdown --value OFF`
6. Verifier l'etat commande:
- Topic: `pilot/<device>/state/shutdown`
## Notes
- En mode `dry_run: true`, aucune action systeme n'est executee.
- Verifier les logs pour confirmer la reception des commandes.