No topics on Mosquitto

Just recently I started using HA and the possibilities are fantastic. I just received a ESP8266 which I equipped with a temperature/humidity sensor for testing, but I am unable to read data from it. It is running Tasmota and in the console I can read that it connects to the broker and I can read:

23:50:16 MQT: tele/sonoffTest/SENSOR = {“Time”:“2019-05-24T23:50:16”,“AM2301”:{“Temperature”:23.2,“Humidity”:34.6},“TempUnit”:“C”}

This shows that the sensor is working and that it publishes information.

In Home Assistant I have installed Mosquitto broker via the add-ons. The config I use here is:

{
“logins”: [],
“anonymous”: true,
“quiet_logs”: true,
“customize”: {
“active”: false,
“folder”: “mosquitto”
},
“certfile”: “fullchain.pem”,
“keyfile”: “privkey.pem”
}

This is for testing purposes so I don’t need any security/credentials for now.
The log of Mosquitto shows:

1558737193: mosquitto version 1.5.6 starting
1558737193: Config loaded from /etc/mosquitto.conf.
1558737193: |-- *** auth-plug: startup
1558737193: Opening ipv4 listen socket on port 1883.
1558737193: Opening ipv6 listen socket on port 1883.
1558737193: Opening websockets listen socket on port 1884.
1558737193: Warning: Mosquitto should not be run as root/administrator.
1558737193: New connection from 172.30.32.1 on port 1883.
1558737193: New client connected from 172.30.32.1 as mosqsub|22-core-ssh (c1, k60).
1558737193: New connection from 192.168.1.100 on port 1883.
1558737193: New client connected from 192.168.1.100 as mqtt-explorer-0c365cf7 (c1, k60).
1558737200: New connection from 192.168.1.19 on port 1883.
1558737200: New client connected from 192.168.1.19 as 0 (c1, k10).
1558737208: New connection from 192.168.1.103 on port 1883.
1558737208: New client connected from 192.168.1.103 as 1a6a1923-1069-4420-b3fa-f9e469425ec8 (c1, k60).

It could be interesting to know that the IP addresses are:
172.30.32.1 > An SSH instance to the Raspberry Pi running HA.
192.168.2.100 > The desktop I am working on.
192.168.2.19 > ESP8266 device.
192.168.1.103 > Home Assistant

This indicates that there is no problem in connecting to the broker and it also shows that the broker is running.

Via SSH I am connected to the Raspberry Pi. Here I run:

mosquitto_sub -h 192.168.1.103 -v -t “#”

As far as I can tell this works, because I get no error messages. That being said I also don’t get any other messages. Nothing happens. It looks to me like there are no topics published to the broker.
Via my dekstop I am connected to the broker via MQTT Explorer, but here I also see nothing.

My configuration.yaml looks like:

mqtt:
broker: 192.168.2.103
port: 1883
discovery: true

logger:
default: warning
logs:
homeassistant.components.mqtt: debug

sensor:

  • platform: mqtt
    name: “Temperature”
    state_topic: “tele/sonoffTest/SENSOR”
    unit_of_measurement: “°C”
    value_template: “{{ value_json.AM2301.Temperature }}”
  • platform: mqtt
    name: “Humidity”
    state_topic: “tele/sonoffTest/SENSOR”
    unit_of_measurement: “%”
    value_template: “{{ value_json.AM2301.Humidity }}”
  • platform: mqtt
    name: “MQTT Time”
    state_topic: “tele/sonoffTest/SENSOR”
    value_template: “{{ value_json.Time }}”

In Home Assistant I see that no value is being read from the ESP8266 since there are no values for Temperature, Humidity and Time in History.

When I go in Home Assistant to services and the mqtt.publish service with service data:

{
“topic”:“home-assistant/switch/1/on”,
“payload”:“Switch is ON”
}

then I see the following line in the log:

2019-05-25 01:14:32 DEBUG (MainThread) [homeassistant.components.mqtt] Transmitting message on home-assistant/switch/1/on: Switch is ON

There is, however, no other sign that MQTT is working. Also mosquitto_sub and MQTT Explorer remain quiet.

I am unable to find why I am unable to read topics from the broker. It probably is just a beginners mistake, but I cannot find it. Does anyone have a suggestion to solve this issue?

if you can’t see it in MQTT explorer it’s not getting to the broker.

Thank you for the reply. I finally solved the problem.
I used no credentials to connect to the broker and this apparently did not work. When I turned off anonymous log in and connected to the broker with a username and password everything worked.

So what did the broker mean when it reported “New client connected”?

That is a good question. I don’t understand it either and this is also the reason that I thought initially that there was no issue in the connection.
Maybe someone with a good knowledge of MQTT/Mosquitto can share his thoughts about this?

My question was rhetorical; the log messages mean precisely what they report. The broker reported all of these clients had established a connection:
172.30.32.1 > An SSH instance to the Raspberry Pi running HA.
192.168.2.100 > The desktop I am working on.
192.168.2.19 > ESP8266 device.
192.168.1.103 > Home Assistant

A Mosquitto broker can definitely be configured to run in anonymous mode which doesn’t require authentication. The fact it did not appear to communicate with your clients implies some other factor was in effect. Unfortunately, given the available information, I can’t identify it.