Using subflow environment variable to set mqtt topic

The trick is to use additional subflow properties:

Here you can see we've defined the ROOM env var. We then define four further env vars, one for each of the topics you want to use. In the subflow properties table, I've set their type to be Env Var - note the $ next to each one. That field type allows you to compose a value in the way you need.

You can then use ${TOPIC1} etc in your MQTT nodes.

3 Likes