#872 reported '--mqtt: unexpected argument' on the Docker image; prior
attempts chased a Docker *rebuild*, but the real cause was disconnected
*code*: the --mqtt* flags lived only in cli::Args (dead code — referenced
nowhere), while the binary parses a separate main::Args with no mqtt fields,
and main.rs never declared/started the mqtt:: publisher. So MQTT was fully
unwired: flags didn't parse, and the publisher never ran.
Fix:
- Extract the mqtt + privacy flags into a shared
(#[derive(clap::Args)]); retarget mqtt::config::{from_args,build_tls} to it.
- #[command(flatten)] MqttArgs into the binary's main::Args (using the *lib*
crate's type so it matches from_args), so --mqtt* now parse.
- Spawn the publisher on --mqtt: build MqttConfig, validate, and bridge the
existing JSON sensing broadcast into the typed VitalsSnapshot stream the
publisher consumes (defensive serde_json::Value mapping — absent fields
default, never wrong values). #[cfg(feature=mqtt)]-gated; without the
feature --mqtt WARNs and no-ops (documented contract). Fix the
mqtt_publisher example for the new signature.
Verified end-to-end against local mosquitto: publisher connects and emits
20 HA auto-discovery entities + live state (presence ON, person_count, …).
Tests: 577 pass default / 580 pass --features mqtt / 0 fail; both configs
build.
Co-Authored-By: claude-flow <ruv@ruv.net>