π‘ MQTT Protocol
The Station's backend runs an MQTT broker. ESP32 devices connect to it for telemetry and commands.
Topic Mapβ
Topic Referenceβ
All topics are scoped: station/{stationId}/device/{deviceId}/<suffix>.
| Direction | Topic | Payload |
|---|---|---|
| Device β Backend | .../state | {"state": {...}} |
| Device β Backend | .../event | {"event": "device_event"|"user_event", "data": {"action":"..."}} |
| Device β Backend | .../heartbeat | {"status": "online"} (auto by SmartHomeCore) |
| Device β Backend | .../handshake | {"type":"...","firmwareVersion":"...","chip":"..."} |
| Backend β Device | .../handshake/ack | {"status":"ok"} or {"status":"unknown_device"} |
| Backend β Device | .../command | {"action":"...", ...} |
Payloadsβ
Stateβ
{"state": { ... }} β JSON object with sensor/actuator values. Keys match capability names from the Device Type Registry.
Eventβ
{"event": "device_event", "data": {"action": "motion_detected"}}
{"event": "user_event", "data": {"action": "button_press"}}
Commandβ
{"action": "toggle"}
{"action": "set_brightness", "brightness": 75}
Built-in commands (handled by SmartHomeCore): reboot, factory_reset, ota_update.
Lifecycleβ
LWT (Last Will and Testament)β
SmartHomeCore sets LWT on MQTT connect β publishes {"status":"offline"} to the heartbeat topic on unexpected disconnect, so Backend can mark the device offline immediately.