[SOLVED][MQTT] Unable to read topic/payload in home assistant

Hi,

I’ve been using home assistant for a couple of months, but it is the first time I’m trying to integrate a device using MQTT. In short I am unable to read out the devices in home assistant, even though I can successfully read the message sent from the devices using an external client (MQTTLens)

The broker I am using is mosquitto through the home assistant addon. I have followed the steps detailed in the documentation to setup ACL and am using anonymous mode.
The devices are a series of coils from a modbus PLC. Through Modbridge I can read these inputs and push any updates of those through MQTT.

As I wrote above, when I use MQTT lens, pointing to the broker in home assistant, I receive all messages correctly. (note: when I input credentials of the user I created in HA instead of leaving it blank, I don’t receive the messages, I don’t know why, but I thought it is worth mentioning. Maybe that’s the issue, but how can I solve this?)

As you can see, the topic the device sends is the input number (here Coil31) with a payload ‘trigger’.

Here come the issues:

  • I have tried defining a sensor in my configuration file, but I seems like it doesn’t receive any data, it stays blank.
sensor:
  - platform: mqtt
    name: "MQTTtest"
    state_topic: "Coil31"
  • When I use mqtt.publish through the developer tools, I don’t see the message in MQTT lens, but I can see the message in HA.

Any help would be greatly appreciated.

Many thanks,

Tom

Seems those 2 don’t use the same broker ?

Hi Francis, thanks for your reply.

In MQTTLens I set the broker to the ip address of my Rpi running HA, port 1883. Would that not be the same broker as is used within HA itself when using mqtt.publish service?

Because of this. What broker do you use ?

I’m using Mosquitto broker running as an addon on Home Assistant.

image

Try setting it false

1 Like

No luck :frowning:

Found the issue should somebody stumble on the same problem.

For one reason or another, home assistant could not connect to the broker (in the MQTT addon log there was a message [WARN] Not found homeassistant on local database).
Fix was remove MQTT addon and integration, restart HA, and add MQTT again. Afterwards everything worked.

edit: to be complete, I also had to set anonymous and active to false (default settings)