In relation to this post here can someone explain why you have to delete the topic in order for the responseTopic to get sent. (The place this is done is 'delete topic and add random payload')
Because the incoming MQTT packet has a topic already (as do ALL MQTT packets) - so you dont want the reply to go to the topic you just received as it would create an endless feedback loop.
By deleting the topic before sending the response, the MQTT Out node detects there is no topic BUT also detects there is a responseTopic and therefore uses that instead.
Thanks Steve - makes sense. I thought MQTT might have something cleverer going under the hood.
Would you do the same thing if you were writing a MQTT 5 client in say python as opposed to nodered - i.e delete the topic or would you just publish to a new topic with the responseTopic as the topic
Obviously in Python it would be code instead of low code so it depends on what you are doing under the hood.
For example, if you were getting the packet from the broker, modifying 1 part then publishing it - you would need to set the topic to the value of responseTopic before publishing.
However if you were constructing a new packet (as I expect), then simply set the new packets topic to that of the incoming responseTopic
Not 100% sure I follow TBH / nor how this relates to Node-RED?