So that is the general question, but I'll provide the scenario here.

I'm running Mosquitto server to provide mqtt comm between esp relay modules (Sonoff from Itead) and Home Assistant. Most of the time, it works just fine. Each module has its own topic, and there are as many "light" configurations in HASS as modules, so they can be controlled from the web frontend by individual toggle buttons.

I've experienced, though, inconsistent state situations where the light is actually on and the toggle in HASS is shown as off (and the opposite situation as well). By inspecting logs I've found that Mosquitto is not publishing certain messages to HASS (which should be subscribed to all module state topics). More specifically, given 4 modules and its corresponding state topics (state/sonoff_xx/POWER), HASS seems to be subscribed only to modules 2 and 4 topics, but not 1 and 3. The following is the expected behavior for module 4, the same can be verified for the other working module, but publishing to HASS is missing for the other two.

Jun 15 19:22:46 nas mosquitto[9486]: Received PUBLISH from sonoff4 (d0, q0, r1, m0, 'stat/sonoff4/POWER', ... (2 bytes))
Jun 15 19:22:46 nas mosquitto[9486]: Sending PUBLISH to home-assistant (d0, q0, r0, m0, 'stat/sonoff4/POWER', ... (2 bytes))

This is not a question regarding HASS and the relay modules, but it is about how to dig into the status of MQTT Server that is supposed to have certain clients subscribed but, by looking at the logs, it has not.

2 Answers 2


No, you can no get list of which clients are subscribed to what out of mosquitto.

What is most likely here is that HASS is not subscribing rather than mosquitto not publishing to a subscribed client.

You can get mosquitto to log each time a subscription request is which made which you could then use to build a list.

log_type subscribe, unsubscribe

This will log all which clients subscribe/unsubscribe from what topics.

  • 1
    I'm already logging all levels (log_type all in mosquitto.conf), actually I've checked the subscribe entry by connecting from a console while having journalctl -f running. I couldn't find, though, entries about HASS subscriptions because that might happened days ago and journald is not configured as persistent, so I had at hand only current boot. That's the reason why I hoped to inspect Mosquitto status.
    – Dario
    Jun 16, 2017 at 14:22
  • 1
    Shouldn't you focus on QoS level. My guess is that the messages sent from the nodes (Sonoff units) are being sent using QoS=0 meaning it is sent only once. Not reliable in that sense. I would try to bump this value until I find a a good level. Switch states should be using QoS 1 or 2 in my opinion. Sensor values which is ok to miss one or two once in a while should use QoS 0. Jun 17, 2017 at 6:37

You can Enable mosquitto log for all and subscribe to the log you will find messages that you can decode for every client action like connecting, disconnecting, subscribing and publishing even errors.

you will set

log_dest topic
log_type all

in mosquitto.conf then you will subscribe to

  • I tired this approach Subscribing and publishing events are not shown
    – kavie
    Aug 2, 2019 at 8:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.