Off on auto logic

I'm wondering if there is a generally accepted way to tackle multi state switch logic. I'd like a switch with states off, on, auto to control a GPIO pin, off and on would output 0 and 1 to the GPIO pin correspondingly and auto would output either 0 or 1 determined by a function of other variables.

Practically speaking I'm hoping to control a heater inside a hardwood kiln, and want all three options available. Auto's output would be a function of a sensors value (sampled by a repeating inject node) and a sliders setpoint.

I'm new to nodered, finding the flow logic quite hard to grasp compared to other langauges.
Thanks in advance of course!

Something like this?

chrome_BBozTC5pQU

The demo flow (use CTRL+I to import)

[{"id":"183424338e85c029","type":"inject","z":"6e1e28ac4d35a2dd","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"mode","payload":"off","payloadType":"str","x":1380,"y":1380,"wires":[["4f829bc83c98aa4e"]]},{"id":"986517735b3e93d7","type":"inject","z":"6e1e28ac4d35a2dd","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"mode","payload":"on","payloadType":"str","x":1380,"y":1420,"wires":[["4f829bc83c98aa4e"]]},{"id":"7d5272f401921a17","type":"inject","z":"6e1e28ac4d35a2dd","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"mode","payload":"auto","payloadType":"str","x":1380,"y":1460,"wires":[["4f829bc83c98aa4e"]]},{"id":"87e414dc7745286f","type":"inject","z":"6e1e28ac4d35a2dd","name":"random 0/1","props":[{"p":"payload"}],"repeat":".5","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"(\t    $minimum := 0;\t    $maximum := 1;\t    $round(($random() * ($maximum-$minimum)) + $minimum, 0)\t)","payloadType":"jsonata","x":1370,"y":1540,"wires":[["4f829bc83c98aa4e"]]},{"id":"4f829bc83c98aa4e","type":"function","z":"6e1e28ac4d35a2dd","name":"mode control","func":"\nlet mode = context.get(\"mode\") || \"off\";\nconst modes = [\"off\", \"on\", \"auto\"];\n\nif (msg.topic === \"mode\") {\n    if (modes.indexOf(msg.payload) < 0) {\n        return null; //ignore bad mode - halt flow\n    }\n    //update mode memory\n    mode = msg.payload;\n    context.set(\"mode\", mode); \n\n    if (mode === \"auto\") {\n        return null;//we are done - halt flow\n    }\n}\n\n\nswitch (mode) {\n    case \"off\":\n        msg.payload = 0;\n        break;\n    case \"on\":\n        msg.payload = 1;\n        break;\n    case \"auto\":\n        //if auto mode, do nothing, just let this msg pass through\n        break;\n    default:\n        node.status({fill:\"red\",shape:\"ring\",text:\"mode is not valid\"});\n        return null;\n}\n\nnode.status({ fill: \"green\", shape: \"ring\", text: `${mode}: ${msg.payload}` });\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1590,"y":1380,"wires":[["14b214761d9ee7ac"]]},{"id":"14b214761d9ee7ac","type":"rbe","z":"6e1e28ac4d35a2dd","name":"on change","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":1770,"y":1380,"wires":[["83f7338f07262277"]]},{"id":"83f7338f07262277","type":"debug","z":"6e1e28ac4d35a2dd","name":"to GPIO -->","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1770,"y":1460,"wires":[]}]

I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

I use this node for combining multiple digital inputs node-red-contrib-boolean-logic-ultimate (node) - Node-RED