# Mqtt node issue... bug or setting?

**URL:** <https://discourse.nodered.org/t/mqtt-node-issue-bug-or-setting/77178>\
**Category:** General\
**Created:** [3 April 2023 04:45 UTC](https://discourse.nodered.org/t/mqtt-node-issue-bug-or-setting/77178 "2023-04-03T04:45:11Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gibbz](https://avatars.discourse-cdn.com/v4/letter/g/dc4da7/32.png) [@Gibbz](https://discourse.nodered.org/u/Gibbz)\
**Post date:** [3 April 2023 04:45 UTC](https://discourse.nodered.org/t/mqtt-node-issue-bug-or-setting/77178/1 "2023-04-03T04:45:11Z")

</div>

I have a mqtt in node "zigbee2mqtt/Garage Remote/action"  
If the device sends a signal to mqtt without the "action" part of the json, node red still triggers and sends the "action" from the previous message.  
This causes my switched to be very flakey as they are constantly being toggles to the previous state.

Is this a bug, or some node-red mqtt setting?

---

<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:** [3 April 2023 04:54 UTC](https://discourse.nodered.org/t/mqtt-node-issue-bug-or-setting/77178/2 "2023-04-03T04:54:40Z")

</div>

I am still learning, but the `topic`.

All my `MQTT IN` nodes have their topic ending in `/#`

So I would have the node (in your case) set to:  
~~`zigbee2mqtt/Garage Remote/action/#`~~  
~~or (if I am wrong)~~  
`zigbee2mqtt/Garage Remote/#`  
Then check if `action` is valid/sent.

That may help with stopping the wrong types of messages getting through.

---

<div class="post-metadata">

**Author:** ![Gibbz](https://avatars.discourse-cdn.com/v4/letter/g/dc4da7/32.png) [@Gibbz](https://discourse.nodered.org/u/Gibbz)\
**Post date:** [3 April 2023 04:59 UTC](https://discourse.nodered.org/t/mqtt-node-issue-bug-or-setting/77178/3 "2023-04-03T04:59:05Z")

</div>

Im still playing with it, but it may have been some kind of QOS issue...  
What does the # on the end do?

---

<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:** [3 April 2023 05:04 UTC](https://discourse.nodered.org/t/mqtt-node-issue-bug-or-setting/77178/4 "2023-04-03T05:04:17Z")

</div>

The `qos` is Quality Of Service.  
That controls how the message is sent.

Also the `retain` flag can cause problems.  
Set it to `FALSE` for now.

QOS (from the help in the node's help section)

```auto
qos number
    0, fire and forget - 1, at least once - 2, once and once only.
retain boolean
    true indicates the message was retained and may be old.

```

There will be other messages sent and if you don't _filter_ them in your code other messages when they come through may cause problems if they don't have the _required_ part of the message.

---

<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:** [3 April 2023 05:07 UTC](https://discourse.nodered.org/t/mqtt-node-issue-bug-or-setting/77178/5 "2023-04-03T05:07:08Z")

</div>

Stick an `MQTT IN` node and have it listening to `zigbee2mqtt/Garage Remote/#`  
Put a `debug` node on it and get the `debug` to show COMPLETE message.

(This may take some time)

Watch for messages that don't have your required structure.  
That may help find out how/why (and _who_) is sending the messages.

I hope it is not an intermittent problem.

---

<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:** [3 April 2023 05:15 UTC](https://discourse.nodered.org/t/mqtt-node-issue-bug-or-setting/77178/6 "2023-04-03T05:15:25Z")

</div>

Oh, sorry... the `#` at the end is a _wild card_.  
Similar to `*` in windows.

So you can put in the topic:  
`zigbee2mqtt/Garage Remote/#` it will listen to anything _below_ that path.  
You could put:  
`zigbee2mqtt/#` and that would listen to all stuff that the zigbee2mqtt is sending.  
(If it is sending on any other channel/topic)  
It can be handy if you have things sending messages with _complicated_ topic structures.  
Say....  
`zigbee2mqtt/Garage Remote/action`  
`zigbee2mqtt/FrontDoor Remote/action`  
`zigbee2mqtt/BackDoor Remote/action`  
`zigbee2mqtt/Lights/Front/action`  
`zigbee2mqtt/Lights/Back/action`  
You could have a topic set to:  
`zigbee2mqtt/#/action` and any/all _actions_ would be shown.  
You wouldn't need to enter all the paths.

(but I kind of went off track there.) This is an EXAMPLE only.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [3 April 2023 06:27 UTC](https://discourse.nodered.org/t/mqtt-node-issue-bug-or-setting/77178/7 "2023-04-03T06:27:39Z")

</div>

> [@Trying\_to\_learn](#):
>
> You could have a topic set to:  
> `zigbee2mqtt/#/action` and any/all _actions_ would be shown.  
> You wouldn't need to enter all the paths.

No, that would not be correct.  
The # would be last thing . If you want a wildcard in the middle of a topic use +

> **[MQTT Topics and Wildcards: essentials & usage examples | Cedalo](https://cedalo.com/blog/mqtt-topics-and-mqtt-wildcards-explained/)**
>
> Discover what MQTT topics and wildcards are, what structure they have, and how to use them. As a bonus, see MQTT topic and wildcard examples.

> **[MQTT Topics, Wildcards, & Best Practices – MQTT Essentials: Part 5](https://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices/)**
>
> Learn about MQTT Topics, naming conventions, MQTT $SYS topics, MQTT Prefix, MQTT Topic Wildcards, and more in this MQTT Essentials article.

---

<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:** [3 April 2023 06:29 UTC](https://discourse.nodered.org/t/mqtt-node-issue-bug-or-setting/77178/8 "2023-04-03T06:29:53Z")

</div>

Thanks.

(I hope you can do a better job at helping than I am/was doing.)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [3 April 2023 06:42 UTC](https://discourse.nodered.org/t/mqtt-node-issue-bug-or-setting/77178/9 "2023-04-03T06:42:36Z")

</div>

> [@Gibbz](#):
>
> Is this a bug, or some node-red mqtt setting?

Probably your flow setup, hard to say without seeing your flow.

If you put a switch node after the mqtt node and set it to has key action, then only objects that have an action will pass. (assuming your mqtt outputs an object)

---

<div class="post-metadata">

**Author:** ![Gibbz](https://avatars.discourse-cdn.com/v4/letter/g/dc4da7/32.png) [@Gibbz](https://discourse.nodered.org/u/Gibbz)\
**Post date:** [3 April 2023 08:27 UTC](https://discourse.nodered.org/t/mqtt-node-issue-bug-or-setting/77178/10 "2023-04-03T08:27:19Z")

</div>

Looking at this again. I think it is actually the switch device...  
Im investigating zigbee2mqtt debounce and reporting limiting at the moment to see if this helps.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [2 June 2023 08:27 UTC](https://discourse.nodered.org/t/mqtt-node-issue-bug-or-setting/77178/11 "2023-06-02T08:27:43Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
