Gpio: passing pin through msg.topic not working


I am using node-red-node-pi-gpio nodes to control solid state relays, which is all working fine when I assign the pin through the gpio node.

I am wanting to assign the pin to use through msg.topic. The docs on the page say to use msg.topic = "pi/{pin number}"

So I am sending through msg.topic = "pi/37", but it does not use the pin.

In fact it always uses the design-assigned gpio pin and not the pin assigned through msg.topic

12 Nov 08:22:52 - [info] Node-RED version: v1.2.3
12 Nov 08:22:52 - [info] Node.js version: v12.19.0
12 Nov 08:22:52 - [info] Linux 4.19.66-v7+ arm LE

Ant other details required?

Function code:

msg.topic = "pi/37";


return msg;

Flow below

[{"id":"c80ffb9b.89eea8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"804f52d3.2aa85","type":"ui_switch","z":"c80ffb9b.89eea8","name":"","label":"MLT Pump Test","tooltip":"","group":"ea5e6691.a9d4b8","order":11,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":280,"y":200,"wires":[["69f28e7a.bbf69"]]},{"id":"d4af027b.d7f91","type":"rpi-gpio out","z":"c80ffb9b.89eea8","name":"MLT GPIO","pin":"32","set":true,"level":"0","freq":"","out":"out","x":690,"y":200,"wires":[]},{"id":"69f28e7a.bbf69","type":"function","z":"c80ffb9b.89eea8","name":"Control GPIO","func":"\nmsg.topic = \"pi/37\";\n\nnode.log(msg.payload);\nnode.log(msg.topic);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":500,"y":200,"wires":[["d4af027b.d7f91"]]},{"id":"ea5e6691.a9d4b8","type":"ui_group","z":"","name":"MLT","tab":"1a3824a0.4dd3fb","order":3,"disp":true,"width":"6","collapse":false},{"id":"1a3824a0.4dd3fb","type":"ui_tab","z":"","name":"Dashboard","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

Hi - where does the help say that ? It says that for the input pin the topic is set to that - but not for the output pin. You cannot allocate the output pin dynamically.

Wow, thanks for the fast response.

Ahh, ok. That makes sense now I read the help page again.
Looks like the gpiod add-on has the same design.

Are there any methods to dynamically assign the GPIO pin on output commands?

The reason I ask is that I am designing some brewing control software and want to provide users the ability to assign their own pins. At this stage I will have to tell them which pins to wire up for the various sub-systems


The latest version of the node does have a text pin field below the picker
which can accept the ${MY_VAR} environment variable syntax which can then be assigned by environment variables outside of Node-RED (presuming you don't want to give them access to the flow editor)