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

**URL:** <https://discourse.nodered.org/t/mqtt-node-subscribing-to-homie-does-not-work/26522>\
**Category:** General\
**Created:** [12 May 2020 11:54 UTC](https://discourse.nodered.org/t/mqtt-node-subscribing-to-homie-does-not-work/26522 "2020-05-12T11:54:47Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [12 May 2020 11:54 UTC](https://discourse.nodered.org/t/mqtt-node-subscribing-to-homie-does-not-work/26522/1 "2020-05-12T11:54:48Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [12 May 2020 12:08 UTC](https://discourse.nodered.org/t/mqtt-node-subscribing-to-homie-does-not-work/26522/2 "2020-05-12T12:08:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 May 2020 12:09 UTC](https://discourse.nodered.org/t/mqtt-node-subscribing-to-homie-does-not-work/26522/3 "2020-05-12T12:09:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [12 May 2020 12:10 UTC](https://discourse.nodered.org/t/mqtt-node-subscribing-to-homie-does-not-work/26522/4 "2020-05-12T12:10:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 May 2020 12:10 UTC](https://discourse.nodered.org/t/mqtt-node-subscribing-to-homie-does-not-work/26522/5 "2020-05-12T12:10:28Z")

</div>

Have you tried another client?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [12 May 2020 12:12 UTC](https://discourse.nodered.org/t/mqtt-node-subscribing-to-homie-does-not-work/26522/6 "2020-05-12T12:12:26Z")

</div>

Yes, works fine with MQTT-Spy.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/f/8f6e87ff130966268afa56e65052167d0cda6f43.png)

In fact `+/+/+` also works in MQTT-Spy 🙂

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [12 May 2020 12:18 UTC](https://discourse.nodered.org/t/mqtt-node-subscribing-to-homie-does-not-work/26522/7 "2020-05-12T12:18:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [12 May 2020 12:24 UTC](https://discourse.nodered.org/t/mqtt-node-subscribing-to-homie-does-not-work/26522/8 "2020-05-12T12:24:29Z")

</div>

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

* * *

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

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [12 May 2020 12:30 UTC](https://discourse.nodered.org/t/mqtt-node-subscribing-to-homie-does-not-work/26522/9 "2020-05-12T12:30:24Z")

</div>

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.

```auto
[{"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.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [12 May 2020 12:31 UTC](https://discourse.nodered.org/t/mqtt-node-subscribing-to-homie-does-not-work/26522/10 "2020-05-12T12:31:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [12 May 2020 12:31 UTC](https://discourse.nodered.org/t/mqtt-node-subscribing-to-homie-does-not-work/26522/11 "2020-05-12T12:31:43Z")

</div>

> [@TotallyInformation](#):
>
> I've just discovered that everything apart from `+/+/$homie` works!

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

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [12 May 2020 12:34 UTC](https://discourse.nodered.org/t/mqtt-node-subscribing-to-homie-does-not-work/26522/12 "2020-05-12T12:34:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 May 2020 12:52 UTC](https://discourse.nodered.org/t/mqtt-node-subscribing-to-homie-does-not-work/26522/13 "2020-05-12T12:52:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [12 May 2020 12:53 UTC](https://discourse.nodered.org/t/mqtt-node-subscribing-to-homie-does-not-work/26522/14 "2020-05-12T12:53:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)\
**Post date:** [12 May 2020 15:11 UTC](https://discourse.nodered.org/t/mqtt-node-subscribing-to-homie-does-not-work/26522/15 "2020-05-12T15:11:41Z")

</div>

Hi,

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.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/3/93bc33bcfda8cd780dd4d4849f24e27b14d8b3c4.png)

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

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/d/ddd4f9970b9443d37f7646a6dcdad428f6e9f0a9.png)

and at the messages itself:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/b/5b0ca74fa60c2cd84a129e7a87df9aa9a28a4b35.png)

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:

> **[node-red-contrib-homie-convention](https://flows.nodered.org/node/node-red-contrib-homie-convention)**
>
> Node-RED nodes for MQTT communication according to the MQTT HOMIE convention

  
mosquitto config tips here:  

> <https://github.com/Christian-Me/node-red-contrib-home/blob/master/Mosquitto/readme.md>

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/#`

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [12 May 2020 15:43 UTC](https://discourse.nodered.org/t/mqtt-node-subscribing-to-homie-does-not-work/26522/16 "2020-05-12T15:43:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [12 May 2020 15:47 UTC](https://discourse.nodered.org/t/mqtt-node-subscribing-to-homie-does-not-work/26522/17 "2020-05-12T15:47:26Z")

</div>

> [@Christian-Me](#):
>
> 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.

How are you generating the device data?

> [@Christian-Me](#):
>
> Important is if your messages are realy "retained". First I would take a look in the broker $sys topics

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.

> [@Christian-Me](#):
>
> mosquitto config tips here:

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

---

<div class="post-metadata">

**Author:** ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)\
**Post date:** [12 May 2020 15:47 UTC](https://discourse.nodered.org/t/mqtt-node-subscribing-to-homie-does-not-work/26522/18 "2020-05-12T15:47:40Z")

</div>

> [@TotallyInformation](#):
>
> Urm, this is bonkers. Other things like `+/+/$state` work, just not `+/+/$homie`

$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.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [12 May 2020 15:49 UTC](https://discourse.nodered.org/t/mqtt-node-subscribing-to-homie-does-not-work/26522/19 "2020-05-12T15:49:23Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/0/00ae2114a6f8311ad09592428c1059b895b40f62.png)

---

<div class="post-metadata">

**Author:** ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)\
**Post date:** [12 May 2020 15:57 UTC](https://discourse.nodered.org/t/mqtt-node-subscribing-to-homie-does-not-work/26522/20 "2020-05-12T15:57:20Z")

</div>

> [@TotallyInformation](#):
>
> How are you generating the device data?

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!

[Next page](https://discourse.nodered.org/t/mqtt-node-subscribing-to-homie-does-not-work/26522.md?page=2)
