Use when debugging or working with MQTT in Home Assistant — listening to topics to see what devices actually publish, inspecting MQTT device discovery, or publishing a message — through HA NOVA Relay.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Mqtt?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/markusleben-mqtt)
---
name: mqtt
description: Use when debugging or working with MQTT in Home Assistant — listening to topics to see what devices actually publish, inspecting MQTT device discovery, or publishing a message — through HA NOVA Relay.
license: MIT
compatibility: Requires the ha-nova CLI (run 'ha-nova setup' first) and the HA NOVA Relay in Home Assistant (App, or standalone container on Container/Core).
---
# HA NOVA MQTT
## Scope
MQTT work through Home Assistant's own MQTT integration:
- listen to a topic for a bounded window to see what is actually being published (the "is my device even talking?" question)
- inspect MQTT discovery/debug info for a device
- publish a message to a topic
Not in scope: the MQTT broker's own configuration, Zigbee2MQTT's web UI, or creating MQTT-based automations (`ha-nova:write`).
## Bootstrap (once per session)
Read and follow `../ha-nova/session-bootstrap.md`.
Bounded subscription windows are guaranteed by the skills' enforced relay floor (`../ha-nova/relay-api.md` -> Bounded Event Collection). If a relay-outdated warning appeared, have the user update the NOVA Relay instead of working around it — an older relay silently ignores `on_limit`, which turns a normal quiet window into a hard error.
Requires the `mqtt` integration: check `GET /api/components` for `mqtt`. If it is absent, say so — this skill cannot add it.
## Relay Contract
- `ha-nova relay ws --data-file <payload-file>` for WS commands
- `ha-nova call mqtt.publish --skill ha-nova:mqtt --data-file <payload-file>` to publish — typed (Zigbee2MQTT's permit_join: `../integration-setup/pairing.md`): show its preview, then follow the result's `next_step` (`ha-nova apply [--confirm <code typed in chat>] --plan <id>`) (exit codes: `../service-call/SKILL.md` → Flow)
- `--out <result-file>` for large windows; `--jq-file <filter-file>` for filtering
## Listening (bounded window)
MQTT topics never emit a "finish" event, so a listen is a WINDOW, not a request. Use the envelope in window mode:
```json
{
"message": { "type": "mqtt/subscribe", "topic": "zigbee2mqtt/#" },
"collect_events": { "max_events": 50, "timeout_ms": 8000, "on_limit": "return" }
}
```
- The relay unsubscribes when the window closes; nothing keeps running.
- `.data.events` holds what was seen. `.data.truncated: true` means the window ended at a LIMIT — either `max_events` or `timeout_ms`, the relay does not distinguish them — not that the stream stopped. Compare the event count with `max_events` to tell them apart: at the cap it hit the event limit (there may be more traffic); below it the window simply ran out of time, which is the normal ending for a quiet topic.
- An EMPTY result is a real answer ("nothing published on that topic in 8 seconds"), not a failure — report it as such. That is often the actual diagnosis.
- **Retained messages are NOT live traffic.** The broker replays every retained message to a new subscriber immediately, so a message can arrive in the first milliseconds of the window even though the device published it days ago and is now silent. Each event carries a `retain` flag: treat `retain: true` as broker state, not as evidence that the device is sending. For the question "is my device actually publishing?", only `retain: false` messages count — and if all you saw were retained ones, say exactly that (the device is silent; the broker is holding its last value).
- Keep windows short (<= 10 s, the relay's ceiling) and topics as narrow as possible; `#` on the root is noise, not evidence.
## User-Assisted Capture
When the traffic needs the user to act (press the remote, trip the sensor), the window cannot wait for them — it starts with the call and the relay caps it at ~10 s (context skill → User-Assisted Readiness):
1. Name the exact action and topic first, and ask if the user is ready.
2. On "ready": announce "listening for the next ~10 s — act now" and open the window in the same turn.
3. A missed capture after the action — an empty window OR one holding only retained replays (`retain: true`) — means re-arm and retry once before reporting "nothing arrived"; never call the device silent on one missed window.
Never instruct the physical action before the ready-check, and never claim monitoring is active without an open window.
## Zigbee2MQTT Bridge Observability (read-only)
Zigbee2MQTT publishes its network state on retained `zigbee2mqtt/bridge/...` topics (`bridge/devices`, `bridge/info`, `bridge/state`). A bounded listen on one of them returns the retained replay immediately — here `retain: true` IS the answer (broker-held state), not a liveness signal. Use it for "which devices does my Zigbee network have / is the bridge online" questions. Bridge WRITES (rename, permit_join) are not covered here. ZHA and Z-Wave setups have no MQTT surface — route them to `ha-nova:fallback` (Zigbee / Z-Wave network status).
## Flow
1. Clarify the topic. Prefer the narrowest one that answers the question (`zigbee2mqtt/<device>` beats `zigbee2mqtt/#`).
2. Listen in a bounded window (above). Summarize: which topics appeared, how many messages, and — separately — how many were live (`retain: false`) versus retained replays. Quote at most a few payloads.
3. Device discovery/debug: WS `{"type":"mqtt/device/debug_info","device_id":"<device_id>"}` shows the subscribed topics and discovery payloads for one MQTT device (resolve `device_id` from the device registry, never guess it).
4. Publishing (mutating): service `mqtt.publish` with `topic`, `payload`, `qos`, `retain`. There is no `payload_template` field in the current schema — render any template yourself and send the finished string as `payload`. (`evaluate_payload: true` only tells HA to evaluate a Python-literal payload for raw bytes; it is not a template switch.) Plan it; confirm its exact topic + payload once.
5. Verify a command/`set` publish: when the topic belongs to an HA-known device, read the affected entity's state back after a moment — a broker accept is not device confirmation; if HA shows no corresponding change, say so. For topics HA does not mirror, state plainly that HA-side verification is not possible.
## Publishing Safety (read before any publish)
- A **retained** message (`retain: true`) persists on the broker and is re-delivered to every future subscriber — including Home Assistant's discovery layer. A wrong retained payload on a `homeassistant/...` discovery topic can create or destroy entities and keeps doing so after a restart.
- Publishing to a device's `set`/command topic actuates real hardware. Preview it as an action, not a message.
- Clearing a retained message means publishing an EMPTY payload to the same topic with `retain: true` — say this explicitly when a retained message is the problem.
- Retained-discovery cleanup clears only the broker side; the dead entity-registry entries it leaves behind are the registry-side sibling cleanup in `ha-nova:maintenance`.
## Error Handling
Full relay/upstream error taxonomy: `../ha-nova/relay-api.md` -> Error Handling. MQTT specifics:
- `UNSUPPORTED_WS_TYPE` on `mqtt/subscribe`: check YOUR request first. A BARE `mqtt/subscribe` is rejected by every relay version — that is by design, and it means the subscription was not wrapped in a `collect_events` envelope. Fix the request. Only if the request WAS enveloped does this error mean the relay predates bounded windows; confirm with `ha-nova relay health` before telling the user to update the App.
- `400 VALIDATION_ERROR` mentioning `on_limit`: never expected — an older relay ignores the field silently rather than rejecting it, so this points at a malformed envelope.
- `UPSTREAM_WS_TIMEOUT` in window mode means the subscription never even established (broker down, integration not loaded) — that is different from an empty window, and worth saying plainly.
- `mqtt/device/debug_info` needs a device_id from the device registry; an entity_id is rejected.
- Publish denied (`.data.status` 401): admin-only since HA 2026.10; a standalone `HA_LLAT` needs an admin owner.
## Output Format
Apply `../ha-nova/output-rules.md`: plain words, HA names verbatim; unless asked or names clash, no ids, "entity", modes, Relay/HA URLs, snapshots, raw JSON. Previews, deletes, and results use the Cards defined there (`../ha-nova/output-cards.md`).
Render the Report shape (output-cards.md). For a listen: the topic, the window length, how many messages arrived (live versus retained — never merge those two), the distinct topics, a few representative payloads. Say explicitly when nothing arrived, and when everything that arrived was a retained replay. For a publish: the topic, payload, and whether it was retained.
## Safety
- Safety Core: before any write, apply `../ha-nova/safety-core.md`; not yet in this conversation → read it first; unreadable or incomplete → stop and write nothing.
- Drafts follow `../ha-nova/smallest-solution.md`: the complete requested outcome in the simplest safe design, nothing speculative.
- Retained publishes and command/`set` topics take the one-time code; the CLI puts every publish on the typed tier, except Zigbee2MQTT's permit_join (`../integration-setup/pairing.md`).
- Never publish to `homeassistant/...` discovery topics unless the user explicitly asks and understands that it can create or delete entities.
## Guardrails
- One topic per window; one publish per `ha-nova call`. A retained-discovery cleanup is several `ha-nova call mqtt.publish` plans, each its own typed plan with its own `say` ask — one reply each in manifest order per `../ha-nova/batch-safety.md` (no shared batch code): one resolved device, topics taken only from `mqtt/device/debug_info`, never guessed or globbed; command/`set` topics always stay single-target.
- Windows are bounded by the relay (max 100 events / 10 s) — never claim continuous monitoring.
- Never guess a `device_id` or invent a payload schema; read what the device actually publishes first.