MQTT Node: Subscribing to `+/+/$homie` does not work?

Hi, I'm trying to get to grips with Homie better in Node-RED.

The Homie convention says that controllers must subscribe to +/+/$homie in order to auto-discover the homie root topic.

Unfortunately, using the MQTT-in node, it doesn't appear as though this works?

+/<devname>/$homie works as does <something>/+/$homie even <something>/+/+ works, just not +/+/<something>

Is this a bug?

Can you have a wildcard at the start of a subscription?

Yeah. Its possible to sub to # at least it is if the broker permits it. Some don't (or it's an option)

Yes, that is fine. And +/something/somethingelse works.

Have you tried another client?

Yes, works fine with MQTT-Spy.

In fact +/+/+ also works in MQTT-Spy :slight_smile:

Well, I shall step up and say I am seeing similar things with what I am doing.

I won't say it is exactly the same, but I am seeing problems with retained messages not being seen on a machine when it boots.
ie: I boot a machine and it doesn't seem to get all/any of the retained MQTT messages that are on the BROKER (main MQTT computer).

But I'll shut up now as I don't want to confuse the problem.

Oh! +/+/+ actually works in Node-RED. Even stranger then.

Urm, this is bonkers. Other things like +/+/$state work, just not +/+/$homie

Hi Julian,

I can't reproduce this.

Here I have a node subscribed to +/+/$homie and a node subscribed to +/b/$homie
When I publish to a/b/$homie I see both nodes receive the message.

[{"id":"fe3d0902.971a58","type":"inject","z":"683f0662.e6d798","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":360,"y":320,"wires":[["ef4eae89.c5447"]]},{"id":"a1656b27.2292e8","type":"mqtt in","z":"683f0662.e6d798","name":"","topic":"+/+/$homie","qos":"2","datatype":"auto","broker":"8db984ef.0e77e8","x":350,"y":100,"wires":[["3d3ace8e.2ade72"]]},{"id":"3d3ace8e.2ade72","type":"debug","z":"683f0662.e6d798","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":560,"y":100,"wires":[]},{"id":"539a1f25.cede7","type":"mqtt in","z":"683f0662.e6d798","name":"","topic":"+/b/$homie","qos":"2","datatype":"auto","broker":"8db984ef.0e77e8","x":350,"y":180,"wires":[["5d7eed7.e838814"]]},{"id":"5d7eed7.e838814","type":"debug","z":"683f0662.e6d798","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":550,"y":180,"wires":[]},{"id":"ef4eae89.c5447","type":"mqtt out","z":"683f0662.e6d798","name":"","topic":"a/b/$homie","qos":"","retain":"","broker":"8db984ef.0e77e8","x":550,"y":320,"wires":[]},{"id":"8db984ef.0e77e8","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

I've tried various combinations of topic strings - some using $, some not (just incase it was confusing the regex the nodes use). All work as expected.

Hi Nick, yes, I've just discovered that everything apart from +/+/$homie works!

It isn't to do with retention as other retained topics work OK.

But +/+/$homie works for me in the flow I just shared.

Yes, so maybe it is something to do with the data or some hidden problem with the topic? I've copied the topic from another MQTT viewer and it still doesn't work properly.

I don't know what it might be but have you restarted/rebooted everything?
Also have a look in the node red and mosquitto logs (if it is mosquitto), though I have no idea what you might find there.

Jullian, do you have any homie nodes installed?
what are the QOS and retained settings/


I use homie now for a long time (currently 1331 retained messages). I can confirm +/+/$homie works as expected with the mqtt in node & mosquitto.

Important is if your messages are realy "retained". First I would take a look in the broker $sys topics


and at the messages itself:

There is a link between QoS and the retained flag in the mqtt spec especially when using QoS 0. More infos how you to configure mosquitto to work perfectly with homie and QoS=0 devices you can find here:

mosquitto config tips here:

If you like to dig deeper:

sobscribing to +/+/$homie gives you the info that there is a homie device present. To read all the data you have to subscribe to homie/#

No, the only Homie output I have at the moment is a test ESP8266 device running my own code and the homie esp8266 library. That particular attribute is automatically created by the library.

How are you generating the device data?

Yes, this is really retained but I don't generate this attribute, it is generated by the library. I'm not creating the device from Node-RED. The problem with the Node-RED nodes is that they require a fixed device name which isn't very helpful when you have a variable number of devices.

The point is that other tools work with +/+/$homie just fine, it is only Node-RED that isn't working.

$state should be updated reguarly. $homie not! So I suspect your problem
it is related to the "problem" that your messages are not stored as retained in your broker (perhaps because they are sent with QoS=0 or the number of retained messages are limited.

The data appears to be correct in both MQTT Explorer and MQTT-Spy:

the broker is the "center" of my system for commands and states. Even Node-RED is a homie device nor (using my homie-node node) All the rest are ESP8266 devices running ESPEasy and homebrew using the ESP-homie library. If you are using ESP8266 you probably have the QoS = 0 problem! because it uses the pubsub library

The "tools" record the messages / topics as they arrive (including retained flag). What happens when you restart MQTT Explorer? Are all messages pop up instantainosly?

The mqtt in node should emit all your retained messages after every deploy. In my case 1331 messages!