Mqtt in and out topic


I have a very simple flow that contains an mqtt-in node, two mqtt-out nodes and two function nodes.

the topic of the mqtt-in node is home/Garage/# and the topic of mqtt-out nodes are home/Garage/door/status and home/Garage/door/command.

obviously this simple flow has an issue which causes an infinite loop.

how can I fix the issue?


Hello @mohammad-torabi-84

Either subscribe to home/garage/+/status
Or (probably better) use command/home/garage/door and status/home/garage/door

So, these two topic of command/home/garage/door and status/home/garage/door have the same result. because the mqtt-out node has the same topic of the mqtt-in node. this will cause an infinite loop in the flow.

I misinterpreted your question.

  1. Presumably the messages that your flow sends on home/garage/door/command are instructions to the door -"Open", "Close" etc. ?

  2. Why does your flow send messages on home/garage/door/status?
    What device subscribes to these messages?
    I assumed that these messages would be sent by the door to indicate it's current state - "Opened", "Closed" etc.

  3. What device publishes the message that your mqtt-in node is intended to receive?
    Do you have control over the topic this device uses?

Add a Filter node in front of each mqtt out node. That should break the loop.

Your MQTT-In node is subscribing to the topic home/Garage/#
The hash # symbol is a wildcard which means the node will accept anything from that point onwards.

Your MQTT-Out nodes are publishing to the topic home/Garage/door/status and

If you write the topics out as a list you can see the overlap.

So your MQTT-In will react everytime you send a message. An infinite loop has been created.

As @jbudd said you need to adjust the topic names or as @Colin says add a 'Filter'node.

If you tell us what is in the function nodes, and why, there may be a better way of handling the problem.

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