MQTT Subscribe to topic (Solved)

Hi!
I’ve installed the mqtt addon and i’m wondering how i do to subscribe to a topic?

I have a mysensors mqtt gateway that publishes on a specific topic and i want to listen to that topic with the hass.io addon mqtt broker. but i cannot use the mosquitto_sub command as i’ve done before on debian.

EDIT: Added more info.

1 Like

You deifine a MQTT component and the state topic is what is subscribed to.

If you just want to trigger an automation, you can also use an MQTT Trigger, which subscribes to that topic.

Hi!

When i’m setting up an mqtt component in my configuration.yaml i get mqtt error address already in use because i already installed the hass.io addon.

I uninstalled the addon and used the mqtt component in configuration.yaml for now.

You need to specify the broker option, overwise the embedded mqtt broker is launched.

Your configuration should look like :

mqtt:
    broker: localhost
    # if it doesn't work try brocker: 172.17.0.1
1 Like

Thank you so much, it works!

I tried it with the ip-adress to my device but that didn’t work but never thought of to try localhost.

Thank you again.

this address? I thought 127.0.0.1 …no?

This is the docker internal ip for the host. If localhost doesn’t work, 127.0.0.1 will not work either.

ahhh now I get it, thanks. Definetely documentation lacks information/tutorials

Sorry, a bit of a necro-post (and possibly a n00b question as Im fairly new to MQTT)

I have a bunch of devices all subscribed to my hass.io Mosquitto broker, but one of them is a publisher (I can subscribe to it from a random PC on my network using mosquitto_sub -h 10.0.0.44 -t "#") - is it possible for hass.io Mosquitto broker to subscribe to the feed from the publisher on that machine?

Just create a sensor or binary_sensor to listen to the published messages.