How to debug Mosquitto MQTT

Hi,

I have an ESP8266 setup sending a test MQTT msg to my topic: homeassistant/indoor/temp
I have setup Mosquitto MQTT but nothing registers?
I have tried manually publishing a packet with the Developer-Tools MQTT tool and this DOES work, my front-end monitor shows the state change.

What is the best way of debugging the network side of MQTT?
(Considering i am a noob)

PS. I have tried various apps but they all give connection errors, Im using the same IP as my Home Assistant with port 8083

Try MQTT Explorer… it’s really great.

If you can’t connect then I suspect the ESP8266 can’t either. Port 1883 is the usual port for an MQTT broker.

6 Likes

Sorry, that was a typo, I am using port 1883.
How do i use the link you provided, not sure how to install this? Is there a windows app or android?

Agreed. This is an outstanding debug tool for MQTT.

1 Like

Click on RELEASES and it takes you here.

1 Like

Found the windows installer and have it installed, it connects ok but if I try to post to a topic no data shows up in HA?

Sounds like you have your topics incorrect or your sensors set up incorrectly.

I have this in my configuration.yaml file

discovery:

mqtt:
broker: 192.168.1.18

sensor:

  • platform: mqtt
    state_topic: “homeassistant/indoor/temp”
    name: ‘Indoor Temp’
    unit_of_measurement: “C”

But publishing on homeassistant/indoor/temp in the debug app does not show up in HA

What are you expecting to show up? Where are you expecting it to show up?

Details, my friend. Details.

Is the sensor listed in the dev-state page? Does updating value change state? What value are you changing to? What does it say the state is? Have you restarted home assistant since adding?

So much valuable information has been left out here. :wink:

I like using NodeRED to read MQTT and log MQTT values.

If you’re having issues with the MQTT broker itself look at it’s log files and it usually says if there are socket or auth errors

Yes, sensor is on dev-state page
Yes, when I change the value in the states page the status DOES change
Status is ‘Unknown’ before I manually change it.
Yes, have restarted and refreshed many times.

I was expecting that when I publish a test msg to the topic: homeassistant/indoor/temp using MQTT-Explorer i would see a state change of the sensor on the states page in HA…? Is that not correct?
This is what I am trying to debug.

Thanks

I have searched for a log, where do I access the MQTT log?

For a standard installation the logs are in /var/log/mosquitto/mosquitto.log. Normally the permissions are such that you need to sudo to read it.

Normally in /var/log/ but not always. Normally the log file is listed in the conf file, for example I have mosquitto running as a Synology package, and I’ve specified my log file here

persistence true
persistence_location /volume1/@appstore/mosquitto/var/

log_dest file /volume1/@appstore/mosquitto/var/running.log

include_dir /volume1/@appstore/mosquitto/etc/mosquitto/conf.d

running.log shows any connection errors

/var/log is empty…
I am using Configurator to view directories, is there another way to see hidden files?
There is no mention of a log file in configuration.yaml, does it need to be turned ON first

MQTT usually needs a username and password.

Are you using hassio or some other install?

Yes hassio

So I am not quite sure how username and password work on hassio, I think they are shared with your login details, but not sure.

Anyway, are you using a username and password on the ESP8266? What firmware is it running?

No, I have it set as anonymous.

I just found some MQTT log data on the HASS.IO page, by then clicking on Mosquitto Broker, log data is at the bottom of page. The last two lines are below

1553588677: New connection from 192.168.1.21 on port 1883.
1553588677: New client connected from 192.168.1.21 as mqttjs_9e0fd90e (c1, k60).

This IS the IP I am testing publishing via MQTT-EXPLORER from, I get a connection but just no record of publishing to the topic.
Just checked this log with the 8266 and same thing happening here, I see a record here of connection but see no publish to topic logs records.

What can cause publishing to fail?

Not having read/write access ?