Mqtt add-on works but no discovery

Hi,

I’m trying to get MQTT auto discovery working. As far as I can see, HA is not listening on the “homeassistant/#” topic.

I have the MQTT Mosquitto integration installed. MQTT integration has “Enable newly added entities.” switch turned on.

MQTT broker has the default configuration and it is working except for discovery.
I have some MQTT lights configured manually in “light.yaml” like:

- platform: mqtt
  schema: json
  name: Livingroom
  state_topic: "mydomain/light/Livingroom/state"
  command_topic: "mydomain/light/Livingroom/set"
  brightness: true
  brightness_scale: 100
  optimistic: false
  qos: 0

These lights work fine and I can control them with something like:

mosquitto_pub -h 127.0.0.1 -p 1883 -t "mydomain/light/Lavanderia/set" -m '{"state":"ON","brightness":50,"indicator":"ON"}' -u USER -P PASS

The log shows:

2020-11-02 23:50:41 INFO (MainThread) [homeassistant.setup] Setting up mqtt
2020-11-02 23:50:41 INFO (MainThread) [homeassistant.setup] Setup of domain mqtt took 0.0 seconds
2020-11-02 23:50:43 INFO (Thread-5) [homeassistant.components.mqtt] Connected to MQTT server core-mosquitto:1883 (0)
2020-11-02 23:50:43 INFO (MainThread) [homeassistant.components.light] Setting up light.mqtt
2020-11-02 23:50:47 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to mydomain/light/Livingroom/state, mid: 21

I am testing MQTT discovery with the example in the documentation (MQTT - Home Assistant) using mosquitto:

mosquitto_pub -h 127.0.0.1 -p 1883 -t "homeassistant/binary_sensor/garden/config" -m '{"name": "garden", "device_class": "motion", "state_topic": "homeassistant/binary_sensor/garden/state"}' -u USER -P PASS

And also with

Developer tools > MQTT > Publish a packet

topic: "homeassistant/binary_sensor/garden/config"
payload: '{"name": "garden", "device_class": "motion", "state_topic": "homeassistant/binary_sensor/garden/state"}'

The log only shows the transmission, but is not receiving:
2020-11-03 00:51:21 DEBUG (MainThread) [homeassistant.components.mqtt] Transmitting message on homeassistant/binary_sensor/garden/config: '{"name": "garden", "device_class": "motion", "state_topic": "homeassistant/binary_sensor/garden/state"}', mid: 43

I am running:

  • HassOS 4.15
  • Home Assistant 0.117.2
  • Mosquitto broker 5.1

With debug enabled in the logger (configuration.yaml):

logger:
  default: info
  logs:
    homeassistant.components.mqtt: debug
    custom_components.my_integration: debug

It was also not working before my last update.
I have tried changing the “Enable newly added entities.” switch on and off and configuring discovery manually:

mqtt:
    discovery: true
    discovery_prefix: homeassistant

I have tried the examples in MQTT auto discovery isn't working, but messages are visible with no success.

Anybody got any idea what I am missing?

Regards,
JA

Your log seems to show a message on /homeassistant It should be homeassistant - no leading slash.

Thanks for the quick response nick.
The leading slash was a mistake. At some point I was trying with slashes after a lot of other options.

Anyway, I already fixed the problem. In the end I uninstalled the add-on and installed it again. My guess is that just deleting the configuration was enough, but I couldn’t find which file to delete.

Thanks,
JA