Adding a topic to payload?

Im trying to controll the Gate node with a normal payload but to actualy controll the gate its self, u need to add the Topic : ''control' to actually control the Gate instead of the payload to just go through the Gate

but I dont want to use the inject node, just the payload from a button.
Is the a way i can add the topic to the buttons payload? I cant figure it out.
.
.
.

more in how the gate node works and download

My code :

[{"id":"91685e52.5f062","type":"function","z":"e4d8382f.f4813","name":"","func":"if (msg.topic === \"banana\") {\n   return [ null, msg ];\n} else {\n   return [ msg, null ];\n}\n","outputs":1,"noerr":0,"x":270,"y":240,"wires":[["d1469461.699a7"]]},{"id":"499c52b6.db221c","type":"inject","z":"e4d8382f.f4813","name":"","topic":"","payload":"1","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":240,"wires":[["91685e52.5f062"]]},{"id":"d1469461.699a7","type":"change","z":"e4d8382f.f4813","name":"Open","rules":[{"t":"set","p":"payload","pt":"msg","to":"open","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"control","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":130,"y":280,"wires":[["b8635022.3cbd4"]]},{"id":"b8635022.3cbd4","type":"gate","z":"e4d8382f.f4813","name":"gate","controlTopic":"control","defaultState":"closed","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":410,"y":320,"wires":[["847b3d34.ebacf"]]},{"id":"847b3d34.ebacf","type":"debug","z":"e4d8382f.f4813","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":570,"y":320,"wires":[]}]

.
How its mean't to be used by the maker :

[{"id":"4405e5fa.2576d4","type":"gate","z":"5c82144c.a24d2c","name":"gate demo","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","x":310,"y":100,"wires":[["f2454fca.a69808"]]},{"id":"31a144c3.58ab6c","type":"inject","z":"5c82144c.a24d2c","name":"input","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":100,"wires":[["4405e5fa.2576d4"]]},{"id":"286fcfb6.811e08","type":"inject","z":"5c82144c.a24d2c","name":"open","topic":"control","payload":"open","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":160,"wires":[["4405e5fa.2576d4"]]},{"id":"d70ab41.582e248","type":"inject","z":"5c82144c.a24d2c","name":"close","topic":"control","payload":"close","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":200,"wires":[["4405e5fa.2576d4"]]},{"id":"f46bc39.5974c4","type":"inject","z":"5c82144c.a24d2c","name":"toggle","topic":"control","payload":"toggle","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":240,"wires":[["4405e5fa.2576d4"]]},{"id":"b044faad.785378","type":"inject","z":"5c82144c.a24d2c","name":"reset","topic":"control","payload":"default","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":280,"wires":[["4405e5fa.2576d4"]]},{"id":"f2454fca.a69808","type":"debug","z":"5c82144c.a24d2c","name":"output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":470,"y":100,"wires":[]}]

.
Thanks in advance,

Ivar

.
.
P.S. I'm unexperienced in node-red

Do you mean add topic to the message? i.e. the message passed between nodes contains
msg.payload and msg.topic ?

One easy way to do it would be to add a change node after the button
Configure the change node to:
set msg.topic
to <what you want it set to>

1 Like

ye that worked ,
thank you