How to write code for a switch node?

Hello, everyone
How to write code in function so that the switch node, for example, if "1" that is transistor, if "0" then there is no transistor? I've tried everything, nothing works.
ек

Why not use the switch node?
If you are talking about something els, then maybe explain yourself a bit more

1 Like

I need to compile a node in the form of a PLC configurator. To use else in the code. The switch node I want to make a choice, if the user needs a transistor, he clicks on the checkmark, if not, then he doesn’t click anything

There are two nodes with "switch" name:
1.- Dashboard node.
2.- Function node.
as mentioned @zenofmud is easer use the swtich function node for your logic:

Screenshot from 2022-06-10 12-26-04
here is the JSON of this example:

[{"id":"6e43f45829fbf3e7","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"59c979d4b0849d9c","type":"switch","z":"6e43f45829fbf3e7","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":550,"y":260,"wires":[["fd98bbff3c2ff4cf"],["34207bf4c4149d73"]]},{"id":"618f38e6c8a9e918","type":"ui_switch","z":"6e43f45829fbf3e7","name":"","label":"switch","tooltip":"","group":"feee56445f470f84","order":1,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","animate":false,"className":"","x":410,"y":260,"wires":[["59c979d4b0849d9c"]]},{"id":"fd98bbff3c2ff4cf","type":"debug","z":"6e43f45829fbf3e7","name":"is transistor","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":710,"y":240,"wires":[]},{"id":"34207bf4c4149d73","type":"debug","z":"6e43f45829fbf3e7","name":"is no transistor","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":720,"y":280,"wires":[]},{"id":"feee56445f470f84","type":"ui_group","name":"Default","tab":"0ed4eeb8e062e528","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"0ed4eeb8e062e528","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

I hope its helps you!!

Thank you very much!