Skip to main content

MQTT Topic Designer

v1.0.0

Topic hierarchy designer — wildcards, retained messages, QoS choice, ACL patterns.

MQTT Topic Hierarchy
# MQTT Topic Hierarchy: acme

## Structure
acme/{location}/{device-type}/{device-id}/{subtopic}

## Topic Patterns
| Topic | Purpose | QoS | Retained |
|---|---|---|---|
| `acme/+/thermostat/+/state` | Device state | 1 | yes |
| `acme/+/thermostat/+/telemetry` | Sensor readings | 1 | no |
| `acme/+/thermostat/+/cmd` | Commands to device | 1 | no |
| `acme/+/thermostat/+/log` | Device logs | 0 | no |
| `acme/+/motion-sensor/+/state` | Device state | 1 | yes |
| `acme/+/motion-sensor/+/telemetry` | Sensor readings | 1 | no |
| `acme/+/motion-sensor/+/cmd` | Commands to device | 1 | no |
| `acme/+/motion-sensor/+/log` | Device logs | 0 | no |
| `acme/+/door-lock/+/state` | Device state | 1 | yes |
| `acme/+/door-lock/+/telemetry` | Sensor readings | 1 | no |
| `acme/+/door-lock/+/cmd` | Commands to device | 1 | no |
| `acme/+/door-lock/+/log` | Device logs | 0 | no |
| `acme/+/camera/+/state` | Device state | 1 | yes |
| `acme/+/camera/+/telemetry` | Sensor readings | 1 | no |
| `acme/+/camera/+/cmd` | Commands to device | 1 | no |
| `acme/+/camera/+/log` | Device logs | 0 | no |

## Wildcards
- `+` matches one level: `acme/floor1/+/abc/state`
- `#` matches all below: `acme/floor1/#` (use only for subscriptions)

## Example Payload
```json
{
  "deviceId": "dev-001",
  "value": 21.5,
  "unit": "celsius",
  "ts": 1781003471671
}
```

## Best Practices
- Use lowercase, hyphen-separated names
- Never use spaces in topics
- Limit depth to 5-6 levels maximum
- Use retained messages only for last-known-state topics