Gilles Soulier 60b622c6be Align MQTT discovery with v1 format and HA specification
This commit fixes the MQTT discovery payload structure to match the working
v1 implementation and comply with Home Assistant's MQTT discovery specification.

Key changes:
- Add "type" field to discovery payload (sensor/switch)
- Update discovery topic format: homeassistant/{component}/{node_id}/{entity_name}/config
- Fix entity naming: {metric}_{device} instead of descriptive names
- Separate state topics for sensors vs switches:
  * Sensors: pilot/{device}/{metric} (no /state suffix)
  * Switches: pilot/{device}/{metric}/state (with /state suffix)
- Add per-entity availability topics: pilot/{device}/{metric}/available
- Add publish_switch_state() function for proper switch state publishing

Discovery topic examples:
- homeassistant/sensor/asus/cpu_usage_asus/config
- homeassistant/switch/asus/shutdown_asus/config

State topic examples:
- pilot/asus/cpu_usage (sensor)
- pilot/asus/shutdown/state (switch)

This matches the Dell 5520 v1 configuration that works correctly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-30 08:14:44 +01:00
2024-09-02 12:38:05 +02:00
2024-09-02 12:38:05 +02:00
2024-09-02 12:37:13 +02:00
2024-09-02 12:38:05 +02:00
2024-09-02 12:38:05 +02:00
2024-04-14 07:45:02 +02:00

Aorus

Description

installe un service qui creer des entites pour home assistant:

  • etat de la batterie
  • button pour eteindre le pc
  • reboot
  • eteindre l'ecran
  • cpu
  • memory
  • adresse ip
  • cpu frequency

Prérequis

installation de python3 et de python-env:

sudo apt install python3-venv
python3 -m venv monenv

activation de l'environnement:

source monenv/bin/activate

Installation

git clone http://10.0.1.200/pilot/aorus.git
cd aorus

Création de l'environnement:

python3 -m venv monenv

Activation de l'environnement:

source monenv/bin/activate

Installation des paquets additionnels:

pip install -r requirements.txt

Test du programme

python3 main.py

Sortie de l'environnement:

deactivate

Installation en temps que service

authorisation de shutdown: ajouter a la fin du fichier

sudo visudo
gilles ALL=(ALL) NOPASSWD: /sbin/shutdown
gilles ALL=(ALL) NOPASSWD: /sbin/reboot
gilles ALL=(ALL) NOPASSWD: /usr/bin/tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed

Installation du service en manuel:

sudo cp mqtt_pilot.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable mqtt_pilot.service
sudo systemctl start mqtt_pilot.service
sudo systemctl status mqtt_pilot.service

lancer l'installation du service:

sudo ./install.sh

PILOT v2 (Rust) FUNCTIONAL

Status: Core implementation complete and tested. Ready for feature development.

Quick Start

# Start MQTT broker (Docker required)
./scripts/start_mqtt_broker.sh

# Run pilot v2
./scripts/run_pilot.sh

# In another terminal, monitor messages
./scripts/monitor_mqtt.sh

# Send a test command
docker exec pilot-mosquitto mosquitto_pub -t "pilot/pilot-device/cmd/screen/set" -m "OFF"

Documentation

Configuration

Example config: config/config.example.yaml

Key settings:

  • MQTT broker connection
  • Telemetry interval (default: 10s)
  • Commands allowlist
  • Dry-run mode (safety during development)
  • Platform backends (power and screen control)

Development

# Run tests
cd pilot-v2 && cargo test

# Build release
cd pilot-v2 && cargo build --release

# Check code
cd pilot-v2 && cargo check

Features (v2)

Working:

  • MQTT connectivity with LWT
  • YAML configuration
  • Telemetry (CPU, memory, IP, battery*)
  • Power commands (shutdown, reboot, sleep)
  • Screen control (on/off)
  • Home Assistant auto-discovery
  • Command allowlist and cooldown
  • Dry-run mode for safe testing

* Battery telemetry: Linux only, auto-detected

Planned (see roadmap):

  • CPU temperature
  • Battery support for Windows
  • GPU telemetry
  • Windows backend implementation
  • TLS/SSL support
  • Integration tests
Description
No description provided
Readme 607 MiB
Languages
HTML 68.1%
D 21%
Rust 9.5%
Python 0.8%
JavaScript 0.3%
Other 0.3%