mqttImplement MQTT messaging avoiding security, QoS, and connection management pitfalls.
Install via ClawdBot CLI:
clawdbot install ivangdavila/mqtt/ creates empty first level — home/temp not /home/temphome/+/temperature# matches everything including nested — home/# gets home/a/b/c/dpersistence true survives restarts — without it, retained messages and subscriptions lostmax_queued_messages prevents memory exhaustion — one slow subscriber shouldn't crash brokerlistener 1883 0.0.0.0 binds all interfaces — use 127.0.0.1 for local-only# sees all traffic — never in production, leaks everything$SYS/# exposes broker metrics — client count, bytes, subscriptionsmosquitto_sub -v shows topic with message — essential for debuggingGenerated Mar 1, 2026
Implement MQTT for controlling lights, thermostats, and sensors in a residential setting. Use QoS 1 for commands to ensure delivery while handling duplicates idempotently, and set up retained messages for device status updates to provide real-time data to new subscribers. Ensure TLS encryption and client authentication to prevent unauthorized access from external bots.
Deploy MQTT in a factory to monitor machinery health via sensors publishing temperature and vibration data. Use QoS 0 for high-frequency sensor readings to minimize overhead, and design topics like 'factory/machine1/temperature' without leading slashes. Implement ACLs to restrict topic access, preventing compromised devices from reading all data, and use retained messages for last-known values during disconnections.
Utilize MQTT for real-time tracking of vehicles, sending location and fuel data. Employ QoS 2 for critical commands like engine shutdown to avoid duplicates, and set up will messages to flag unexpected disconnects as 'offline'. Configure keep-alive intervals of 60 seconds for timely dead client detection and use TLS to secure credentials over external networks.
Integrate MQTT for medical devices such as patient monitors transmitting vital signs. Use QoS 1 for data transmission to balance reliability and performance, ensuring handlers are idempotent. Design topics with clear hierarchies like 'hospital/room1/heartrate' and avoid wildcards in publishing. Implement persistent connections with clean session false to queue messages during network outages.
Apply MQTT in a farm setting for soil moisture and weather sensors. Use QoS 0 for frequent environmental data to reduce overhead, and set retained messages for sensor readings to persist across subscriber connections. Avoid topic depth limits by keeping hierarchies shallow, and configure Mosquitto with persistence true to retain data after broker restarts.
Offer a cloud-based MQTT broker service with built-in security features like TLS and authentication, targeting small to medium enterprises. Provide analytics dashboards for data visualization and charge subscription fees based on message volume and connected devices. Include support for debugging tools like topic monitoring to enhance user experience.
Provide expert consulting to businesses integrating MQTT into their IoT systems, focusing on avoiding pitfalls like security traps and QoS misunderstandings. Offer custom configuration, training, and ongoing support, with revenue from project-based fees and retainer contracts. Specialize in industries like manufacturing or healthcare for tailored solutions.
Sell pre-configured MQTT-enabled devices, such as sensors or gateways, bundled with software for easy deployment. Include secure broker setups with ACLs and retained message management, targeting DIY enthusiasts and small businesses. Generate revenue through product sales and optional premium support packages for advanced features.
💬 Integration Tip
Always configure TLS and authentication to secure MQTT connections, and design topics without leading slashes to avoid empty levels. Use retained messages cautiously by clearing them with empty payloads to prevent old data confusion.
Control Sonos speakers (discover/status/play/volume/group).
Control Philips Hue lights/scenes via the OpenHue CLI.
Control Eight Sleep pods (status, temperature, alarms, schedules).
BluOS CLI (blu) for discovery, playback, grouping, and volume.
Control Home Assistant smart home devices, run automations, and receive webhook events. Use when controlling lights, switches, climate, scenes, scripts, or any HA entity. Supports bidirectional communication via REST API (outbound) and webhooks (inbound triggers from HA automations).
Use when integrating with Tesla's official Fleet API to read vehicle/energy device data or issue remote commands (e.g. start HVAC preconditioning, wake vehicle, charge controls). Covers onboarding (developer app registration, regions/base URLs), OAuth token flows (third-party + partner tokens, refresh rotation), required domain/public-key hosting, and using Tesla's official vehicle-command/tesla-http-proxy for signed vehicle commands.