# Filter incoming MQTT messages with same topic

**URL:** <https://discourse.nodered.org/t/filter-incoming-mqtt-messages-with-same-topic/72932>\
**Category:** General\
**Tags:** function-node, mqtt\
**Created:** [30 December 2022 08:44 UTC](https://discourse.nodered.org/t/filter-incoming-mqtt-messages-with-same-topic/72932 "2022-12-30T08:44:24Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![elmo2002](https://avatars.discourse-cdn.com/v4/letter/e/b487fb/32.png) [@elmo2002](https://discourse.nodered.org/u/elmo2002)\
**Post date:** [30 December 2022 09:58 UTC](https://discourse.nodered.org/t/filter-incoming-mqtt-messages-with-same-topic/72932/21 "2022-12-30T09:58:23Z")

</div>

Agreed, however for some reason it does not seem to happen in this case as can be seen by the topic.

---

<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:** [30 December 2022 11:51 UTC](https://discourse.nodered.org/t/filter-incoming-mqtt-messages-with-same-topic/72932/22 "2022-12-30T11:51:41Z")

</div>

> [@elmo2002](#):
>
> I had thought of this but thought that it would only pass the model part of the payload and not all of the objects.

That is not correct. The Switch node passes on the full message to the output that matches the specification. Did you try it? If you want to split your messages down different paths dependent on the model you can add extra lines to the Switch specification so that the different models are sent to different outputs.

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [30 December 2022 22:42 UTC](https://discourse.nodered.org/t/filter-incoming-mqtt-messages-with-same-topic/72932/23 "2022-12-30T22:42:59Z")

</div>

It would be best to use a `switch node` first to change the msg.topic to` rtl_433/<id>/<model>.`

The reason being that although I use the `id` to identify a device, they do have a habit of changing the `id` after a battery change. Also, I am unsure as to whether the id is unique (I suspect not).

You can then use a switch node. Using `model` only as a switch is a bit fraught as there may be other users of that model in the vicinity.

For those wondering about the use of `rtl_433` as a message topic, there are other options in the rtl\_433 output but this is the one that gives the best information

---

<div class="post-metadata">

**Author:** ![Daniel8535](https://avatars.discourse-cdn.com/v4/letter/d/5fc32e/32.png) [@Daniel8535](https://discourse.nodered.org/u/Daniel8535)\
**Post date:** [31 December 2022 05:16 UTC](https://discourse.nodered.org/t/filter-incoming-mqtt-messages-with-same-topic/72932/24 "2022-12-31T05:16:44Z")

</div>

I appreciate the information and advice you have shared[.](https://www.arise-portal.com/)

---

<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:** [14 January 2023 05:17 UTC](https://discourse.nodered.org/t/filter-incoming-mqtt-messages-with-same-topic/72932/25 "2023-01-14T05:17:28Z")

</div>

Closed on 14 January 2023 05:17 UTC

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

[Previous page](https://discourse.nodered.org/t/filter-incoming-mqtt-messages-with-same-topic/72932.md?page=1)
