(And not wanting to flood the thread)
I’ve been working on what I just posted.
Building the TOPIC in a node before the MQTT seems easier.
So I have this:
[{"id":"9ed05fb4.f4b728","type":"inject","z":"9b7e7466.a4b698","name":"","topic":"","payload":"boo","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":650,"y":840,"wires":[["cc2b24d6.d8fbc8"]]},{"id":"b0958d4d.f35c","type":"debug","z":"9b7e7466.a4b698","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"topic","x":1000,"y":760,"wires":[]},{"id":"771a258a.db51f4","type":"debug","z":"9b7e7466.a4b698","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1010,"y":800,"wires":[]},{"id":"3dd040c9.046da","type":"mqtt in","z":"9b7e7466.a4b698","name":"test topic","topic":"TEST/TelePi","qos":"2","broker":"3f12fa81.11a276","x":700,"y":920,"wires":[["de0bd61e.f9a45"]]},{"id":"7f07752c.ee0c64","type":"mqtt out","z":"9b7e7466.a4b698","name":"test topic","topic":"{{msg.topic}}","qos":"2","retain":"","broker":"3f12fa81.11a276","x":1000,"y":840,"wires":[]},{"id":"de0bd61e.f9a45","type":"debug","z":"9b7e7466.a4b698","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":920,"y":920,"wires":[]},{"id":"cc2b24d6.d8fbc8","type":"function","z":"9b7e7466.a4b698","name":"","func":"msg.topic=global.get('myDeviceName');\nmsg.topic =\"TEST/\" + msg.topic;\nreturn msg;","outputs":1,"noerr":0,"x":790,"y":840,"wires":[["7f07752c.ee0c64","b0958d4d.f35c","771a258a.db51f4"]]},{"id":"3f12fa81.11a276","type":"mqtt-broker","z":"","broker":"192.168.0.99","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"20","cleansession":true,"willTopic":"EOM","willQos":"2","willPayload":"'TelePi telemetry failure'","birthTopic":"SOM","birthQos":"2","birthPayload":"'Awaiting Pi Face'"}]
I inject “boo” and go through a Function node. That gets the global name, appends it to “TEMP/” as the topic and sends on the entire message.
Two debug nodes show me I get the message and topic correct.
I send that to the MQTT node and send it.
The receiving MQTT node sees nothing.
In this example I have used TelePi as that is a remote machine and NOT the MQTT server, so better for testing.