Home Assistant: How to Monitor MQTT Traffic with Mosquitto

When sensors or switches send data via MQTT, you often need to know exactly which payloads reach the broker whenever issues arise. While on traditional server setups you can simply run the command mosquitto_sub -v -t '#' in the terminal, Home Assistant offers multiple ways to achieve this. This guide shows you how to track and inspect the traffic passing through your Mosquitto broker.

What You Need

  • Access to your Home Assistant system
  • A configured Mosquitto broker
  • Depending on the method: SSH access or tools like MQTTLens or MQTT Explorer

1. Intercepting MQTT Traffic via Terminal Using mosquitto_sub

If you have the SSH add-on installed, you can log in to your Home Assistant system via SSH and directly use the familiar Mosquitto client.

Loading product data …

Run the following command in the console:

mosquitto_sub -v -t '#'

2. Visual Monitoring with MQTT Explorer or MQTTLens

To keep an organized overview of topics and messages, you can use dedicated graphical tools. For instance, the MQTTLens browser extension or MQTT Explorer allow you to follow message traffic live in a structured interface.

3. Displaying MQTT Messages in Home Assistant Logs

Alternatively, MQTT traffic can be logged directly within the Home Assistant system log without having to keep a console window open.

To do this, add the MQTT component with your desired log level to your logger configuration (for example, in configuration.yaml or a separate logger.yaml):

logger:
  logs:
    homeassistant.components.mqtt: debug

After reloading the configuration, you will find incoming messages in the frontend under Developer Tools in the logs section.

Is It Working?

As soon as a device publishes data, the corresponding topics and payloads will appear in your terminal window or GUI tool. You can test the data flow by subscribing to a topic and publishing a manual test message to that same topic.

Troubleshooting

  • No incoming messages: Verify whether the transmitting device is genuinely connected to the broker’s IP address and that the Mosquitto broker is running actively.

Monitoring allows you to spot transmission errors quickly and process unrecognized MQTT payloads whenever necessary.

Sources: Forum: Home Assistant Community, smarterkram.de, alkly.de

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top