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>
This commit is contained in:
9
scripts/monitor_mqtt.sh
Executable file
9
scripts/monitor_mqtt.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
# Monitor all MQTT messages for debugging
|
||||
set -euo pipefail
|
||||
|
||||
echo "Monitoring all MQTT topics..."
|
||||
echo "Press Ctrl+C to stop"
|
||||
echo ""
|
||||
|
||||
docker exec -it pilot-mosquitto mosquitto_sub -v -t '#'
|
||||
34
scripts/mqtt_send.py
Normal file
34
scripts/mqtt_send.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# Script simple pour publier des commandes MQTT (tests manuels).
|
||||
import argparse
|
||||
import time
|
||||
|
||||
import paho.mqtt.client as mqtt
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Envoi de commandes MQTT pour pilot-v2")
|
||||
parser.add_argument("--host", default="127.0.0.1")
|
||||
parser.add_argument("--port", type=int, default=1883)
|
||||
parser.add_argument("--device", required=True)
|
||||
parser.add_argument("--action", required=True, choices=["shutdown", "reboot", "sleep", "screen"])
|
||||
parser.add_argument("--value", required=True, choices=["ON", "OFF"])
|
||||
parser.add_argument("--username", default="")
|
||||
parser.add_argument("--password", default="")
|
||||
args = parser.parse_args()
|
||||
|
||||
topic = f"pilot/{args.device}/cmd/{args.action}/set"
|
||||
|
||||
client = mqtt.Client()
|
||||
if args.username or args.password:
|
||||
client.username_pw_set(args.username, args.password)
|
||||
|
||||
client.connect(args.host, args.port, 60)
|
||||
client.loop_start()
|
||||
client.publish(topic, args.value, qos=0, retain=False)
|
||||
time.sleep(0.5)
|
||||
client.loop_stop()
|
||||
client.disconnect()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
18
scripts/run_pilot.sh
Executable file
18
scripts/run_pilot.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
# Lance pilot-v2 en mode local avec config.yaml dans le dossier courant.
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "$ROOT_DIR/pilot-v2"
|
||||
|
||||
if [ ! -f "config.yaml" ]; then
|
||||
if [ -f "../config.yaml" ]; then
|
||||
cp ../config.yaml config.yaml
|
||||
echo "config.yaml copie depuis la racine"
|
||||
elif [ -f "../config/config.example.yaml" ]; then
|
||||
cp ../config/config.example.yaml config.yaml
|
||||
echo "config.yaml cree a partir de config/config.example.yaml"
|
||||
fi
|
||||
fi
|
||||
|
||||
cargo run
|
||||
28
scripts/start_mqtt_broker.sh
Executable file
28
scripts/start_mqtt_broker.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
# Start MQTT broker for development and testing
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
echo "Starting Mosquitto MQTT broker..."
|
||||
docker compose -f docker-compose.dev.yml up -d
|
||||
|
||||
echo "Waiting for broker to be ready..."
|
||||
sleep 2
|
||||
|
||||
echo "Testing broker connection..."
|
||||
docker exec pilot-mosquitto mosquitto_sub -t test -C 1 &
|
||||
sleep 1
|
||||
docker exec pilot-mosquitto mosquitto_pub -t test -m "Hello"
|
||||
|
||||
echo ""
|
||||
echo "✅ MQTT broker is running!"
|
||||
echo " Broker: localhost:1883"
|
||||
echo " WebSocket: localhost:9001"
|
||||
echo ""
|
||||
echo "To monitor all messages:"
|
||||
echo " docker exec pilot-mosquitto mosquitto_sub -v -t '#'"
|
||||
echo ""
|
||||
echo "To stop the broker:"
|
||||
echo " docker compose -f docker-compose.dev.yml down"
|
||||
Reference in New Issue
Block a user