Multi-state switch + passthrough / msg parts

Hi there, I've been going in circles trying to get this (seemingly simple) config. I have a UI input template sending data to UI text node display. From the same input there is going to be two independent sets of data, one flow.set in memory (A) the other in filesystem (B) depending on a state of a toggle switch.

In other words if the switch is set in A position the data that's being entered/submitted is getting stored in set A and the UI text node is showing that set. You can toggle back and forth to see the two sets.
My approach was to place the switch before the function so the function receives both data and switch status to determine how to handle the data.

Everything is working EXCEPT I can't figure out how to combine/separate data and switch status msg. even though this multistate switch has a specific "state" field. The only way I can read it in the function is if it's set on "payload" but then it interferes with the input data. A different value frees up the data passthrough but then I can't find a way to read it.

Here is that piece of the flow but the function is blank (simper than the mess I have). Thank you guys!

[
    {
        "id": "d50cb6ebd3a83f2c",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "86adc926e9fd3301",
        "type": "ui_template",
        "z": "d50cb6ebd3a83f2c",
        "group": "085d7feec44f7e35",
        "name": "form",
        "order": 10,
        "width": "2",
        "height": "3",
        "format": "\n<div flex=\"\" style=\"margin 3px 0px 0px 7px\" layout=\"row\">\n\n<div flex=\"35\" style=\"padding:0 5px\">    \n    <div layout=\"column\">\n       <div><md-input-container><input aria-label=\"amt\" ng-model=\"amt\"></md-input-container></div> \n     <div layout=\"row\">\n        <div style =\"margin-left:-13px\"><md-checkbox ng-model=\"aut\" aria-label=\"aut\"></md-checkbox></div> \n        <div style =\"margin-left:13px\"><md-checkbox ng-model=\"sl_trl\" aria-label=\"sl_trl\">🡅</md-checkbox></div> \n     </div>\n    </div> \n    </div>\n\n<div flex=\"15\" style=\"padding:0 5px\">    \n\n      <div style=\"text-align:center\"><md-input-container><input ng-model=\"sl\" aria-label=\"sl\"><span class=mylabel>SL</span></md-input-container></div>\n\n</div>\n\n<div flex=\"20\" style=\"padding:0 5px\">    \n\n       <div style=\"text-align:center\"><md-input-container><input ng-model=\"tp\" aria-label=\"tp\"><span class=mylabel>TP</span></md-input-container></div> \n</div>\n<div flex=\"15\" style=\"padding:0 5px\">\n\n       <div style=\"text-align:center\"><md-input-container><input aria-label=\"tp_trl\" ng-model=\"tp_trl\"><span class=mylabel>TR</span></md-input-container></div>        \n\n</div>\n<div flex=\"15\" style=\"padding:0 5px\">\n\n       <div style=\"text-align:center\"><md-input-container><input aria-label=\"tm\" ng-model=\"tm\"><span class=mylabel>T</span></md-input-container></div>        \n\n</div>\n\n</div>\n\n<div flex=\"\" layout=\"row\">\n  <div flex=\"40\" id=\"regular_plus\" style = \"margin-left:2px; padding: 0px 5x;\" ><md-button class=\"md-button remote-button\"><span style=\"color:{{msg.colour}}\" class=\"fa fa-repeat\"> </span></md-button></div>\n  <div flex=\"60\" style = \"text-align:center; margin: 0px 5px 0px 10px; padding-left: 7px;\"><md-button aria-label=\"set\" class=\"md-accent md-hue-2 md-raised\" ng-click=\"send({payload:{amt:amt, aut:aut, sl_trl:sl_trl, sl:sl, tp:tp, tp_trl:tp_trl, tm:tml}})\">SET</md-button></div>\n</div>\n\n<script>\n\n(function($scope) {\n    \n$('#regular_plus').on('click', function(e) {\n    e.preventDefault(); //prevent default behavior\n    $scope.send({\"topic\":\"regular_plus\",\"payload\": \"vol-up\"});\n});\n    \n})(scope);\n</script>",
        "storeOutMessages": false,
        "fwdInMessages": true,
        "resendOnRefresh": false,
        "templateScope": "local",
        "className": "setbox",
        "x": 490,
        "y": 320,
        "wires": [
            [
                "fbc2463f5e25697a"
            ]
        ]
    },
    {
        "id": "fbc2463f5e25697a",
        "type": "ui_multistate_switch",
        "z": "d50cb6ebd3a83f2c",
        "name": "multi-switch",
        "group": "085d7feec44f7e35",
        "order": 6,
        "width": "1",
        "height": "1",
        "label": "",
        "stateField": "state",
        "enableField": "enable",
        "passthroughField": "passthrough",
        "inputMsgField": "inputmsg",
        "rounded": true,
        "useThemeColors": false,
        "hideSelectedLabel": false,
        "multilineLabel": false,
        "passThrough": "always",
        "inputMsg": "all",
        "userInput": "enabled_show",
        "options": [
            {
                "label": "&nbsp;",
                "value": "x",
                "valueType": "str",
                "color": "#1e2223"
            },
            {
                "label": "A",
                "value": "A",
                "valueType": "str",
                "color": "#0042ad"
            },
            {
                "label": "&nbsp;",
                "value": "y",
                "valueType": "str",
                "color": "#1e2223"
            },
            {
                "label": "M",
                "value": "M",
                "valueType": "str",
                "color": "#ff0000"
            }
        ],
        "topic": "switch",
        "x": 630,
        "y": 320,
        "wires": [
            [
                "573015edc6bb81f1"
            ]
        ]
    },
    {
        "id": "573015edc6bb81f1",
        "type": "function",
        "z": "d50cb6ebd3a83f2c",
        "name": "function 1",
        "func": "\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 780,
        "y": 320,
        "wires": [
            [
                "3941c8d39fb0b5e2"
            ]
        ]
    },
    {
        "id": "deea311bab3c6bc3",
        "type": "change",
        "z": "d50cb6ebd3a83f2c",
        "name": "defaults",
        "rules": [
            {
                "t": "set",
                "p": "payload.amt",
                "pt": "msg",
                "to": "20",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.sl",
                "pt": "msg",
                "to": "3",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.tp",
                "pt": "msg",
                "to": "5",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.tp_trl",
                "pt": "msg",
                "to": "",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.sl_trl",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.tm",
                "pt": "msg",
                "to": "1",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.aut",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.flag",
                "pt": "msg",
                "to": "set",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "set",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 370,
        "y": 320,
        "wires": [
            [
                "86adc926e9fd3301"
            ]
        ]
    },
    {
        "id": "3941c8d39fb0b5e2",
        "type": "ui_text",
        "z": "d50cb6ebd3a83f2c",
        "group": "085d7feec44f7e35",
        "order": 3,
        "width": "2",
        "height": "1",
        "name": "display",
        "label": "",
        "format": "<font color= {{msg.color}} > {{msg.payload}} </font>",
        "layout": "row-spread",
        "className": "values",
        "x": 910,
        "y": 320,
        "wires": []
    },
    {
        "id": "085d7feec44f7e35",
        "type": "ui_group",
        "name": "LEFT",
        "tab": "7e13e6107768d821",
        "order": 3,
        "disp": false,
        "width": "4",
        "collapse": false,
        "className": ""
    },
    {
        "id": "7e13e6107768d821",
        "type": "ui_tab",
        "name": "CRYPTO",
        "icon": "dashboard",
        "order": 2,
        "disabled": false,
        "hidden": false
    }
]

Have a msg.payload.state property on incoming msg, and set State Field to msg.payload.state. No idea if this is the best way but it works.

Hi, thanks ... yes, I am able to read the switch state. However, as I toggle the switch the debug is showing both it being able to read it ('M' or 'A') and it being 'undefined' - and same for the rest of the msg data ...

"TypeError: Cannot read property 'state' of undefined"
11/4/2022, 8:50:45 PMnode: debug 2
mode : msg.payload : string[1]
"M"
11/4/2022, 8:51:25 PMnode: mode
function : (error)
"TypeError: Cannot read property 'state' of undefined"
11/4/2022, 8:51:25 PMnode: debug 2
mode : msg.payload : string[1]
"A"
11/4/2022, 8:51:26 PMnode: mode
function : (error)
"TypeError: Cannot read property 'state' of undefined"

test flow

[
    {
        "id": "ef6e05528cb59973",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "892067a035a65d67",
        "type": "ui_multistate_switch",
        "z": "ef6e05528cb59973",
        "name": "mode",
        "group": "085d7feec44f7e35",
        "order": 13,
        "width": "1",
        "height": "1",
        "label": "",
        "stateField": "payload.state",
        "enableField": "enable",
        "passthroughField": "passthrough",
        "inputMsgField": "inputmsg",
        "rounded": true,
        "useThemeColors": false,
        "hideSelectedLabel": false,
        "multilineLabel": false,
        "passThrough": "always",
        "inputMsg": "all",
        "userInput": "enabled_show",
        "options": [
            {
                "label": "P",
                "value": "x",
                "valueType": "str",
                "color": "#1e2223"
            },
            {
                "label": "&nbsp;",
                "value": "y",
                "valueType": "str",
                "color": "#1e2223"
            },
            {
                "label": "M",
                "value": "M",
                "valueType": "str",
                "color": "#ff0000"
            },
            {
                "label": "A",
                "value": "A",
                "valueType": "str",
                "color": "#0042ad"
            }
        ],
        "topic": "mode",
        "x": 610,
        "y": 140,
        "wires": [
            [
                "41b2b3f851edd784"
            ]
        ]
    },
    {
        "id": "41b2b3f851edd784",
        "type": "function",
        "z": "ef6e05528cb59973",
        "name": "mode",
        "func": "var state = msg.payload.state;  \n\n\nmsg.payload = state;\n\nreturn [msg];\n\n\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 810,
        "y": 140,
        "wires": [
            [
                "16a9bb05d378e812"
            ]
        ]
    },
    {
        "id": "16a9bb05d378e812",
        "type": "debug",
        "z": "ef6e05528cb59973",
        "name": "debug 3",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 970,
        "y": 140,
        "wires": []
    },
    {
        "id": "085d7feec44f7e35",
        "type": "ui_group",
        "name": "LEFT",
        "tab": "7e13e6107768d821",
        "order": 3,
        "disp": false,
        "width": "4",
        "collapse": false,
        "className": ""
    },
    {
        "id": "7e13e6107768d821",
        "type": "ui_tab",
        "name": "CRYPTO",
        "icon": "dashboard",
        "order": 2,
        "disabled": false,
        "hidden": false
    }
]

This isn't a finished flow of what you are after, but it does give you a payload containing all the info from the switch & form nodes. (I hope)

Still to do:

  • Format displayed data as required
  • Switch data to be shown dependant on 'A' or 'M'
  • Default entries in form & switch nodes
[{"id":"86adc926e9fd3301","type":"ui_template","z":"d50cb6ebd3a83f2c","group":"085d7feec44f7e35","name":"form","order":3,"width":6,"height":4,"format":"\n<div flex=\"\" style=\"margin 3px 0px 0px 7px\" layout=\"row\">\n\n<div flex=\"35\" style=\"padding:0 5px\">    \n    <div layout=\"column\">\n       <div><md-input-container><input aria-label=\"amt\" ng-model=\"amt\"></md-input-container></div> \n     <div layout=\"row\">\n        <div style =\"margin-left:-13px\"><md-checkbox ng-model=\"aut\" aria-label=\"aut\"></md-checkbox></div> \n        <div style =\"margin-left:13px\"><md-checkbox ng-model=\"sl_trl\" aria-label=\"sl_trl\">🡅</md-checkbox></div> \n     </div>\n    </div> \n    </div>\n\n<div flex=\"15\" style=\"padding:0 5px\">    \n\n      <div style=\"text-align:center\"><md-input-container><input ng-model=\"sl\" aria-label=\"sl\"><span class=mylabel>SL</span></md-input-container></div>\n\n</div>\n\n<div flex=\"20\" style=\"padding:0 5px\">    \n\n       <div style=\"text-align:center\"><md-input-container><input ng-model=\"tp\" aria-label=\"tp\"><span class=mylabel>TP</span></md-input-container></div> \n</div>\n<div flex=\"15\" style=\"padding:0 5px\">\n\n       <div style=\"text-align:center\"><md-input-container><input aria-label=\"tp_trl\" ng-model=\"tp_trl\"><span class=mylabel>TR</span></md-input-container></div>        \n\n</div>\n<div flex=\"15\" style=\"padding:0 5px\">\n\n       <div style=\"text-align:center\"><md-input-container><input aria-label=\"tm\" ng-model=\"tm\"><span class=mylabel>T</span></md-input-container></div>        \n\n</div>\n\n</div>\n\n<div flex=\"\" layout=\"row\">\n  <div flex=\"40\" id=\"regular_plus\" style = \"margin-left:2px; padding: 0px 5x;\" ><md-button class=\"md-button remote-button\"><span style=\"color:{{msg.colour}}\" class=\"fa fa-repeat\"> </span></md-button></div>\n  <div flex=\"60\" style = \"text-align:center; margin: 0px 5px 0px 10px; padding-left: 7px;\"><md-button aria-label=\"set\" class=\"md-accent md-hue-2 md-raised\" ng-click=\"send({topic: 'set', payload:{amt:amt, aut:aut, sl_trl:sl_trl, sl:sl, tp:tp, tp_trl:tp_trl, tm:tml}})\">SET</md-button></div>\n</div>\n\n<script>\n\n(function($scope) {\n    \n$('#regular_plus').on('click', function(e) {\n    e.preventDefault(); //prevent default behavior\n    $scope.send({\"topic\":\"regular_plus\",\"payload\": \"vol-up\"});\n});\n    \n})(scope);\n</script>","storeOutMessages":false,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","className":"setbox","x":690,"y":260,"wires":[["d68ab5f6f76916cf","573015edc6bb81f1"]]},{"id":"573015edc6bb81f1","type":"function","z":"d50cb6ebd3a83f2c","name":"function 1","func":"let state = context.get('state') || ''\nlet setting = context.get('setting') || {}\nlet volume = context.get('volume')|| ''\nlet display = ''\n\nif (msg.topic === 'regular_plus') {\n    volume = msg.payload\n\n    context.set('volume', volume)\n}\n\nif (msg.topic === 'set') {\n    setting = msg.payload\n    display = Object.entries(setting).map(x=>x.join(\":\")).join(\",\")\n\n    context.set('setting', setting)\n}\n\nif (msg.topic === 'switch') {\n    state = msg.payload.state\n\n    context.set('state', state)\n}\n\nmsg.payload = setting\nmsg.payload.state = state\nmsg.payload.volume = volume\nmsg.payload.display = display\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":900,"y":320,"wires":[["3941c8d39fb0b5e2","f94ca8bfbd5df65c"]]},{"id":"deea311bab3c6bc3","type":"change","z":"d50cb6ebd3a83f2c","name":"defaults","rules":[{"t":"set","p":"payload.amt","pt":"msg","to":"20","tot":"str"},{"t":"set","p":"payload.sl","pt":"msg","to":"3","tot":"str"},{"t":"set","p":"payload.tp","pt":"msg","to":"5","tot":"str"},{"t":"set","p":"payload.tp_trl","pt":"msg","to":"","tot":"str"},{"t":"set","p":"payload.sl_trl","pt":"msg","to":"true","tot":"bool"},{"t":"set","p":"payload.tm","pt":"msg","to":"1","tot":"str"},{"t":"set","p":"payload.aut","pt":"msg","to":"false","tot":"bool"},{"t":"set","p":"payload.flag","pt":"msg","to":"set","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":260,"wires":[["86adc926e9fd3301"]]},{"id":"3941c8d39fb0b5e2","type":"ui_text","z":"d50cb6ebd3a83f2c","group":"085d7feec44f7e35","order":1,"width":"6","height":"2","name":"display","label":"","format":"<font color= {{msg.color}} > {{msg.payload.display}} </font>","layout":"row-spread","className":"values","x":1060,"y":320,"wires":[]},{"id":"fbc2463f5e25697a","type":"ui_multistate_switch","z":"d50cb6ebd3a83f2c","name":"multi-switch","group":"085d7feec44f7e35","order":2,"width":"2","height":1,"label":"","stateField":"payload.state","enableField":"enable","passthroughField":"passthrough","inputMsgField":"inputmsg","rounded":false,"useThemeColors":false,"hideSelectedLabel":false,"multilineLabel":false,"passThrough":"change","inputMsg":"all","userInput":"enabled_show","options":[{"label":"&nbsp;","value":"x","valueType":"str","color":"#1e2223"},{"label":"A","value":"A","valueType":"str","color":"#0042ad"},{"label":"&nbsp;","value":"y","valueType":"str","color":"#1e2223"},{"label":"M","value":"M","valueType":"str","color":"#ff0000"}],"topic":"switch","x":700,"y":320,"wires":[["573015edc6bb81f1","a657261f9d5316cd"]]},{"id":"240d45409613b4f4","type":"inject","z":"d50cb6ebd3a83f2c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{}","payloadType":"json","x":110,"y":320,"wires":[["deea311bab3c6bc3","527d65ec8cc3ab31"]]},{"id":"d68ab5f6f76916cf","type":"debug","z":"d50cb6ebd3a83f2c","name":"debug 4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":900,"y":240,"wires":[]},{"id":"a657261f9d5316cd","type":"debug","z":"d50cb6ebd3a83f2c","name":"debug 5","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":900,"y":400,"wires":[]},{"id":"f94ca8bfbd5df65c","type":"debug","z":"d50cb6ebd3a83f2c","name":"debug 6","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1060,"y":360,"wires":[]},{"id":"527d65ec8cc3ab31","type":"change","z":"d50cb6ebd3a83f2c","name":"Switch Defaults","rules":[{"t":"set","p":"color","pt":"msg","to":"Red","tot":"str"},{"t":"set","p":"payload.state","pt":"msg","to":"A","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":320,"wires":[["fbc2463f5e25697a"]]},{"id":"085d7feec44f7e35","type":"ui_group","name":"LEFT","tab":"7e13e6107768d821","order":3,"disp":false,"width":6,"collapse":false,"className":""},{"id":"7e13e6107768d821","type":"ui_tab","name":"CRYPTO","icon":"dashboard","order":2,"disabled":false,"hidden":false}]
1 Like

Hi, thank you for providing this! I managed to get the functionality more-or-less working with my fairly crude approach but seems somewhat buggy - I am looking to switch to what you proposed. The info (which you showed how to capture) is used in the primary objective of the function, which is to create and manage two independent sets of data - one stored in memory, the other in filesystem (to be then used in a different function). So if the switch is in "A" mode, we're updating (and displaying) that data set in memory.

Typically I want to update only one parameter at at time, so the issue that had given me the most problems is the fact that ALL fields get submitted at the same time and the blank ones come in 'undefined' and overwrite stored values; hence a lot of checking undefined. The default values are meant to initialize the set in memory, but on reboot they would also overwrite the ones in filesystem (it was supposed to be prevented by defaulting the switch to A mode). I ended up putting a check box input on the same form to allow updates only when checked) - so on reboot the function is seeing that's its false and avoiding the overwrite.

P.S. I noticed you're using "Let" instead of "Var" - I was trying to understand the difference from various explanations but still unclear. Here is the current code:

var state = msg.payload.state;  
var amt = msg.payload.amt; var amt_a;
var tp = msg.payload.tp;  var tp_a;
var tp_trl = msg.payload.tp_trl;  var tp_trl_a;
var sl = msg.payload.sl;  var sl_a;
var sl_trl = msg.payload.sl_trl;  var sl_trl_a;
var tm = msg.payload.tm;  var tm_a;
var sav= msg.payload.sav;
var topic = msg.topic;

if (msg.topic == "mode") {
flow.set('state', state);
}


if (flow.get('state') == "M") {

 if (sav) {

if (typeof amt != 'undefined' &&  amt !== null &&  amt > 0 && amt < 1001 ) {flow.set('amt', amt)} else amt = null
if (typeof tp != 'undefined' &&  tp  !== null &&  tp  > 0 && tp  < 16 ) {flow.set('tp', tp)} else tp = null
if (typeof tp_trl != 'undefined' &&  tp_trl  !== null &&  tp_trl  > 0 && tp_trl  < 4 ) {flow.set('tp_trl', tp_trl)} else tp_trl = null
if (typeof sl != 'undefined' &&  tp  !== null &&  tp  > 0 && tp  < 6 )  {flow.set('sl', sl)} else sl = null
if (typeof sl_trl != 'undefined' &&  sl_trl  !== null &&  sl_trl  > 0 && sl_trl  < 4 )  {flow.set('sl_trl', sl_trl)} else sl_trl = null
if (typeof tm != 'undefined' &&  tm !== null &&  tm > 0 && tm < 4 ) {flow.set('tm', tm)} else tm = null

 }

msg.payload = flow.get('amt') +" | "+ flow.get('tp') +" : "+ flow.get('tp_trl') +" | "+ flow.get('sl') +" : "+ flow.get('sl_trl') +" | "+ flow.get('tm') +" | "+ flow.get('int', 'file')
msg.color = "#777777"

} else


if (flow.get('state') == "A") {
    
 if (sav) {

if (typeof amt != 'undefined' &&  amt !== null &&  amt > 0 && amt < 1001 ) {flow.set('amt_a', amt, 'file')} else amt_a = null
if (typeof tp != 'undefined' &&  tp  !== null &&  tp  > 0 && tp  < 16 ) {flow.set('tp_a', tp, 'file')} else tp_a = null
if (typeof tp_trl != 'undefined' &&  tp_trl  !== null &&  tp_trl  > 0 && tp_trl  < 4 ) {flow.set('tp_trl_a', tp_trl, 'file')} else tp_trl_a = null
if (typeof sl != 'undefined' &&  tp  !== null &&  tp  > 0 && tp  < 6 )  {flow.set('sl_a', sl, 'file')} else sl_a = null
if (typeof sl_trl != 'undefined' &&  sl_trl  !== null &&  sl_trl  > 0 && sl_trl  < 4 )  {flow.set('sl_trl_a', sl_trl, 'file')} else sl_trl_a = null
if (typeof tm != 'undefined' &&  tm !== null &&  tm > 0 && tm < 4 ) {flow.set('tm_a', tm, 'file')} else tm_a = null

 }


msg.payload = flow.get('amt_a', 'file') +" | "+ flow.get('tp_a', 'file') +" : "+ flow.get('tp_trl_a', 'file') +" | "+ flow.get('sl_a', 'file') +" : "+ flow.get('sl_trl_a', 'file') +" | "+ flow.get('tm_a', 'file') +" | "+ flow.get('int', 'file')
msg.color = "#fdef55"


}   else

if (flow.get('state') == "d") {msg.payload = ""}

return [msg];

const & let are the currently preferred way of initialising variables ( JavaScript let vs var: Complete Guide (askjavascript.com)) explains the difference.

for your code you are missing some {} around the else part of the if statements. There are still bits that need sorting, and maybe some default values supplied.

Same code with some cosmetic changes - just me :wink:

/*
var state = msg.payload.state;  
var amt = msg.payload.amt; var amt_a;
var tp = msg.payload.tp;  var tp_a;
var tp_trl = msg.payload.tp_trl;  var tp_trl_a;
var sl = msg.payload.sl;  var sl_a;
var sl_trl = msg.payload.sl_trl;  var sl_trl_a;
var tm = msg.payload.tm;  var tm_a;
var sav= msg.payload.sav;
var topic = msg.topic;
*/

/**
 * Explaination
 * Deconstruct the payload Object into local variables
 * 
 * If you want to provide default values
 * let {state = true, amt = 1, tp, tp_trl, sl, sl_trl, tm, sav} = msg.payload
 */

let {state, amt, tp, tp_trl, sl, sl_trl, tm, sav} = msg.payload
let amt_a, tp_a, tp_trl_a, sl_a, sl_trl_a, tm_a

let topic = msg.topic

if (msg.topic === "mode") {
    flow.set('state', state);
}

if (flow.get('state') === "M") {

    // Where does 'sav' come from?
    if (sav) {

        /**
         * Explaination
         * if ( some_variable ) {
         *      we don't get here if some_variable is null, undefined, 0, NaN, false, or ""
         *  }
         * 
         * Missing {} in the 'else' parts your function
         * 
         */
        if ( amt && amt > 0 && amt < 1001 ) {
            flow.set('amt', amt)
        } else {
            amt = null
        } 

        if ( tp && tp > 0 && tp < 16 ) {
            flow.set('tp', tp)
        } else {
             tp = null
        }

        if ( tp_trl && tp_trl > 0 && tp_trl < 4 ) {
            flow.set('tp_trl', tp_trl)
        } else {
            tp_trl = null
        }

        if ( sl && tp &&  tp > 0 && tp  < 6 )  {
            flow.set('sl', sl)
        } else {
            sl = null
        }

        if ( sl_trl &&  sl_trl > 0 && sl_trl < 4 )  {
            flow.set('sl_trl', sl_trl)
        } else {
            sl_trl = null
        }

        if ( tm && tm > 0 && tm < 4 ) {
            flow.set('tm', tm)
        } else {
            tm = null
        }

    }

    // Where does flow.get('int', 'file') come from?
    /** 
     * Template literal
     * `string text ${expression} string text`
    */

    msg.payload = `${flow.get('amt')} | ${flow.get('tp')} : ${flow.get('tp_trl')} | ${flow.get('sl')} : ${flow.get('sl_trl')} | ${flow.get('tm')} | ${flow.get('int', 'file')}`
    msg.color = "#777777"

} else if (flow.get('state') === "A") {
    
    if (sav) {

        if ( amt &&  amt > 0 && amt < 1001 ) {
            flow.set('amt_a', amt, 'file')
        } else {
            amt_a = null
        }

        if ( tp &&  tp  > 0 && tp  < 16 ) {
            flow.set('tp_a', tp, 'file')
        } else {
            tp_a = null
        }

        if ( tp_trl &&  tp_trl > 0 && tp_trl  < 4 ) {
            flow.set('tp_trl_a', tp_trl, 'file')
        } else {
            tp_trl_a = null
        }

        if ( sl &&  tp &&  tp > 0 && tp < 6 )  {
            flow.set('sl_a', sl, 'file')
        } else {
            sl_a = null
        }

        if ( sl_trl && sl_trl > 0 && sl_trl < 4 )  {
            flow.set('sl_trl_a', sl_trl, 'file')
        } else {
            sl_trl_a = null
        }

        if ( tm &&  tm > 0 && tm < 4 ) {
            flow.set('tm_a', tm, 'file')
        } else {
            tm_a = null
        }

    }

    msg.payload = `${flow.get('amt_a', 'file')} | ${flow.get('tp_a', 'file')} : ${flow.get('tp_trl_a', 'file')} | ${flow.get('sl_a', 'file')} : ${flow.get('sl_trl_a', 'file')} | ${flow.get('tm_a', 'file')} | ${flow.get('int', 'file')}`
    msg.color = "#fdef55"


} else if (flow.get('state') === "d") { 
    msg.payload = ""
}

return msg

Thank you - let me try it out. The "sav" is the checkbox (I mentioned) that I had to put in to prevent filesystem values from being overwritten on restart; perhaps it's no longer necessary.

You mentioned setting default values here, if you recall there being set in the change node - is there a difference?

"int" is a variable that gets created in a different function; i am calling it here simply to add to the display

It seems to be working! Thanks so much!!

One more issue I've not bee able to figure out is how to clear the input boxes - ideally after the submit (like a regular form); if that's too complex then perhaps it's easier with a button action (that's why I put in that button with script).

And I realized that I have no way of clearing values from memory (besides just updating them with another value). I added a checkbox ("clear" with circle icon) so if it's checked and submitted the values for that respective set are cleared from memory or file system.

UPDATED/WORKING (!) FLOW

[
    {
        "id": "34ed368a2b393118",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "c2633fba12985284",
        "type": "change",
        "z": "34ed368a2b393118",
        "name": "defaults",
        "rules": [
            {
                "t": "set",
                "p": "payload.currency",
                "pt": "msg",
                "to": "GALA",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.exchange",
                "pt": "msg",
                "to": "Gate.io",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.flag",
                "pt": "msg",
                "to": "reset",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "time",
                "pt": "msg",
                "to": "",
                "tot": "date"
            },
            {
                "t": "set",
                "p": "payload.change",
                "pt": "msg",
                "to": "",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.window",
                "pt": "msg",
                "to": "",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.note",
                "pt": "msg",
                "to": "",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 890,
        "y": 320,
        "wires": [
            [
                "9f9aba813101519a"
            ]
        ]
    },
    {
        "id": "98d0cb33611c9411",
        "type": "change",
        "z": "34ed368a2b393118",
        "name": "values",
        "rules": [
            {
                "t": "set",
                "p": "payload.amt",
                "pt": "msg",
                "to": "20",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.tp",
                "pt": "msg",
                "to": "5",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.tp_trl",
                "pt": "msg",
                "to": "3",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.sl",
                "pt": "msg",
                "to": "3",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.sl_trl",
                "pt": "msg",
                "to": "2",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.tm",
                "pt": "msg",
                "to": "1",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.sav",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.clear",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.state",
                "pt": "msg",
                "to": "M",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 890,
        "y": 280,
        "wires": [
            [
                "8591e5f4ae2a979e"
            ]
        ]
    },
    {
        "id": "9f9aba813101519a",
        "type": "link out",
        "z": "34ed368a2b393118",
        "name": "link out 32",
        "mode": "link",
        "links": [
            "1cad2a747e05334e"
        ],
        "x": 895,
        "y": 360,
        "wires": []
    },
    {
        "id": "41903a3c9ca53b7d",
        "type": "link in",
        "z": "34ed368a2b393118",
        "name": "link in 8",
        "links": [
            "bf9d41a5946d11f9"
        ],
        "x": 795,
        "y": 300,
        "wires": [
            [
                "98d0cb33611c9411",
                "c2633fba12985284"
            ]
        ]
    },
    {
        "id": "8591e5f4ae2a979e",
        "type": "ui_template",
        "z": "34ed368a2b393118",
        "group": "085d7feec44f7e35",
        "name": "SET",
        "order": 8,
        "width": "2",
        "height": 4,
        "format": "<div  style=\"padding: 5px 5px 0px 5px\" >\n<div flex=\"\" layout=\"row\">\n\n     <div flex=\"22\" style=\"padding:0 5px\">    \n       <div style=\"text-align:center\"><md-input-container><input ng-model=\"tp\" aria-label=\"tp\"><span class=mylabel>TP</span></md-input-container></div> \n     </div>\n\n     <div flex=\"20\" style=\"padding:0 5px\">    \n       <div style=\"text-align:center\"><md-input-container><input ng-model=\"tp_trl\" aria-label=\"tp_trl\"><span class=mylabel>P🡅</span></md-input-container></div> \n     </div>\n\n     <div flex=\"20\" style=\"padding:0 5px\">    \n      <div style=\"text-align:center\"><md-input-container><input ng-model=\"sl\" aria-label=\"sl\"><span class=mylabel>SL</span></md-input-container></div>\n    </div>\n\n     <div flex=\"20\" style=\"padding:0 5px\">    \n    <div style=\"text-align:center\"><md-input-container><input aria-label=\"sl_trl\" ng-model=\"sl_trl\"><span class=mylabel>L🡅</span></md-input-container></div> \n    </div>\n \n    <div flex=\"18\" style=\"padding:0 5px\">\n    <div style=\"text-align:center\"><md-input-container><input aria-label=\"tm\" ng-model=\"tm\"><span class=mylabel>TM</span></md-input-container></div>        \n    </div>\n</div>\n\n<div flex=\"\" style=\"margin: 5px 5px 0px 5px\" layout=\"row\">\n    \n   <div flex=\"40\" layout=\"column\"> \n      <div style=\"margin-top:25px\" flex=\"\" layout=\"row\">\n         <div style=\"margin-left:5px\"><md-checkbox ng-model=\"sav\" aria-label=\"sav\"><i class=\"fa fa-unlock-alt\" aria-hidden=\"true\"></i></md-checkbox></div>  \n         <div style=\"margin-left:10px\"><md-checkbox ng-model=\"clear\" aria-label=\"clear\"><i class=\"fa fa-circle-o\" aria-hidden=\"true\"></i></md-checkbox></div>\n      </div> \n     <div style=\"margin: -10px 0px 0px -10px\" id=\"regular_plus\"><md-button class=\"md-button remote-button\"><span style=\"font-size:12px; color:{{msg.colour}}\" class=\"fa fa-repeat\"> </span></md-button></div>  \n    </div>\n    <div style=\"margin-left:20px\" flex=\"40\" layout=\"column\">\n <div style=\"margin:7px 0px 0px 22px; text-align:center\"><md-input-container><input aria-label=\"amt\" ng-model=\"amt\"><span class=mylabel></span></md-input-container></div>\n  <div style=\"margin:-2px 0px 0px 0px\"><md-button aria-label=\"set\" class=\"md-accent md-hue-2 md-raised\" ng-click=\"send({topic: 'set', payload:{amt:amt, aut:aut, sl_trl:sl_trl, sl:sl, tp:tp, tp_trl:tp_trl, tm:tml}})\">SET</md-button></div>\n</div>\n</div>\n<script>\n\n(function($scope) {\n    \n$('#regular_plus').on('click', function(e) {\n    e.preventDefault(); //prevent default behavior\n    $scope.send({\"topic\":\"regular_plus\",\"payload\": \"vol-up\"});\n});\n    \n})(scope);\n</script>",
        "storeOutMessages": false,
        "fwdInMessages": true,
        "resendOnRefresh": false,
        "templateScope": "local",
        "className": "setbox",
        "x": 1090,
        "y": 280,
        "wires": [
            [
                "efdd23302c2c7ff9"
            ]
        ]
    },
    {
        "id": "efdd23302c2c7ff9",
        "type": "function",
        "z": "34ed368a2b393118",
        "name": "function 2",
        "func": "/**\n * Explaination\n * Deconstruct the payload Object into local variables\n * \n * If you want to provide default values\n * let {state = true, amt = 1, tp, tp_trl, sl, sl_trl, tm, sav} = msg.payload\n */\n\nlet {state, amt, tp, tp_trl, sl, sl_trl, tm, sav} = msg.payload\nlet amt_a, tp_a, tp_trl_a, sl_a, sl_trl_a, tm_a\n\nlet topic = msg.topic\n\nif (msg.topic === \"mode\") {\n    flow.set('state', state);\n}\n\nif (flow.get('state') === \"M\") {\n\n    // Where does 'sav' come from?\n \n\n        /**\n         * Explaination\n         * if ( some_variable ) {\n         *      we don't get here if some_variable is null, undefined, 0, NaN, false, or \"\"\n         *  }\n         * \n         * Missing {} in the 'else' parts your function\n         * \n         */\n        if ( amt && amt > 0 && amt < 1001 ) {\n            flow.set('amt', amt)\n        } else {\n            amt = null\n        } \n\n        if ( tp && tp > 0 && tp < 16 ) {\n            flow.set('tp', tp)\n        } else {\n             tp = null\n        }\n\n        if ( tp_trl && tp_trl > 0 && tp_trl < 4 ) {\n            flow.set('tp_trl', tp_trl)\n        } else {\n            tp_trl = null\n        }\n\n        if ( sl && tp &&  tp > 0 && tp  < 6 )  {\n            flow.set('sl', sl)\n        } else {\n            sl = null\n        }\n\n        if ( sl_trl &&  sl_trl > 0 && sl_trl < 4 )  {\n            flow.set('sl_trl', sl_trl)\n        } else {\n            sl_trl = null\n        }\n\n        if ( tm && tm > 0 && tm < 4 ) {\n            flow.set('tm', tm)\n        } else {\n            tm = null\n        }\n\n\n\n    // Where does flow.get('int', 'file') come from?\n    /** \n     * Template literal\n     * `string text ${expression} string text`\n    */\n\n    msg.payload = `${flow.get('amt')} | ${flow.get('tp')} : ${flow.get('tp_trl')} | ${flow.get('sl')} : ${flow.get('sl_trl')} | ${flow.get('tm')} | ${flow.get('int', 'file')}`\n    msg.color = \"#777777\"\n\n} else if (flow.get('state') === \"A\") {\n    \n \n\n        if ( amt &&  amt > 0 && amt < 1001 ) {\n            flow.set('amt_a', amt, 'file')\n        } else {\n            amt_a = null\n        }\n\n        if ( tp &&  tp  > 0 && tp  < 16 ) {\n            flow.set('tp_a', tp, 'file')\n        } else {\n            tp_a = null\n        }\n\n        if ( tp_trl &&  tp_trl > 0 && tp_trl  < 4 ) {\n            flow.set('tp_trl_a', tp_trl, 'file')\n        } else {\n            tp_trl_a = null\n        }\n\n        if ( sl &&  tp &&  tp > 0 && tp < 6 )  {\n            flow.set('sl_a', sl, 'file')\n        } else {\n            sl_a = null\n        }\n\n        if ( sl_trl && sl_trl > 0 && sl_trl < 4 )  {\n            flow.set('sl_trl_a', sl_trl, 'file')\n        } else {\n            sl_trl_a = null\n        }\n\n        if ( tm &&  tm > 0 && tm < 4 ) {\n            flow.set('tm_a', tm, 'file')\n        } else {\n            tm_a = null\n        }\n\n\n\n    msg.payload = `${flow.get('amt_a', 'file')} | ${flow.get('tp_a', 'file')} : ${flow.get('tp_trl_a', 'file')} | ${flow.get('sl_a', 'file')} : ${flow.get('sl_trl_a', 'file')} | ${flow.get('tm_a', 'file')} | ${flow.get('int', 'file')}`\n    msg.color = \"#fdef55\"\n\n\n} else if (flow.get('state') === \"d\") { \n    msg.payload = \"\"\n}\n\nreturn msg\n\n\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1100,
        "y": 320,
        "wires": [
            []
        ]
    },
    {
        "id": "3164ac9abdae0221",
        "type": "inject",
        "z": "34ed368a2b393118",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{}",
        "payloadType": "json",
        "x": 910,
        "y": 500,
        "wires": [
            [
                "55915008df8e4330"
            ]
        ]
    },
    {
        "id": "55915008df8e4330",
        "type": "change",
        "z": "34ed368a2b393118",
        "name": "sw def",
        "rules": [
            {
                "t": "set",
                "p": "color",
                "pt": "msg",
                "to": "Red",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.state",
                "pt": "msg",
                "to": "A",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1090,
        "y": 400,
        "wires": [
            [
                "5cb593d7ca072adc"
            ]
        ]
    },
    {
        "id": "5cb593d7ca072adc",
        "type": "ui_multistate_switch",
        "z": "34ed368a2b393118",
        "name": "mode",
        "group": "085d7feec44f7e35",
        "order": 6,
        "width": "1",
        "height": "1",
        "label": "",
        "stateField": "payload.state",
        "enableField": "enable",
        "passthroughField": "passthrough",
        "inputMsgField": "inputmsg",
        "rounded": true,
        "useThemeColors": false,
        "hideSelectedLabel": false,
        "multilineLabel": false,
        "passThrough": "always",
        "inputMsg": "all",
        "userInput": "enabled_show",
        "options": [
            {
                "label": "&nbsp;",
                "value": "x",
                "valueType": "str",
                "color": "#1e2223"
            },
            {
                "label": "&nbsp;",
                "value": "y",
                "valueType": "str",
                "color": "#1e2223"
            },
            {
                "label": "<i class=\"fa fa-cloud-upload\"></i>",
                "value": "M",
                "valueType": "str",
                "color": "#ff0000"
            },
            {
                "label": "<i class=\"fa fa-database\"></i>",
                "value": "A",
                "valueType": "str",
                "color": "#0042ad"
            }
        ],
        "topic": "mode",
        "x": 1090,
        "y": 360,
        "wires": [
            [
                "efdd23302c2c7ff9"
            ]
        ]
    },
    {
        "id": "085d7feec44f7e35",
        "type": "ui_group",
        "name": "LEFT",
        "tab": "7e13e6107768d821",
        "order": 3,
        "disp": false,
        "width": "4",
        "collapse": false,
        "className": ""
    },
    {
        "id": "7e13e6107768d821",
        "type": "ui_tab",
        "name": "CRYPTO",
        "icon": "dashboard",
        "order": 2,
        "disabled": false,
        "hidden": false
    }
]

Seems I am still have the problem of state "A" ( filesystem) values being overwritten with defaults meant only for "M" on restart - strange, I thought it was fixed.

I have amended the 'form' to allow the default values to be shown. (set sl_rtl default to 2) Also a few minor edits to function. I have reintroduced 'sav' to show whether the output is from the default or pressing the SET button. Also changed the checkboxes to icons. Ignore anything you do not like. Mostly done to see if I could so may not be what you want

Hopefully doesn't overwrite anything on initialisation although the msg is still published (see note in function)

[
    {
        "id": "86adc926e9fd3301",
        "type": "ui_template",
        "z": "d50cb6ebd3a83f2c",
        "group": "085d7feec44f7e35",
        "name": "form",
        "order": 4,
        "width": 8,
        "height": 5,
        "format": "    <style>\n        \n        .custom-checkbox input[type=\"checkbox\"],\n            .custom-checkbox .checked {\n            display: none;\n\n        }\n \n        .custom-checkbox input[type=\"checkbox\"]:checked ~ .checked\n        {\n              display: inline-block;\n\n        }\n \n        .custom-checkbox input[type=\"checkbox\"]:checked ~ .unchecked\n        {\n            display: none;\n        }\n    </style>\n\n<div style = \"padding: 5px 5px 0px 5px\" >\n       <div flex=\"\" layout=\"row\">\n\n              <div flex=\"22\" style=\"padding:0 5px\">    \n                     <div style=\"text-align:center\"><md-input-container><input ng-model=\"tp\" aria-label=\"tp\"><span class=mylabel>TP</span></md-input-container></div> \n              </div>\n\n              <div flex=\"20\" style=\"padding:0 5px\">    \n                     <div style=\"text-align:center\"><md-input-container><input ng-model=\"tp_trl\" aria-label=\"tp_trl\"><span class=mylabel>P🡅</span></md-input-container></div> \n              </div>\n\n              <div flex=\"20\" style=\"padding:0 5px\">    \n                     <div style=\"text-align:center\"><md-input-container><input ng-model=\"sl\" aria-label=\"sl\"><span class=mylabel>SL</span></md-input-container></div>\n              </div>\n\n              <div flex=\"20\" style=\"padding:0 5px\">    \n                     <div style=\"text-align:center\"><md-input-container><input aria-label=\"sl_trl\" ng-model=\"sl_trl\"><span class=mylabel>L🡅</span></md-input-container></div> \n              </div>\n \n              <div flex=\"18\" style=\"padding:0 5px\">\n                     <div style=\"text-align:center\"><md-input-container><input aria-label=\"tm\" ng-model=\"tm\"><span class=mylabel>TM</span></md-input-container></div>        \n              </div>\n\n       </div>\n\n       <div flex=\"\" style=\"margin: 5px 5px 0px 5px\" layout=\"row\">\n    \n              <div flex=\"40\" layout=\"column\"> \n                     <div style=\"margin-top:25px\" flex=\"\" layout=\"row\">\n                            <div>\n                                   <label class = \"custom-checkbox\">\n                                          <input type = \"checkbox\" ng-model = \"sav\"/>\n                                          <i style = \"font-size: 1.6em\" class = \"fa fa-lock unchecked\"></i>\n                                          <i style = \"font-size: 1.6em\" class = \"fa fa-unlock-alt checked\"></i>\n\n                                   </label>\n \n                            </div>\n                             <div style = \"margin-left:2em\">\n                                   <label class = \"custom-checkbox\">\n                                          <input type = \"checkbox\" ng-model = \"clear\" ng-change = \"clear_form()\"/>\n                                          <i style = \"font-size: 1.6em\" class = \"fa fa-circle unchecked\"></i>\n                                          <i style = \"font-size: 1.6em\" class = \"fa fa-circle-o checked\"></i>\n\n                                   </label>\n \n                            </div>\n                            <!-- color:{{msg.colour}} not used so removed-->      \n                            <div style = \"margin: 74px 0px 0px -74px\" id = \"regular_plus\"><md-button class=\"md-button remote-button\" ng-click = \"regular_plus()\")><span style=\"font-size:1.4em; color:{{msg.colour}}\" class=\"fa fa-repeat\"></span></md-button></div>\n                     \n                     </div> \n                            \n              </div>\n    \n              <div style=\"margin-left:20px\" flex=\"40\" layout=\"column\">\n                     <div style=\"margin:0px 0px 0px 22px; text-align:center\"><md-input-container><input aria-label=\"amt\" ng-model=\"amt\"><span class=mylabel></span></md-input-container></div>\n                     <!-- changed tm:tml to tm:tm as could not find tml\n                     -->\n                     <div style=\"margin: -2px 0px 0px 0px\"><md-button aria-label=\"set\" class=\"md-accent md-hue-2 md-raised\" ng-click=\"send({topic: 'set', payload:{amt: amt, sl_trl: sl_trl, sl: sl, tp: tp, tp_trl: tp_trl, tm: tm, sav: sav, clear: clear}})\">SET</md-button></div>\n              </div>\n\n       </div>\n\n </div>\n\n<script>\n\n(function(scope) {\n\n       // Set local variables. Could also set them to default values\n       let local_amt\n       let local_sl_trl\n       let local_sl\n       let local_tp\n       let local_tp_trl\n       let local_tm\n\n       // Variables used in the form\n       scope.amt = local_amt\n       scope.sl_trl = local_sl_trl\n       scope.sl = local_sl\n       scope.tp = local_tp\n       scope.tp_trl = local_tp_trl\n       scope.tm = local_tm\n\n       scope.clear = false\n       scope.sav = false\n\n       // Clear form\n       scope.clear_form = function() {\n              if (scope.clear === true) {\n                     local_amt = ''\n                     local_sl_trl = ''\n                     local_sl = ''\n                     local_tp = ''\n                     local_tp_trl = ''\n                     local_tm = ''\n\n                     showChange()\n\n              }\n\n       }\n  \n       scope.regular_plus = function() {\n              scope.send({topic: 'regular_plus', payload: 'vol-up'})\n\n       }\n\n       scope.$watch('msg', function(msg) {\n              // No error checking for properties\n              if(msg) {\n                     local_amt = msg.payload.amt\n                     local_sl_trl = msg.payload.sl_trl\n                     local_sl = msg.payload.sl\n                     local_tp = msg.payload.tp\n                     local_tp_trl = msg.payload.tp_trl\n                     local_tm = msg.payload.tm\n                     scope.clear = msg.payload.clear\n\n                     // Set to false so any incoming msg does not action following function\n                     msg.payload.sav = false                 \n\n                     showChange()\n\n                     scope.send(msg)\n              }\n\n       })\n    \n       // Update the scope variables to reflect back to the HTML\n       function showChange() {\n              scope.amt = local_amt\n              scope.sl_trl = local_sl_trl\n              scope.sl = local_sl\n              scope.tp = local_tp\n              scope.tp_trl = local_tp_trl\n              scope.tm = local_tm\n                            \n       }\n \n\n})(scope);\n</script>",
        "storeOutMessages": false,
        "fwdInMessages": false,
        "resendOnRefresh": false,
        "templateScope": "local",
        "className": "setbox",
        "x": 690,
        "y": 260,
        "wires": [
            [
                "d68ab5f6f76916cf",
                "43d0f1df8bfdcf0a"
            ]
        ]
    },
    {
        "id": "deea311bab3c6bc3",
        "type": "change",
        "z": "d50cb6ebd3a83f2c",
        "name": "defaults",
        "rules": [
            {
                "t": "set",
                "p": "payload.amt",
                "pt": "msg",
                "to": "20",
                "tot": "num"
            },
            {
                "t": "set",
                "p": "payload.sl",
                "pt": "msg",
                "to": "3",
                "tot": "num"
            },
            {
                "t": "set",
                "p": "payload.tp",
                "pt": "msg",
                "to": "5",
                "tot": "num"
            },
            {
                "t": "set",
                "p": "payload.tp_trl",
                "pt": "msg",
                "to": "1",
                "tot": "num"
            },
            {
                "t": "set",
                "p": "payload.sl_trl",
                "pt": "msg",
                "to": "2",
                "tot": "num"
            },
            {
                "t": "set",
                "p": "payload.tm",
                "pt": "msg",
                "to": "1",
                "tot": "num"
            },
            {
                "t": "set",
                "p": "payload.sav",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.clear",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 340,
        "y": 260,
        "wires": [
            [
                "86adc926e9fd3301",
                "eedde58b17cb3d65"
            ]
        ]
    },
    {
        "id": "3941c8d39fb0b5e2",
        "type": "ui_text",
        "z": "d50cb6ebd3a83f2c",
        "group": "085d7feec44f7e35",
        "order": 1,
        "width": 8,
        "height": 1,
        "name": "display",
        "label": "",
        "format": "<font color= {{msg.color}} > {{msg.payload}} </font>",
        "layout": "row-spread",
        "className": "values",
        "x": 1100,
        "y": 140,
        "wires": []
    },
    {
        "id": "fbc2463f5e25697a",
        "type": "ui_multistate_switch",
        "z": "d50cb6ebd3a83f2c",
        "name": "multi-switch",
        "group": "085d7feec44f7e35",
        "order": 2,
        "width": 3,
        "height": 1,
        "label": "",
        "stateField": "payload.state",
        "enableField": "enable",
        "passthroughField": "passthrough",
        "inputMsgField": "inputmsg",
        "rounded": true,
        "useThemeColors": false,
        "hideSelectedLabel": false,
        "multilineLabel": false,
        "passThrough": "change",
        "inputMsg": "all",
        "userInput": "enabled_show",
        "options": [
            {
                "label": "&nbsp;",
                "value": "x",
                "valueType": "str",
                "color": "#1e2223"
            },
            {
                "label": "&nbsp;",
                "value": "y",
                "valueType": "str",
                "color": "#1e2223"
            },
            {
                "label": "<i class=\"fa fa-cloud-upload\"></i>",
                "value": "M",
                "valueType": "str",
                "color": "#ff0000"
            },
            {
                "label": "<i class=\"fa fa-database\"></i>",
                "value": "A",
                "valueType": "str",
                "color": "#0042ad"
            }
        ],
        "topic": "mode",
        "x": 700,
        "y": 320,
        "wires": [
            [
                "a657261f9d5316cd",
                "43d0f1df8bfdcf0a"
            ]
        ]
    },
    {
        "id": "240d45409613b4f4",
        "type": "inject",
        "z": "d50cb6ebd3a83f2c",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{}",
        "payloadType": "json",
        "x": 110,
        "y": 320,
        "wires": [
            [
                "deea311bab3c6bc3",
                "527d65ec8cc3ab31"
            ]
        ]
    },
    {
        "id": "d68ab5f6f76916cf",
        "type": "debug",
        "z": "d50cb6ebd3a83f2c",
        "name": "debug 4",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 900,
        "y": 240,
        "wires": []
    },
    {
        "id": "a657261f9d5316cd",
        "type": "debug",
        "z": "d50cb6ebd3a83f2c",
        "name": "debug 5",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 900,
        "y": 400,
        "wires": []
    },
    {
        "id": "f94ca8bfbd5df65c",
        "type": "debug",
        "z": "d50cb6ebd3a83f2c",
        "name": "debug 6",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1100,
        "y": 200,
        "wires": []
    },
    {
        "id": "527d65ec8cc3ab31",
        "type": "change",
        "z": "d50cb6ebd3a83f2c",
        "name": "Switch Defaults",
        "rules": [
            {
                "t": "set",
                "p": "color",
                "pt": "msg",
                "to": "Red",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.state",
                "pt": "msg",
                "to": "A",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 340,
        "y": 320,
        "wires": [
            [
                "fbc2463f5e25697a"
            ]
        ]
    },
    {
        "id": "43d0f1df8bfdcf0a",
        "type": "function",
        "z": "d50cb6ebd3a83f2c",
        "name": "function 2",
        "func": "/**\n * Explaination\n * Deconstruct the payload Object into local variables\n * \n * If you want to provide default values\n * let {state = 'A', amt = 1, tp, tp_trl, sl, sl_trl, tm, sav, clear = false} = msg.payload\n * \n * aut does not seem to get used so removed\n * \n * regular_plus not handled yet\n * \n * 'state' = d not input yet. Changed this to 'clear' data. See last 'if', sets msg.payload to ''\n * \n */\n\n\nlet {state, amt, tp, tp_trl, sl, sl_trl, tm, sav, clear = false} = msg.payload\nlet amt_a, tp_a, tp_trl_a, sl_a, sl_trl_a, tm_a\n\nlet topic = msg.topic\n\nif (msg.topic === \"mode\") {\n    flow.set('state', state);\n}\n\nif (flow.get('state') === \"M\") {\n\n    // If SET Button pressed\n    if (sav) {\n\n        /**\n         * Explaination\n         * if ( some_variable ) {\n         *      we don't get here if some_variable is null, undefined, 0, NaN, false, or \"\"\n         *  }\n         * \n         * Missing {} in the 'else' parts your function\n         * \n         */\n        if ( amt && amt > 0 && amt < 1001 ) {\n            flow.set('amt', amt)\n        } else {\n            amt = null\n        } \n\n        if ( tp && tp > 0 && tp < 16 ) {\n            flow.set('tp', tp)\n        } else {\n             tp = null\n        }\n\n        if ( tp_trl && tp_trl > 0 && tp_trl < 4 ) {\n            flow.set('tp_trl', tp_trl)\n        } else {\n            tp_trl = null\n        }\n\n        if ( sl && tp &&  tp > 0 && tp  < 6 )  {\n            flow.set('sl', sl)\n        } else {\n            sl = null\n        }\n\n        if ( sl_trl &&  sl_trl > 0 && sl_trl < 4 )  {\n            flow.set('sl_trl', sl_trl)\n        } else {\n            sl_trl = null\n        }\n\n        if ( tm && tm > 0 && tm < 4 ) {\n            flow.set('tm', tm)\n        } else {\n            tm = null\n        }\n\n    }\n\n    // Where does flow.get('int', 'file') come from? This may get sent when form initialised so could be moved into if(sav) section above\n    /** \n     * Template literal\n     * `string text ${expression} string text`\n    */\n\n    msg.payload = `${flow.get('amt')} | ${flow.get('tp')} : ${flow.get('tp_trl')} | ${flow.get('sl')}  : ${flow.get('sl_trl')} | ${flow.get('tm')} | ${flow.get('int', 'file')}`\n    msg.color = \"#777777\"\n\n} else if (flow.get('state') === \"A\") {\n    \n    if (sav) {\n\n        if ( amt &&  amt > 0 && amt < 1001 ) {\n            flow.set('amt_a', amt, 'file')\n        } else {\n            amt_a = null\n        }\n\n        if ( tp &&  tp  > 0 && tp  < 16 ) {\n            flow.set('tp_a', tp, 'file')\n        } else {\n            tp_a = null\n        }\n\n        if ( tp_trl && tp_trl > 0 && tp_trl  < 4 ) {\n            flow.set('tp_trl_a', tp_trl, 'file')\n        } else {\n            tp_trl_a = null\n        }\n\n        if ( sl &&  tp &&  tp > 0 && tp < 6 )  {\n            flow.set('sl_a', sl, 'file')\n        } else {\n            sl_a = null\n        }\n\n        if ( sl_trl && sl_trl > 0 && sl_trl < 4 )  {\n            flow.set('sl_trl_a', sl_trl, 'file')\n        } else {\n            sl_trl_a = null\n        }\n\n        if ( tm &&  tm > 0 && tm < 4 ) {\n            flow.set('tm_a', tm, 'file')\n        } else {\n            tm_a = null\n        }\n\n    }\n\n    // This may get sent when form initialised so could be moved into if(sav) section above\n    msg.payload = `${flow.get('amt_a', 'file')} | ${flow.get('tp_a', 'file')} : ${flow.get('tp_trl_a', 'file')} | ${flow.get('sl_a', 'file')}  : ${flow.get('sl_trl_a', 'file')} | ${flow.get('tm_a', 'file')} | ${flow.get('int', 'file')}`\n    msg.color = \"#fdef55\"\n\n}\n\nif (clear === true) { \n    msg.payload = \"\"\n\n}\n\nreturn msg",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 900,
        "y": 140,
        "wires": [
            [
                "f94ca8bfbd5df65c",
                "3941c8d39fb0b5e2"
            ]
        ]
    },
    {
        "id": "eedde58b17cb3d65",
        "type": "debug",
        "z": "d50cb6ebd3a83f2c",
        "name": "debug 8",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 520,
        "y": 160,
        "wires": []
    },
    {
        "id": "085d7feec44f7e35",
        "type": "ui_group",
        "name": "LEFT",
        "tab": "7e13e6107768d821",
        "order": 3,
        "disp": false,
        "width": 8,
        "collapse": false,
        "className": ""
    },
    {
        "id": "7e13e6107768d821",
        "type": "ui_tab",
        "name": "CRYPTO",
        "icon": "dashboard",
        "order": 2,
        "disabled": false,
        "hidden": false
    }
]

Hi, sorry, my form had changed since the original version (It was in the flow that I included in the last message). I tried getting your updates into the new form/function but something is wrong, can't update any values. Could you take a look pls ... thanks again.

[
    {
        "id": "ee4152b3e411a368",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "3eff36e85affaf3a",
        "type": "change",
        "z": "ee4152b3e411a368",
        "name": "defaults",
        "rules": [
            {
                "t": "set",
                "p": "payload.currency",
                "pt": "msg",
                "to": "GALA",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.exchange",
                "pt": "msg",
                "to": "Gate.io",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.flag",
                "pt": "msg",
                "to": "reset",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "time",
                "pt": "msg",
                "to": "",
                "tot": "date"
            },
            {
                "t": "set",
                "p": "payload.change",
                "pt": "msg",
                "to": "",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.window",
                "pt": "msg",
                "to": "",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.note",
                "pt": "msg",
                "to": "",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 410,
        "y": 320,
        "wires": [
            [
                "0bcf980968b29705"
            ]
        ]
    },
    {
        "id": "96d2d5d344dc9e74",
        "type": "change",
        "z": "ee4152b3e411a368",
        "name": "values",
        "rules": [
            {
                "t": "set",
                "p": "payload.amt",
                "pt": "msg",
                "to": "20",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.tp",
                "pt": "msg",
                "to": "5",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.tp_trl",
                "pt": "msg",
                "to": "3",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.sl",
                "pt": "msg",
                "to": "3",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.sl_trl",
                "pt": "msg",
                "to": "2",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.tm",
                "pt": "msg",
                "to": "1",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.sav",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.clear",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.state",
                "pt": "msg",
                "to": "M",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 410,
        "y": 280,
        "wires": [
            [
                "095e2829ccad11d0"
            ]
        ]
    },
    {
        "id": "0bcf980968b29705",
        "type": "link out",
        "z": "ee4152b3e411a368",
        "name": "link out 32",
        "mode": "link",
        "links": [
            "1cad2a747e05334e"
        ],
        "x": 415,
        "y": 360,
        "wires": []
    },
    {
        "id": "6542a9b4fb109ade",
        "type": "link in",
        "z": "ee4152b3e411a368",
        "name": "link in 8",
        "links": [
            "bf9d41a5946d11f9"
        ],
        "x": 315,
        "y": 300,
        "wires": [
            [
                "96d2d5d344dc9e74",
                "3eff36e85affaf3a"
            ]
        ]
    },
    {
        "id": "095e2829ccad11d0",
        "type": "ui_template",
        "z": "ee4152b3e411a368",
        "group": "085d7feec44f7e35",
        "name": "SET",
        "order": 8,
        "width": "2",
        "height": 4,
        "format": "<div  style=\"padding: 5px 5px 0px 5px\" >\n<div flex=\"\" layout=\"row\">\n\n     <div flex=\"22\" style=\"padding:0 5px\">    \n       <div style=\"text-align:center\"><md-input-container><input ng-model=\"tp\" aria-label=\"tp\"><span class=mylabel>TP</span></md-input-container></div> \n     </div>\n\n     <div flex=\"20\" style=\"padding:0 5px\">    \n       <div style=\"text-align:center\"><md-input-container><input ng-model=\"tp_trl\" aria-label=\"tp_trl\"><span class=mylabel>P🡅</span></md-input-container></div> \n     </div>\n\n     <div flex=\"20\" style=\"padding:0 5px\">    \n      <div style=\"text-align:center\"><md-input-container><input ng-model=\"sl\" aria-label=\"sl\"><span class=mylabel>SL</span></md-input-container></div>\n    </div>\n\n     <div flex=\"20\" style=\"padding:0 5px\">    \n    <div style=\"text-align:center\"><md-input-container><input aria-label=\"sl_trl\" ng-model=\"sl_trl\"><span class=mylabel>L🡅</span></md-input-container></div> \n    </div>\n \n    <div flex=\"18\" style=\"padding:0 5px\">\n    <div style=\"text-align:center\"><md-input-container><input aria-label=\"tm\" ng-model=\"tm\"><span class=mylabel>TM</span></md-input-container></div>        \n    </div>\n</div>\n\n<div flex=\"\" style=\"margin: 5px 5px 0px 5px\" layout=\"row\">\n    \n   <div flex=\"40\" layout=\"column\"> \n      <div style=\"margin-top:25px\" flex=\"\" layout=\"row\">\n         <div style=\"margin-left:5px\"><md-checkbox ng-model=\"sav\" aria-label=\"sav\"><i class=\"fa fa-unlock-alt\" aria-hidden=\"true\"></i></md-checkbox></div>  \n         <div style=\"margin-left:10px\"><md-checkbox ng-model=\"clear\" aria-label=\"clear\"><i class=\"fa fa-circle-o\" aria-hidden=\"true\"></i></md-checkbox></div>\n      </div> \n     <div style=\"margin: -10px 0px 0px -10px\" id=\"regular_plus\"><md-button class=\"md-button remote-button\"><span style=\"font-size:12px; color:{{msg.colour}}\" class=\"fa fa-repeat\"> </span></md-button></div>  \n    </div>\n    <div style=\"margin-left:20px\" flex=\"40\" layout=\"column\">\n <div style=\"margin:7px 0px 0px 22px; text-align:center\"><md-input-container><input aria-label=\"amt\" ng-model=\"amt\"><span class=mylabel></span></md-input-container></div>\n  <div style=\"margin:-2px 0px 0px 0px\"><md-button aria-label=\"set\" class=\"md-accent md-hue-2 md-raised\" ng-click=\"send({topic: 'set', payload:{amt:amt, aut:aut, sl_trl:sl_trl, sl:sl, tp:tp, tp_trl:tp_trl, tm:tml}})\">SET</md-button></div>\n</div>\n</div>\n\n\n<script>\n\n(function(scope) {\n\n       // Set local variables. Could also set them to default values\n       let local_amt\n       let local_sl_trl\n       let local_sl\n       let local_tp\n       let local_tp_trl\n       let local_tm\n\n       // Variables used in the form\n       scope.amt = local_amt\n       scope.sl_trl = local_sl_trl\n       scope.sl = local_sl\n       scope.tp = local_tp\n       scope.tp_trl = local_tp_trl\n       scope.tm = local_tm\n\n       scope.clear = false\n       scope.sav = false\n\n       // Clear form\n       scope.clear_form = function() {\n              if (scope.clear === true) {\n                     local_amt = ''\n                     local_sl_trl = ''\n                     local_sl = ''\n                     local_tp = ''\n                     local_tp_trl = ''\n                     local_tm = ''\n\n                     showChange()\n\n              }\n\n       }\n  \n       scope.regular_plus = function() {\n              scope.send({topic: 'regular_plus', payload: 'vol-up'})\n\n       }\n\n       scope.$watch('msg', function(msg) {\n              // No error checking for properties\n              if(msg) {\n                     local_amt = msg.payload.amt\n                     local_sl_trl = msg.payload.sl_trl\n                     local_sl = msg.payload.sl\n                     local_tp = msg.payload.tp\n                     local_tp_trl = msg.payload.tp_trl\n                     local_tm = msg.payload.tm\n                     scope.clear = msg.payload.clear\n\n                     // Set to false so any incoming msg does not action following function\n                     msg.payload.sav = false                 \n\n                     showChange()\n\n                     scope.send(msg)\n              }\n\n       })\n    \n       // Update the scope variables to reflect back to the HTML\n       function showChange() {\n              scope.amt = local_amt\n              scope.sl_trl = local_sl_trl\n              scope.sl = local_sl\n              scope.tp = local_tp\n              scope.tp_trl = local_tp_trl\n              scope.tm = local_tm\n                            \n       }\n \n\n})(scope);\n</script>",
        "storeOutMessages": false,
        "fwdInMessages": true,
        "resendOnRefresh": false,
        "templateScope": "local",
        "className": "setbox",
        "x": 610,
        "y": 280,
        "wires": [
            [
                "23f596f2b259e92f"
            ]
        ]
    },
    {
        "id": "23f596f2b259e92f",
        "type": "function",
        "z": "ee4152b3e411a368",
        "name": "set",
        "func": "/**\n * Explaination\n * Deconstruct the payload Object into local variables\n * \n * If you want to provide default values\n * let {state = true, amt = 1, tp, tp_trl, sl, sl_trl, tm, sav} = msg.payload\n */\n\nlet {state, amt, tp, tp_trl, sl, sl_trl, tm, sav, clear = false} = msg.payload\nlet amt_a, tp_a, tp_trl_a, sl_a, sl_trl_a, tm_a, tp_s, sl_s, tp_s_a, sl_s_a, tp_trl_s, tp_trl_s_a, sl_trl_s, sl_trl_s_a, tm_s, tm_s_a, P, L, P_a, L_a, T, T_a\n\nlet topic = msg.topic\n\nif (msg.topic === \"mode\") {\n    flow.set('state', state);\n}\n\nif (flow.get('state') === \"M\") {\n\n    // If SET Button pressed\n    if (sav) {\n\n        /**\n         * Explaination\n         * if ( some_variable ) {\n         *      we don't get here if some_variable is null, undefined, 0, NaN, false, or \"\"\n         *  }\n         * \n         * \n         */\n        if ( amt && amt > 19 && amt < 1001 ) {\n            flow.set('amt', amt)\n        } else {\n            amt = null\n        } \n\n        if ( tp && tp > 0 && tp < 16 ) {\n            flow.set('tp', tp); tp_s = true;\n        } else {\n             tp = null; tp_s = false;\n             \n        } flow.set('tp_s', tp_s);\n\n        if ( tp_trl && tp_trl > 0 && tp_trl < 4 ) {\n            flow.set('tp_trl', tp_trl); tp_trl_s = true;\n        } else {\n            tp_trl = null; tp_trl_s = false;\n            \n        }   flow.set('tp_trl_s', tp_trl_s);\n\n        if ( sl && tp &&  tp > 0 && tp  < 6 )  {\n            flow.set('sl', sl); sl_s = true;\n        } else {\n            sl = null; sl_s = false;\n            \n        }   flow.set('sl_s', sl_s);\n\n        if ( sl_trl &&  sl_trl > 0 && sl_trl < 4 )  {\n            flow.set('sl_trl', sl_trl); sl_trl_s = true;\n        } else {\n            sl_trl = null; sl_trl_s = false;\n            \n        }   flow.set('sl_trl_s', sl_trl_s);\n\n        if ( tm && tm > 0 && tm < 4 ) {\n            flow.set('tm', tm); tm_s = true;\n        } else {\n            tm = null; tm_s = false;\n            \n        }   flow.set('tm_s', tm_s);\n\n}\n\n    /** \n     * Template literal\n     * `string text ${expression} string text`\n    */\n    \n    if(tp_s) {P = \"${flow.get('tp')} : ${flow.get('tp_trl')}\"}  else {P = \"\"}  \n  \n//    msg.payload = `${flow.get('amt')}  | L  ${flow.get('sl')} : ${flow.get('sl_trl')}  | T  ${flow.get('tm')} | ${flow.get('int', 'file')}`\n \n      msg.payload = `${flow.get('amt')}  | P  ${flow.get('tp')} : ${flow.get('tp_trl')}  | L  ${flow.get('sl')} : ${flow.get('sl_trl')}  | T  ${flow.get('tm')} | ${flow.get('int', 'file')}`\n      msg.color = \"#777777\"\n\n} else if (flow.get('state') === \"A\") {\n    \n     if (sav) {\n\n        if ( amt &&  amt > 0 && amt < 1001 ) {\n            flow.set('amt_a', amt, 'file')\n        } else {\n            amt_a = null\n        }\n\n        if ( tp &&  tp  > 0 && tp  < 16 ) {\n            flow.set('tp_a', tp, 'file'); tp_s_a = true;\n        } else {\n            tp_a = null; tp_s_a = false;\n        }\n\n        if ( tp_trl &&  tp_trl > 0 && tp_trl  < 4 ) {\n            flow.set('tp_trl_a', tp_trl, 'file'); tp_trl_s_a = true;\n        } else {\n            tp_trl_a = null; tp_trl_s_a = false;\n        }\n\n        if ( sl &&  tp &&  tp > 0 && tp < 6 )  {\n            flow.set('sl_a', sl, 'file'); sl_s_a = true;\n        } else {\n            sl_a = null; sl_s_a = false;\n        }\n\n        if ( sl_trl && sl_trl > 0 && sl_trl < 4 )  {\n            flow.set('sl_trl_a', sl_trl, 'file');sl_trl_s_a = true;\n        } else {\n            sl_trl_a = null; sl_trl_s_a = false;\n        }\n\n        if ( tm &&  tm > 0 && tm < 4 ) {\n            flow.set('tm_a', tm, 'file'); tm_s_a = true;\n        } else {\n            tm_a = null; tm_s_a = false;\n        }\n    }\n\n\n    msg.payload = `${flow.get('amt_a', 'file')} | P  ${flow.get('tp_a', 'file')} : ${flow.get('tp_trl_a', 'file')} | L  ${flow.get('sl_a', 'file')} : ${flow.get('sl_trl_a', 'file')}  | T  ${flow.get('tm_a', 'file')} | ${flow.get('int', 'file')}`\n    msg.color = \"#fdef55\"\n\n}\n\n\nif (clear === true) { \n    msg.payload = \"\"\n\n}\n\nreturn msg\n\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 610,
        "y": 320,
        "wires": [
            [
                "6dc9b10f57abfe41"
            ]
        ]
    },
    {
        "id": "024ed1746fc3fb92",
        "type": "inject",
        "z": "ee4152b3e411a368",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{}",
        "payloadType": "json",
        "x": 430,
        "y": 500,
        "wires": [
            [
                "4d2fa98ceb33fa36"
            ]
        ]
    },
    {
        "id": "4d2fa98ceb33fa36",
        "type": "change",
        "z": "ee4152b3e411a368",
        "name": "sw def",
        "rules": [
            {
                "t": "set",
                "p": "color",
                "pt": "msg",
                "to": "Red",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.state",
                "pt": "msg",
                "to": "A",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 610,
        "y": 400,
        "wires": [
            [
                "330aafd7e607bafb"
            ]
        ]
    },
    {
        "id": "6dc9b10f57abfe41",
        "type": "ui_text",
        "z": "ee4152b3e411a368",
        "group": "085d7feec44f7e35",
        "order": 3,
        "width": "2",
        "height": "1",
        "name": "values",
        "label": "",
        "format": "<font color= {{msg.color}} > {{msg.payload}} </font>",
        "layout": "row-spread",
        "className": "values",
        "x": 770,
        "y": 360,
        "wires": []
    },
    {
        "id": "330aafd7e607bafb",
        "type": "ui_multistate_switch",
        "z": "ee4152b3e411a368",
        "name": "mode",
        "group": "085d7feec44f7e35",
        "order": 6,
        "width": "1",
        "height": "1",
        "label": "",
        "stateField": "payload.state",
        "enableField": "enable",
        "passthroughField": "passthrough",
        "inputMsgField": "inputmsg",
        "rounded": true,
        "useThemeColors": false,
        "hideSelectedLabel": false,
        "multilineLabel": false,
        "passThrough": "always",
        "inputMsg": "all",
        "userInput": "enabled_show",
        "options": [
            {
                "label": "&nbsp;",
                "value": "d",
                "valueType": "str",
                "color": "#1e2223"
            },
            {
                "label": "&nbsp;",
                "value": "y",
                "valueType": "str",
                "color": "#1e2223"
            },
            {
                "label": "<i class=\"fa fa-cloud-upload\"></i>",
                "value": "M",
                "valueType": "str",
                "color": "#ff0000"
            },
            {
                "label": "<i class=\"fa fa-database\"></i>",
                "value": "A",
                "valueType": "str",
                "color": "#0042ad"
            }
        ],
        "topic": "mode",
        "x": 610,
        "y": 360,
        "wires": [
            [
                "23f596f2b259e92f"
            ]
        ]
    },
    {
        "id": "085d7feec44f7e35",
        "type": "ui_group",
        "name": "LEFT",
        "tab": "7e13e6107768d821",
        "order": 3,
        "disp": false,
        "width": "4",
        "collapse": false,
        "className": ""
    },
    {
        "id": "7e13e6107768d821",
        "type": "ui_tab",
        "name": "CRYPTO",
        "icon": "dashboard",
        "order": 2,
        "disabled": false,
        "hidden": false
    }
]

Should work now. Some edits with comments

[
    {
        "id": "d024f151657a2969",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "acc45ad8c52f5d73",
        "type": "change",
        "z": "d024f151657a2969",
        "name": "defaults",
        "rules": [
            {
                "t": "set",
                "p": "payload.currency",
                "pt": "msg",
                "to": "GALA",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.exchange",
                "pt": "msg",
                "to": "Gate.io",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.flag",
                "pt": "msg",
                "to": "reset",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "time",
                "pt": "msg",
                "to": "",
                "tot": "date"
            },
            {
                "t": "set",
                "p": "payload.change",
                "pt": "msg",
                "to": "",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.window",
                "pt": "msg",
                "to": "",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.note",
                "pt": "msg",
                "to": "",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 420,
        "y": 320,
        "wires": [
            [
                "c8a328181d735035"
            ]
        ]
    },
    {
        "id": "8adb65042e91f44c",
        "type": "change",
        "z": "d024f151657a2969",
        "name": "values",
        "rules": [
            {
                "t": "set",
                "p": "payload.amt",
                "pt": "msg",
                "to": "20",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.tp",
                "pt": "msg",
                "to": "5",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.tp_trl",
                "pt": "msg",
                "to": "3",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.sl",
                "pt": "msg",
                "to": "3",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.sl_trl",
                "pt": "msg",
                "to": "2",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.tm",
                "pt": "msg",
                "to": "1",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.sav",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.clear",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.state",
                "pt": "msg",
                "to": "M",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 410,
        "y": 280,
        "wires": [
            [
                "2dd518a943174baf",
                "5c67705336061196"
            ]
        ]
    },
    {
        "id": "c8a328181d735035",
        "type": "link out",
        "z": "d024f151657a2969",
        "name": "link out 32",
        "mode": "link",
        "links": [
            "1cad2a747e05334e"
        ],
        "x": 415,
        "y": 360,
        "wires": []
    },
    {
        "id": "f1b52ba38f793428",
        "type": "link in",
        "z": "d024f151657a2969",
        "name": "link in 8",
        "links": [
            "bf9d41a5946d11f9"
        ],
        "x": 285,
        "y": 280,
        "wires": [
            [
                "8adb65042e91f44c",
                "acc45ad8c52f5d73"
            ]
        ]
    },
    {
        "id": "2dd518a943174baf",
        "type": "ui_template",
        "z": "d024f151657a2969",
        "group": "01243dae5db25fd5",
        "name": "SET",
        "order": 4,
        "width": 8,
        "height": 5,
        "format": "<!-- added style to align icons under checkboxes -->\n<style>\n       md-checkbox .md-label {\n              margin-left: 5px;\n              margin-top: 14px;\n\n       }\n       \n</style>\n\n<div  style=\"padding: 5px 5px 0px 5px\" >\n<div flex=\"\" layout=\"row\">\n\n     <div flex=\"22\" style=\"padding:0 5px\">    \n       <div style=\"text-align:center\"><md-input-container><input ng-model=\"tp\" aria-label=\"tp\"><span class=mylabel>TP</span></md-input-container></div> \n     </div>\n\n     <div flex=\"20\" style=\"padding:0 5px\">    \n       <div style=\"text-align:center\"><md-input-container><input ng-model=\"tp_trl\" aria-label=\"tp_trl\"><span class=mylabel>P🡅</span></md-input-container></div> \n     </div>\n\n     <div flex=\"20\" style=\"padding:0 5px\">    \n      <div style=\"text-align:center\"><md-input-container><input ng-model=\"sl\" aria-label=\"sl\"><span class=mylabel>SL</span></md-input-container></div>\n    </div>\n\n     <div flex=\"20\" style=\"padding:0 5px\">    \n    <div style=\"text-align:center\"><md-input-container><input aria-label=\"sl_trl\" ng-model=\"sl_trl\"><span class=mylabel>L🡅</span></md-input-container></div> \n    </div>\n \n    <div flex=\"18\" style=\"padding:0 5px\">\n    <div style=\"text-align:center\"><md-input-container><input aria-label=\"tm\" ng-model=\"tm\"><span class=mylabel>TM</span></md-input-container></div>        \n    </div>\n</div>\n\n<div flex=\"\" style=\"margin: 5px 5px 0px 5px\" layout=\"row\">\n    \n   <div flex=\"40\" layout=\"column\"> \n      <div style=\"margin-top:25px\" flex=\"\" layout=\"row\">\n         <div style=\"margin-left:5px\"><md-checkbox ng-model=\"sav\" aria-label=\"sav\"><i class=\"fa fa-unlock-alt\" aria-hidden=\"true\"></i></md-checkbox></div>  \n         <!-- added ng-change = \"clear_form()\" -->\n         <div style=\"margin-left:10px\"><md-checkbox ng-model=\"clear\" ng-change = \"clear_form()\" aria-label=\"clear\"><i class=\"fa fa-circle-o\" aria-hidden=\"true\"></i></md-checkbox></div>\n      </div> \n     <!-- color:{{msg.colour}} not used so removed. Added ng-click = \"regular_plus()\" to action function --> \n     <div style=\"margin: -10px 0px 0px -10px\" id=\"regular_plus\"><md-button class=\"md-button remote-button\" ng-click = \"regular_plus()\"><span style=\"font-size:12px; color:{{msg.colour}}\" class=\"fa fa-repeat\"> </span></md-button></div>  \n    </div>\n    <div style=\"margin-left:20px\" flex=\"40\" layout=\"column\">\n <div style=\"margin:7px 0px 0px 22px; text-align:center\"><md-input-container><input aria-label=\"amt\" ng-model=\"amt\"><span class=mylabel></span></md-input-container></div>\n       <!-- changed tm:tml to tm:tm as could not find tml, changed aut to sav -->\n       <div style=\"margin:-2px 0px 0px 0px\"><md-button aria-label=\"set\" class=\"md-accent md-hue-2 md-raised\" ng-click=\"send({topic: 'set', payload:{amt:amt, sav:sav, sl_trl:sl_trl, sl:sl, tp:tp, tp_trl:tp_trl, tm:tm}})\">SET</md-button></div>\n</div>\n</div>\n\n\n<script>\n\n(function(scope) {\n\n       // Set local variables. Could also set them to default values\n       let local_amt\n       let local_sl_trl\n       let local_sl\n       let local_tp\n       let local_tp_trl\n       let local_tm\n\n       // Variables used in the form\n       scope.amt = local_amt\n       scope.sl_trl = local_sl_trl\n       scope.sl = local_sl\n       scope.tp = local_tp\n       scope.tp_trl = local_tp_trl\n       scope.tm = local_tm\n\n       scope.clear = false\n       scope.sav = false\n\n       // Clear form\n       scope.clear_form = function() {\n              if (scope.clear === true) {\n                     local_amt = ''\n                     local_sl_trl = ''\n                     local_sl = ''\n                     local_tp = ''\n                     local_tp_trl = ''\n                     local_tm = ''\n\n                     showChange()\n\n              }\n\n       }\n  \n       scope.regular_plus = function() {\n              scope.send({topic: 'regular_plus', payload: 'vol-up'})\n\n       }\n\n       scope.$watch('msg', function(msg) {\n              // No error checking for properties\n              if(msg) {\n                     local_amt = msg.payload.amt\n                     local_sl_trl = msg.payload.sl_trl\n                     local_sl = msg.payload.sl\n                     local_tp = msg.payload.tp\n                     local_tp_trl = msg.payload.tp_trl\n                     local_tm = msg.payload.tm\n                     scope.clear = msg.payload.clear\n\n                     // Set to false so any incoming msg does not action following function\n                     msg.payload.sav = false                 \n\n                     showChange()\n\n                     scope.send(msg)\n              }\n\n       })\n    \n       // Update the scope variables to reflect back to the HTML\n       function showChange() {\n              scope.amt = local_amt\n              scope.sl_trl = local_sl_trl\n              scope.sl = local_sl\n              scope.tp = local_tp\n              scope.tp_trl = local_tp_trl\n              scope.tm = local_tm\n                            \n       }\n \n\n})(scope);\n</script>",
        "storeOutMessages": false,
        "fwdInMessages": true,
        "resendOnRefresh": false,
        "templateScope": "local",
        "className": "setbox",
        "x": 610,
        "y": 280,
        "wires": [
            [
                "54d76d4680fef5b0",
                "3127b608ed979b4a"
            ]
        ]
    },
    {
        "id": "54d76d4680fef5b0",
        "type": "function",
        "z": "d024f151657a2969",
        "name": "set",
        "func": "/**\n * Explaination\n * Deconstruct the payload Object into local variables\n * \n * If you want to provide default values\n * let {state = true, amt = 1, tp, tp_trl, sl, sl_trl, tm, sav} = msg.payload\n */\n\nlet {state, amt, tp, tp_trl, sl, sl_trl, tm, sav, clear = false} = msg.payload\nlet amt_a, tp_a, tp_trl_a, sl_a, sl_trl_a, tm_a, tp_s, sl_s, tp_s_a, sl_s_a, tp_trl_s, tp_trl_s_a, sl_trl_s, sl_trl_s_a, tm_s, tm_s_a, P, L, P_a, L_a, T, T_a\n\nlet topic = msg.topic\n\nif (msg.topic === \"mode\") {\n    flow.set('state', state);\n}\n\nif (flow.get('state') === \"M\") {\n\n    // If SET Button pressed\n    if (sav) {\n\n        /**\n         * Explaination\n         * if ( some_variable ) {\n         *      we don't get here if some_variable is null, undefined, 0, NaN, false, or \"\"\n         *  }\n         * \n         * \n         */\n        if ( amt && amt > 19 && amt < 1001 ) {\n            flow.set('amt', amt)\n        } else {\n            amt = null\n        } \n\n        if ( tp && tp > 0 && tp < 16 ) {\n            flow.set('tp', tp);\n            tp_s = true;\n        } else {\n             tp = null;\n             tp_s = false;\n             \n        }\n        \n        flow.set('tp_s', tp_s);\n\n        if ( tp_trl && tp_trl > 0 && tp_trl < 4 ) {\n            flow.set('tp_trl', tp_trl);\n            tp_trl_s = true;\n        } else {\n            tp_trl = null;\n            tp_trl_s = false;\n            \n        } \n        \n        flow.set('tp_trl_s', tp_trl_s);\n\n        if ( sl && tp &&  tp > 0 && tp  < 6 )  {\n            flow.set('sl', sl);\n            sl_s = true;\n        } else {\n            sl = null;\n            sl_s = false;\n            \n        }\n        \n        flow.set('sl_s', sl_s);\n\n        if ( sl_trl &&  sl_trl > 0 && sl_trl < 4 )  {\n            flow.set('sl_trl', sl_trl);\n            sl_trl_s = true;\n        } else {\n            sl_trl = null;\n            sl_trl_s = false;\n            \n        }\n        \n        flow.set('sl_trl_s', sl_trl_s);\n\n        if ( tm && tm > 0 && tm < 4 ) {\n            flow.set('tm', tm)\n            tm_s = true;\n\n        } else {\n            tm = null;\n            tm_s = false;\n            \n        }\n        \n        flow.set('tm_s', tm_s);\n\n    }\n\n    /** \n     * Template literal\n     * `string text ${expression} string text`\n    */\n    \n    if(tp_s) {P = \"${flow.get('tp')} : ${flow.get('tp_trl')}\"}  else {P = \"\"}  \n  \n//    msg.payload = `${flow.get('amt')}  | L  ${flow.get('sl')} : ${flow.get('sl_trl')}  | T  ${flow.get('tm')} | ${flow.get('int', 'file')}`\n \n    msg.payload = `${flow.get('amt')}  | P  ${flow.get('tp')} : ${flow.get('tp_trl')}  | L  ${flow.get('sl')} : ${flow.get('sl_trl')}  | T  ${flow.get('tm')} | ${flow.get('int', 'file')}`\n    msg.color = \"#777777\"\n\n} else if (flow.get('state') === \"A\") {\n    \n     if (sav) {\n\n        if ( amt &&  amt > 0 && amt < 1001 ) {\n            flow.set('amt_a', amt, 'file')\n        } else {\n            amt_a = null\n        }\n\n        if ( tp &&  tp  > 0 && tp  < 16 ) {\n            flow.set('tp_a', tp, 'file'); tp_s_a = true;\n        } else {\n            tp_a = null; tp_s_a = false;\n        }\n\n        if ( tp_trl &&  tp_trl > 0 && tp_trl  < 4 ) {\n            flow.set('tp_trl_a', tp_trl, 'file'); tp_trl_s_a = true;\n        } else {\n            tp_trl_a = null; tp_trl_s_a = false;\n        }\n\n        if ( sl &&  tp &&  tp > 0 && tp < 6 )  {\n            flow.set('sl_a', sl, 'file'); sl_s_a = true;\n        } else {\n            sl_a = null; sl_s_a = false;\n        }\n\n        if ( sl_trl && sl_trl > 0 && sl_trl < 4 )  {\n            flow.set('sl_trl_a', sl_trl, 'file');sl_trl_s_a = true;\n        } else {\n            sl_trl_a = null; sl_trl_s_a = false;\n        }\n\n        if ( tm &&  tm > 0 && tm < 4 ) {\n            flow.set('tm_a', tm, 'file'); tm_s_a = true;\n        } else {\n            tm_a = null; tm_s_a = false;\n        }\n    }\n\n\n    msg.payload = `${flow.get('amt_a', 'file')} | P  ${flow.get('tp_a', 'file')} : ${flow.get('tp_trl_a', 'file')} | L  ${flow.get('sl_a', 'file')} : ${flow.get('sl_trl_a', 'file')}  | T  ${flow.get('tm_a', 'file')} | ${flow.get('int', 'file')}`\n    msg.color = \"#fdef55\"\n\n}\n\n\nif (clear === true) { \n    msg.payload = \"\"\n\n}\n\nreturn msg\n\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 610,
        "y": 320,
        "wires": [
            [
                "f903c2f4d4527ee8",
                "4e27bb63f1d3ea3a"
            ]
        ]
    },
    {
        "id": "f4d4d7072bb2377d",
        "type": "inject",
        "z": "d024f151657a2969",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{}",
        "payloadType": "json",
        "x": 430,
        "y": 500,
        "wires": [
            [
                "db3e88daa902a03f"
            ]
        ]
    },
    {
        "id": "db3e88daa902a03f",
        "type": "change",
        "z": "d024f151657a2969",
        "name": "sw def",
        "rules": [
            {
                "t": "set",
                "p": "color",
                "pt": "msg",
                "to": "Red",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.state",
                "pt": "msg",
                "to": "A",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 610,
        "y": 420,
        "wires": [
            [
                "feecddf765a73ad3"
            ]
        ]
    },
    {
        "id": "f903c2f4d4527ee8",
        "type": "ui_text",
        "z": "d024f151657a2969",
        "group": "01243dae5db25fd5",
        "order": 1,
        "width": 8,
        "height": 1,
        "name": "values",
        "label": "",
        "format": "<font color= {{msg.color}} > {{msg.payload}} </font>",
        "layout": "row-spread",
        "className": "values",
        "x": 770,
        "y": 360,
        "wires": []
    },
    {
        "id": "feecddf765a73ad3",
        "type": "ui_multistate_switch",
        "z": "d024f151657a2969",
        "name": "mode",
        "group": "01243dae5db25fd5",
        "order": 2,
        "width": 3,
        "height": 1,
        "label": "",
        "stateField": "payload.state",
        "enableField": "enable",
        "passthroughField": "passthrough",
        "inputMsgField": "inputmsg",
        "rounded": true,
        "useThemeColors": false,
        "hideSelectedLabel": false,
        "multilineLabel": false,
        "passThrough": "always",
        "inputMsg": "all",
        "userInput": "enabled_show",
        "options": [
            {
                "label": "&nbsp;",
                "value": "d",
                "valueType": "str",
                "color": "#1e2223"
            },
            {
                "label": "&nbsp;",
                "value": "y",
                "valueType": "str",
                "color": "#1e2223"
            },
            {
                "label": "<i class=\"fa fa-cloud-upload\"></i>",
                "value": "M",
                "valueType": "str",
                "color": "#ff0000"
            },
            {
                "label": "<i class=\"fa fa-database\"></i>",
                "value": "A",
                "valueType": "str",
                "color": "#0042ad"
            }
        ],
        "topic": "mode",
        "x": 610,
        "y": 360,
        "wires": [
            [
                "54d76d4680fef5b0",
                "f425f63c447edd93"
            ]
        ]
    },
    {
        "id": "93bdc533213daa9c",
        "type": "inject",
        "z": "d024f151657a2969",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{}",
        "payloadType": "json",
        "x": 110,
        "y": 300,
        "wires": [
            [
                "8adb65042e91f44c",
                "acc45ad8c52f5d73"
            ]
        ]
    },
    {
        "id": "5c67705336061196",
        "type": "debug",
        "z": "d024f151657a2969",
        "name": "debug 9",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 580,
        "y": 160,
        "wires": []
    },
    {
        "id": "3127b608ed979b4a",
        "type": "debug",
        "z": "d024f151657a2969",
        "name": "debug 10",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 880,
        "y": 220,
        "wires": []
    },
    {
        "id": "4e27bb63f1d3ea3a",
        "type": "debug",
        "z": "d024f151657a2969",
        "name": "debug 11",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 880,
        "y": 320,
        "wires": []
    },
    {
        "id": "f425f63c447edd93",
        "type": "debug",
        "z": "d024f151657a2969",
        "name": "debug 12",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 880,
        "y": 420,
        "wires": []
    },
    {
        "id": "f20b2d9a3fb182a5",
        "type": "ui_spacer",
        "z": "d024f151657a2969",
        "name": "spacer",
        "group": "01243dae5db25fd5",
        "order": 3,
        "width": 5,
        "height": 1
    },
    {
        "id": "4295b5ebed8899c8",
        "type": "ui_spacer",
        "z": "d024f151657a2969",
        "name": "spacer",
        "group": "085d7feec44f7e35",
        "order": 3,
        "width": 5,
        "height": 1
    },
    {
        "id": "01243dae5db25fd5",
        "type": "ui_group",
        "name": "Right",
        "tab": "7e13e6107768d821",
        "order": 2,
        "disp": false,
        "width": "8",
        "collapse": false,
        "className": ""
    },
    {
        "id": "085d7feec44f7e35",
        "type": "ui_group",
        "name": "LEFT",
        "tab": "7e13e6107768d821",
        "order": 3,
        "disp": false,
        "width": 8,
        "collapse": false,
        "className": ""
    },
    {
        "id": "7e13e6107768d821",
        "type": "ui_tab",
        "name": "CRYPTO",
        "icon": "dashboard",
        "order": 2,
        "disabled": false,
        "hidden": false
    }
]

Hi - yes, works great! I can't thank you enough for all your help!

Last piece of the puzzle :slight_smile: As you recall there is another (unused) button

<md-button class="md-button remote-button" ng-click = "regular_plus()"><span style="font-size:12px; color:{{msg.colour}}" class="fa fa-repeat"> </span></md-button></div>  

I was thinking that's what was going to be used to clear the inputs, but checkbox is perfectly fine. I would like to use that button to clear the full set of values, either in memory ("M" mode selected) or in filesystem (for "A" mode).

And a quick question; you're using environmental variables to construct msg.payload for display:

msg.payload = ${flow.get('int', 'file')}

I've been struggle to figure how how to append a regular variable (string) to the message: X = "text to append"

I have started looking at the 'apocalypse' button, also at helping with data entry. Will send it on when it works.

let string = 'abcde'
let anotherString = 'xyz'

string = string + anotherString
//or
msg.payload = 'abc'
msg.payload = msg.payload + 'xyz'

These are not environmental variables they are an expression in a template literal. (a good explanation is here Template literals (Template strings) - JavaScript | MDN (mozilla.org))

Given an example of the 'apocalypse' button, on the form is now a clear_form action, max & min values to entries (where available), all entries are formatted as numbers. See notes for other changes. They should give you some ideas which I hope will allow you to get the flow you want.

[
    {
        "id": "9f615412d7859c89",
        "type": "inject",
        "z": "8610e6e475a61e1f",
        "name": "Manual Default Set",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{}",
        "payloadType": "json",
        "x": 190,
        "y": 220,
        "wires": [
            [
                "2c1d673a29c60bbe",
                "f7bfb0834b720f9c"
            ]
        ]
    },
    {
        "id": "2c1d673a29c60bbe",
        "type": "change",
        "z": "8610e6e475a61e1f",
        "name": "Form Defaults",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{}",
                "tot": "json"
            },
            {
                "t": "set",
                "p": "payload.amt",
                "pt": "msg",
                "to": "20",
                "tot": "num"
            },
            {
                "t": "set",
                "p": "payload.tp",
                "pt": "msg",
                "to": "5",
                "tot": "num"
            },
            {
                "t": "set",
                "p": "payload.tp_trl",
                "pt": "msg",
                "to": "3",
                "tot": "num"
            },
            {
                "t": "set",
                "p": "payload.sl",
                "pt": "msg",
                "to": "3",
                "tot": "num"
            },
            {
                "t": "set",
                "p": "payload.sl_trl",
                "pt": "msg",
                "to": "2",
                "tot": "num"
            },
            {
                "t": "set",
                "p": "payload.tm",
                "pt": "msg",
                "to": "1",
                "tot": "num"
            },
            {
                "t": "set",
                "p": "payload.save",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.clear",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 460,
        "y": 160,
        "wires": [
            [
                "59d336951086907b",
                "dee41d1431259abf"
            ]
        ]
    },
    {
        "id": "59d336951086907b",
        "type": "debug",
        "z": "8610e6e475a61e1f",
        "name": "debug 13",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 640,
        "y": 100,
        "wires": []
    },
    {
        "id": "18af028145d733b7",
        "type": "function",
        "z": "8610e6e475a61e1f",
        "name": "Save Data",
        "func": "/**\n * Explaination\n * Deconstruct the payload Object into local variables\n * \n * If you want to provide default values\n * const {save = false, clear = false, state = ''} = msg.payload\n */\n\nlet data = flow.get('data') || {amt: 0, tp: 0, tp_trl: 0, sl: 0, sl_trl: 0, tm: 0,}\nlet dataFile = flow.get('dataFile') || {amt_a: 0, tp_a: 0, tp_trl_a: 0, sl_a: 0, sl_trl_a: 0, tm_a: 0};\n\n/**\n * One method of getting values from msg.payload into data. Deconstruction\n *\n *  ({amt: data.amt, tp: data.tp, tp_trl: data.tp_trl, sl: data.sl, sl_trl: data.sl_trl, tm: data.tm} = msg.payload)\n*/\n\n// Second method of getting values from msg.payload into data.\nfor (const property of Object.keys(data)) {\n    if (msg.payload.hasOwnProperty(property)) {    \n        data[property] = msg.payload[property]\n                            \n    }\n\n}\n\n// Use deconstruction to get values from msg.payload if available. Default values used otherwise.\nconst {save = false, clear = false, state = ''} = msg.payload\n\nlet tp_s, sl_s, tp_s_a, sl_s_a, tp_trl_s, tp_trl_s_a, sl_trl_s, sl_trl_s_a, tm_s, tm_s_a, P, L, P_a, L_a, T, T_a\n\nlet topic = msg.topic\n\n// Apocalypse, delete all saved memory data. Can also delete file data if required.\nif (topic === 'apocalypse' && msg.payload === 'delete') {\n    data = {}\n\n    flow.set('data', data)\n\n    node.warn('Deleting Data')\n\n    return\n    \n}\n\nif (topic === \"mode\") {\n    flow.set('state', state)\n\n}\n\nif (flow.get('state') === \"M\") {\n\n    // If SET Button pressed\n    if (save) {\n\n        /**\n         * Explaination\n         * if ( some_variable ) {\n         *      we don't get here if some_variable is null, undefined, 0, NaN, false, or \"\"\n         *  }\n         * \n         * \n         */\n        if ( data.amt && data.amt > 19 && data.amt < 1001 ) {\n            flow.set('data.amt', data.amt)\n        } else {\n            data.amt = null\n        } \n\n        if ( data.tp && data.tp > 0 && data.tp < 16 ) {\n            flow.set('data.tp', data.tp);\n            tp_s = true;\n        } else {\n             data.tp = null;\n             tp_s = false;\n\n        }\n        \n        flow.set('tp_s', tp_s);\n\n        if ( data.tp_trl && data.tp_trl > 0 && data.tp_trl < 4 ) {\n            flow.set('data.tp_trl', data.tp_trl);\n            tp_trl_s = true;\n        } else {\n            data.tp_trl = null;\n            tp_trl_s = false;\n            \n        } \n        \n        flow.set('tp_trl_s', tp_trl_s);\n\n        if ( data.sl && data.tp && data.tp > 0 && data.tp < 6 )  {\n            flow.set('data.sl', data.sl);\n            sl_s = true;\n        } else {\n            data.sl = null;\n            sl_s = false;\n            \n        }\n        \n        flow.set('sl_s', sl_s);\n\n        if ( data.sl_trl && data.sl_trl > 0 && data.sl_trl < 4 )  {\n            flow.set('data.sl_trl', data.sl_trl);\n            sl_trl_s = true;\n        } else {\n            data.sl_trl = null;\n            sl_trl_s = false;\n            \n        }\n        \n        flow.set('sl_trl_s', sl_trl_s);\n\n        if ( data.tm && data.tm > 0 && data.tm < 4 ) {\n            flow.set('data.tm', data.tm)\n            tm_s = true;\n\n        } else {\n            data.tm = null;\n            tm_s = false;\n            \n        }\n        \n        flow.set('tm_s', tm_s);\n\n    }\n\n    /** \n     * Template literal\n     * `string text ${expression} string text`\n    */\n    \n    if(tp_s) {P = `${flow.get('data.tp')} : ${flow.get('data.tp_trl')}`}  else {P = \"\"}  \n  \n//    msg.payload = `${flow.get('amt')}  | L  ${flow.get('sl')} : ${flow.get('sl_trl')}  | T  ${flow.get('tm')} | ${flow.get('int', 'file')}`\n \n    msg.payload = `${flow.get('data.amt')}  | P  ${flow.get('data.tp')} : ${flow.get('data.tp_trl')}  | L  ${flow.get('data.sl')} : ${flow.get('data.sl_trl')}  | T  ${flow.get('data.tm')} | ${flow.get('int', 'file')}`\n    msg.color = \"#777777\"\n\n} else if (flow.get('state') === \"A\") {\n    \n     if (save) {\n\n        if ( data.amt && data.amt > 0 && data.amt < 1001 ) {\n            flow.set('dataFile.amt_a', data.amt, 'file')\n        } else {\n           dataFile.amt_a= null\n        }\n\n        if ( data.tp &&  data.tp  > 0 && data.tp < 16 ) {\n            flow.set('dataFile.tp_a', data.tp, 'file'); \n            tp_s_a = true;\n        } else {\n            dataFile.tp_a = null; \n            tp_s_a = false;\n        }\n\n        if ( data.tp_trl &&  data.tp_trl > 0 && data.tp_trl  < 4 ) {\n            flow.set('dataFile.tp_trl_a', data.tp_trl, 'file'); \n            tp_trl_s_a = true;\n        } else {\n            dataFile.tp_trl_a = null; \n            tp_trl_s_a = false;\n        }\n\n        if ( data.sl && data.tp && data.tp > 0 && data.tp < 6 )  {\n            flow.set('dataFile.sl_a', data.sl, 'file'); \n            sl_s_a = true;\n        } else {\n            dataFile.sl_a = null; \n            sl_s_a = false;\n        }\n\n        if ( data.sl_trl && data.sl_trl > 0 && data.sl_trl < 4 )  {\n            flow.set('dataFile.sl_trl_a', data.sl_trl, 'file');\n            sl_trl_s_a = true;\n        } else {\n            dataFile.sl_trl_a = null; \n            sl_trl_s_a = false;\n        }\n\n        if ( data.tm && data.tm > 0 && data.tm < 4 ) {\n            flow.set('dataFile.tm_a', data.tm, 'file'); \n            tm_s_a = true;\n        } else {\n            dataFile.tm_a = null; \n            tm_s_a = false;\n        }\n    }\n\n    msg.payload = `${flow.get('dataFile.amt_a', 'file')} | P  ${flow.get('dataFile.tp_a', 'file')} : ${flow.get('dataFile.tp_trl_a', 'file')} | L  ${flow.get('dataFile.sl_a', 'file')} : ${flow.get('dataFile.sl_trl_a', 'file')}  | T  ${flow.get('dataFile.tm_a', 'file')} | ${flow.get('int', 'file')}`\n    msg.color = \"#fdef55\"\n\n}\n\nif (clear === true) { \n    msg.payload = \"\"\n\n}\n\nreturn msg",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 650,
        "y": 220,
        "wires": [
            [
                "31b56205a3d66551",
                "cee453b3cb713995"
            ]
        ]
    },
    {
        "id": "c66936589a1fe5af",
        "type": "debug",
        "z": "8610e6e475a61e1f",
        "name": "debug 14",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 920,
        "y": 160,
        "wires": []
    },
    {
        "id": "cee453b3cb713995",
        "type": "debug",
        "z": "8610e6e475a61e1f",
        "name": "debug 15",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 920,
        "y": 200,
        "wires": []
    },
    {
        "id": "31b56205a3d66551",
        "type": "ui_text",
        "z": "8610e6e475a61e1f",
        "group": "8d6786088b616e59",
        "order": 1,
        "width": 8,
        "height": 1,
        "name": "values",
        "label": "",
        "format": "<font color= {{msg.color}} > {{msg.payload}} </font>",
        "layout": "row-spread",
        "className": "values",
        "x": 910,
        "y": 240,
        "wires": []
    },
    {
        "id": "797b4f7ffa53f5cb",
        "type": "ui_multistate_switch",
        "z": "8610e6e475a61e1f",
        "name": "mode",
        "group": "8d6786088b616e59",
        "order": 2,
        "width": 3,
        "height": 1,
        "label": "",
        "stateField": "payload.state",
        "enableField": "enable",
        "passthroughField": "passthrough",
        "inputMsgField": "inputmsg",
        "rounded": true,
        "useThemeColors": false,
        "hideSelectedLabel": false,
        "multilineLabel": false,
        "passThrough": "always",
        "inputMsg": "all",
        "userInput": "enabled_show",
        "options": [
            {
                "label": "&nbsp;",
                "value": "d",
                "valueType": "str",
                "color": "#1e2223"
            },
            {
                "label": "&nbsp;",
                "value": "y",
                "valueType": "str",
                "color": "#1e2223"
            },
            {
                "label": "<i class=\"fa fa-cloud-upload\"></i>",
                "value": "M",
                "valueType": "str",
                "color": "#ff0000"
            },
            {
                "label": "<i class=\"fa fa-database\"></i>",
                "value": "A",
                "valueType": "str",
                "color": "#0042ad"
            }
        ],
        "topic": "mode",
        "x": 630,
        "y": 280,
        "wires": [
            [
                "18af028145d733b7",
                "5af3a60c282cfdd7"
            ]
        ]
    },
    {
        "id": "f7bfb0834b720f9c",
        "type": "change",
        "z": "8610e6e475a61e1f",
        "name": "Mode Defaults",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{}",
                "tot": "json"
            },
            {
                "t": "set",
                "p": "color",
                "pt": "msg",
                "to": "Red",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.state",
                "pt": "msg",
                "to": "A",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 460,
        "y": 280,
        "wires": [
            [
                "797b4f7ffa53f5cb"
            ]
        ]
    },
    {
        "id": "5af3a60c282cfdd7",
        "type": "debug",
        "z": "8610e6e475a61e1f",
        "name": "debug 16",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 920,
        "y": 280,
        "wires": []
    },
    {
        "id": "dee41d1431259abf",
        "type": "ui_template",
        "z": "8610e6e475a61e1f",
        "group": "8d6786088b616e59",
        "name": "Input Form",
        "order": 3,
        "width": 0,
        "height": 0,
        "format": "<!-- added style to align icons under checkboxes -->\n<style>\n       md-checkbox .md-label {\n              margin-left: 5px;\n              margin-top: 14px;\n\n       }\n       \n</style>\n<form name=\"myForm\">\n<div style = \"padding: 5px 5px 0px 5px\" >\n       <div flex = \"\" layout = \"row\">\n\n              <!-- ng-focus = \"clear_entry('..')\" tp all inputs. Clears default entry when focused. Also added max and min, check values \n                   set input type to 'number'\n              -->\n              <div flex = \"22\" style = \"padding:0 5px\">    \n                     <div style = \"text-align:center\"><md-input-container><input type = \"number\" ng-model = \"tp\"  ng-focus = \"clear_entry('tp')\" min = \"{{minValue.tp}}\" max = \"{{maxValue.tp}}\" aria-label = \"tp\"><span class = mylabel>TP</span></md-input-container></div> \n              </div>\n\n              <div flex = \"20\" style = \"padding:0 5px\">    \n                     <div style = \"text-align:center\"><md-input-container><input type = \"number\" ng-model = \"tp_trl\" ng-focus = \"clear_entry('tp_trl')\" min = \"{{minValue.tp_trl}}\" max = \"{{maxValue.tp_trl}}\" aria-label = \"tp_trl\"><span class = mylabel>P🡅</span></md-input-container></div>\n              </div>\n\n              <div flex = \"20\" style = \"padding:0 5px\">    \n                     <div style = \"text-align:center\"><md-input-container><input type = \"number\" ng-model = \"sl\" ng-focus = \"clear_entry('sl')\" aria-label = \"sl\"><span class = mylabel>SL</span></md-input-container></div>\n              </div>\n\n              <div flex = \"20\" style = \"padding:0 5px\">    \n                     <div style = \"text-align:center\"><md-input-container><input type = \"number\" ng-model = \"sl_trl\" ng-focus = \"clear_entry('sl_trl')\" min = \"{{minValue.sl_trl}}\" max = \"{{maxValue.sl_trl}}\" aria-label = \"sl_trl\"><span class = mylabel>L🡅</span></md-input-container></div> \n              </div>\n \n              <div flex = \"18\" style = \"padding:0 5px\">\n                     <div style = \"text-align:center\"><md-input-container><input type = \"number\" ng-model = \"tm\" ng-focus = \"clear_entry('tm')\" min = \"{{minValue.tm}}\" max = \"{{maxValue.tm}}\" aria-label = \"tm\"><span class = mylabel>TM</span></md-input-container></div>        \n              </div>\n       </div>\n\n       <div flex = \"\" style = \"margin: 5px 5px 0px 5px\" layout = \"row\">\n    \n              <div flex = \"40\" layout = \"column\"> \n                     <div style = \"margin-top:25px\" flex = \"\" layout = \"row\">\n                            <div style = \"margin-left:5px\"><md-checkbox ng-model = \"save\" aria-label = \"save\"><i class = \"fa fa-unlock-alt\" aria-hidden = \"true\"></i></md-checkbox></div>  \n                            <!-- added ng-change = \"clear_form()\", color:{{msg.colour}} not used so removed. -->\n                            <div style = \"margin-left:10px\"><md-checkbox ng-model = \"clear\" ng-change = \"clear_form()\" aria-label = \"clear\"><i class = \"fa fa-circle-o\" aria-hidden = \"true\"></i></md-checkbox></div>\n                     </div> \n\n              </div>\n       \n              <div flex = \"40\" layout = \"column\">\n                     <div flex = \"\" layout = \"row\">\n                            <div style = \"margin:0px 0px 0px 22px; text-align:center\"><md-input-container><input type = \"number\" ng-focus = \"clear_entry('amt')\" ng-model = \"amt\" min = \"{{maxValue.amt}}\"  max = \"{{maxValue.amt}}\" aria-label = \"amt\" ><span class=mylabel>Amt</span></md-input-container></div>\n                     </div>\n              </div>\n       </div>\n     \n       <div flex = \"\" style = \"margin: 5px 5px 0px 5px\" layout = \"row\">\n              <div flex = \"40\" layout = \"column\"> \n                     <!-- changed tm:tml to tm:tm as could not find tml, changed aut to sav. Added ng-click = \"clear_memory()\" -->\n                     <div style = \"margin: -2px 0px 0px -10px\"><md-button class = \"md-accent md-hue-2 md-raised\" style = \"font-size: 1.6em\" ng-click = \"clear_memory()\" aria-label = \"clear memory\"> <i style = \"margin-bottom: 5px\" class=\"fa fa-refresh\" aria-hidden=\"true\"> </i></md-button></div>  \n              </div>\n       \n              <div flex = \"40\" layout = \"column\">       \n                     <div style = \"margin:-2px 0px 0px 0px\"><md-button class = \"md-accent md-hue-2 md-raised\" ng-click = \"send({topic: 'set', payload:{save: save, amt: amt, sl_trl: sl_trl, sl: sl, tp: tp, tp_trl: tp_trl, tm: tm}})\" aria-label = \"set\" >SET</md-button></div>\n              </div>\n\n       </div>\n\n</div>\n\n</form>\n<script>\n\n(function(scope) {\n\n       // Set local variables. Could also set them to default values\n       let local = {amt: 0, sl_trl: 0, sl: 0, tp: 0, tp_trl: 0, tm: 0}\n\n       // Copy local variables to 'scope' used in the form\n       for (const property of Object.keys(local)) {\n              scope[property] = local[property]\n\n       }\n\n       scope.clear = false\n       scope.save = false\n \n       // Set min and max values for data values\n       scope.minValue = {tp: 1, tp_trl: 1, sl_trl: 1, tm: 1, amt: 20}\n       scope.maxValue = {tp: 15, tp_trl: 3, sl_trl: 3, tm: 3, amt: 1000}\n\n       // Clear form\n       scope.clear_form = function() {\n              if (scope.clear === true) {\n                     for (const property of Object.keys(local)) {\n                            local[property] = 0\n\n                     }\n\n                     showChange()\n\n              }\n\n       }\n\n       // Clear input when receives focus\n       scope.clear_entry = function(e) {\n              scope[e] = ''\n\n       }\n  \n       scope.clear_memory = function() {\n              scope.send({topic: 'apocalypse', payload: 'delete'})\n\n       }\n\n       scope.$watch('msg', function(msg) {\n              // No error checking for properties\n              if(msg) {\n                     for (const property of Object.keys(local)) {\n                            if (Object.hasOwn(msg.payload, property)) {\n                                   local[property] = msg.payload[property]\n                            \n                            }\n\n                     }\n                     scope.clear = msg.payload.clear\n\n                     // Set to false so any incoming msg does not action following function\n                     msg.payload.save = false                 \n\n                     showChange()\n\n                     scope.send(msg)\n              }\n\n       })\n    \n       // Update the scope variables to reflect back to the HTML\n       function showChange() {\n              for (const property of Object.keys(local)) {\n                     scope[property] = local[property]\n\n              }\n                            \n       }\n \n\n})(scope);\n</script>",
        "storeOutMessages": false,
        "fwdInMessages": false,
        "resendOnRefresh": false,
        "templateScope": "local",
        "className": "setbox",
        "x": 650,
        "y": 160,
        "wires": [
            [
                "c66936589a1fe5af",
                "18af028145d733b7"
            ]
        ]
    },
    {
        "id": "81b1770db31a868f",
        "type": "ui_ui_control",
        "z": "8610e6e475a61e1f",
        "name": "Default of Tab Change",
        "events": "all",
        "x": 180,
        "y": 160,
        "wires": [
            [
                "f7bfb0834b720f9c",
                "2c1d673a29c60bbe"
            ]
        ]
    },
    {
        "id": "8d6786088b616e59",
        "type": "ui_group",
        "name": "Testing",
        "tab": "7e13e6107768d821",
        "order": 3,
        "disp": false,
        "width": "8",
        "collapse": false,
        "className": ""
    },
    {
        "id": "7e13e6107768d821",
        "type": "ui_tab",
        "name": "CRYPTO",
        "icon": "dashboard",
        "order": 2,
        "disabled": false,
        "hidden": false
    }
]

Hi, thanks - trying to add the updates in, running into issues.
What is the 'apocalypse' button function?
What is the benefit of the new form config - all of the input clearing was working well.
Is this method advantageous?

/ Second method of getting values from msg.payload into data.
for (const property of Object.keys(data)) {
if (msg.payload.hasOwnProperty(property)) {
data[property] = msg.payload[property]

}

The number formatting is problematic (I tried that before) - the browser is inserting a selector in the input box, etc. Trying to remember how to remove that.

Unfortunately not having much luck incorporating the updates, it's breaking. My input config had changed. I had an additional input form and it made sense to merge the two. I also had three different functions handling similar type of requests so made sense to combine those as well. I really appreciate all the time you're spending on this; would be grateful i if you could do one more pass on the latest config.

Here is where I am stuck:

  1. The clearing of inputs was working great - I noticed a different (form) approach in the last update? I was trying to move the clearing function from the checkbox to the button below (more intuitive) but simply assigning ng-click="clear_form()" didn't do the trick. If the 'apocalypse' is clearing of the memory then I it would better to have two-step action like selecting the checkbox to the right of the lock and clicking SET.

  2. You had the clear function assigned to a checkbox - I didn't know that was possible, it seemed equivalent to a button? I was trying to do the same with the with the checkboxes on the left (15, 30, 1h, 2h), assign a function (same one to each: ng-change = "tdv()") which on any change would send a payload with the state of those 4 checkboxes.

  3. Finally in the new combined function (it's disconnected in the flow) it became confusing how to grab ( the two button sends (LOAD is sending radio buttons, text field, and checkboxes if they can't be made independent with their own action) and properly separate the various requests - using "topic" seemed to work, although something was wrong with the LOAD button topic, just couldn't recognize it.

LATEST FLOW

[
    {
        "id": "b59048cad1b35242",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "deea13a755f78771",
        "type": "change",
        "z": "b59048cad1b35242",
        "name": "defaults",
        "rules": [
            {
                "t": "set",
                "p": "payload.currency",
                "pt": "msg",
                "to": "GALA",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.exchange",
                "pt": "msg",
                "to": "Gate.io",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.flag",
                "pt": "msg",
                "to": "reset",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "time",
                "pt": "msg",
                "to": "",
                "tot": "date"
            },
            {
                "t": "set",
                "p": "payload.change",
                "pt": "msg",
                "to": "",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.window",
                "pt": "msg",
                "to": "",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.note",
                "pt": "msg",
                "to": "",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "reset",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 670,
        "y": 420,
        "wires": [
            [
                "285ef3655aecaf41"
            ]
        ]
    },
    {
        "id": "873e956a1914c95e",
        "type": "change",
        "z": "b59048cad1b35242",
        "name": "values",
        "rules": [
            {
                "t": "set",
                "p": "payload.amt",
                "pt": "msg",
                "to": "20",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.tp",
                "pt": "msg",
                "to": "5",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.tp_trl",
                "pt": "msg",
                "to": "3",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.sl",
                "pt": "msg",
                "to": "3",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.sl_trl",
                "pt": "msg",
                "to": "2",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.tm",
                "pt": "msg",
                "to": "1",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.sav",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.clear",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.state",
                "pt": "msg",
                "to": "M",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 670,
        "y": 380,
        "wires": [
            [
                "250df4ed18e9e93b"
            ]
        ]
    },
    {
        "id": "285ef3655aecaf41",
        "type": "link out",
        "z": "b59048cad1b35242",
        "name": "link out 34",
        "mode": "link",
        "links": [
            "d1da4326b4ca3757"
        ],
        "x": 675,
        "y": 460,
        "wires": []
    },
    {
        "id": "59c6445aaa27cd0b",
        "type": "link in",
        "z": "b59048cad1b35242",
        "name": "link in 10",
        "links": [],
        "x": 585,
        "y": 400,
        "wires": [
            [
                "873e956a1914c95e",
                "deea13a755f78771"
            ]
        ]
    },
    {
        "id": "13b6034ca4b31a85",
        "type": "function",
        "z": "b59048cad1b35242",
        "name": "set",
        "func": "/**\n * Explaination\n * Deconstruct the payload Object into local variables\n * \n * If you want to provide default values\n * let {state = true, amt = 1, tp, tp_trl, sl, sl_trl, tm, sav} = msg.payload\n */\n\nlet {state, amt, tp, tp_trl, sl, sl_trl, tm, sav, clear = false} = msg.payload\nlet amt_a, tp_a, tp_trl_a, sl_a, sl_trl_a, tm_a, tp_s, sl_s, tp_s_a, sl_s_a, tp_trl_s, tp_trl_s_a, sl_trl_s, sl_trl_s_a, tm_s, tm_s_a, P, L, P_a, L_a, T, T_a\n\nlet topic = msg.topic\n\nif (msg.topic === \"mode\") {\n    flow.set('state', state);\n}\n\nif (flow.get('state') === \"M\") {\n\n    // If SET Button pressed\n    if (sav) {\n\n        /**\n         * Explaination\n         * if ( some_variable ) {\n         *      we don't get here if some_variable is null, undefined, 0, NaN, false, or \"\"\n         *  }\n         * \n         * \n         */\n        if ( amt && amt > 19 && amt < 1001 ) {\n            flow.set('amt', amt)\n        } else {\n            amt = null\n        } \n\n        if ( tp && tp > 0 && tp < 16 ) {\n            flow.set('tp', tp);\n            tp_s = true;\n        } else {\n             tp = null;\n             tp_s = false;\n             \n        }\n        \n        flow.set('tp_s', tp_s);\n\n        if ( tp_trl && tp_trl > 0 && tp_trl < 4 ) {\n            flow.set('tp_trl', tp_trl);\n            tp_trl_s = true;\n        } else {\n            tp_trl = null;\n            tp_trl_s = false;\n            \n        } \n        \n        flow.set('tp_trl_s', tp_trl_s);\n\n        if ( sl && tp &&  tp > 0 && tp  < 6 )  {\n            flow.set('sl', sl);\n            sl_s = true;\n        } else {\n            sl = null;\n            sl_s = false;\n            \n        }\n        \n        flow.set('sl_s', sl_s);\n\n        if ( sl_trl &&  sl_trl > 0 && sl_trl < 4 )  {\n            flow.set('sl_trl', sl_trl);\n            sl_trl_s = true;\n        } else {\n            sl_trl = null;\n            sl_trl_s = false;\n            \n        }\n        \n        flow.set('sl_trl_s', sl_trl_s);\n\n        if ( tm && tm > 0 && tm < 4 ) {\n            flow.set('tm', tm)\n            tm_s = true;\n\n        } else {\n            tm = null;\n            tm_s = false;\n            \n        }\n        \n        flow.set('tm_s', tm_s);\n\n    }\n\n    /** \n     * Template literal\n     * `string text ${expression} string text`\n    */\n    \n    if(tp_s) {P = \"${flow.get('tp')} : ${flow.get('tp_trl')}\"}  else {P = \"\"}  \n  \n//    msg.payload = `${flow.get('amt')}  | L:  ${flow.get('sl')} : ${flow.get('sl_trl')}  | T  ${flow.get('tm')} | ${flow.get('int', 'file')}`\n \n    msg.payload = `${flow.get('amt')}  | P:  ${flow.get('tp')} : ${flow.get('tp_trl')}  | L:  ${flow.get('sl')} : ${flow.get('sl_trl')}  | T:  ${flow.get('tm')} | ${flow.get('int', 'file')}`\n    msg.color = \"#777777\"\n\n} else if (flow.get('state') === \"A\") {\n    \n     if (sav) {\n\n        if ( amt &&  amt > 0 && amt < 1001 ) {\n            flow.set('amt_a', amt, 'file')\n        } else {\n            amt_a = null\n        }\n\n        if ( tp &&  tp  > 0 && tp  < 16 ) {\n            flow.set('tp_a', tp, 'file'); tp_s_a = true;\n        } else {\n            tp_a = null; tp_s_a = false;\n        }\n\n        if ( tp_trl &&  tp_trl > 0 && tp_trl  < 4 ) {\n            flow.set('tp_trl_a', tp_trl, 'file'); tp_trl_s_a = true;\n        } else {\n            tp_trl_a = null; tp_trl_s_a = false;\n        }\n\n        if ( sl &&  tp &&  tp > 0 && tp < 6 )  {\n            flow.set('sl_a', sl, 'file'); sl_s_a = true;\n        } else {\n            sl_a = null; sl_s_a = false;\n        }\n\n        if ( sl_trl && sl_trl > 0 && sl_trl < 4 )  {\n            flow.set('sl_trl_a', sl_trl, 'file');sl_trl_s_a = true;\n        } else {\n            sl_trl_a = null; sl_trl_s_a = false;\n        }\n\n        if ( tm &&  tm > 0 && tm < 4 ) {\n            flow.set('tm_a', tm, 'file'); tm_s_a = true;\n        } else {\n            tm_a = null; tm_s_a = false;\n        }\n    }\n\n\n    msg.payload = `${flow.get('amt_a', 'file')} | P:  ${flow.get('tp_a', 'file')} : ${flow.get('tp_trl_a', 'file')} | L:  ${flow.get('sl_a', 'file')} : ${flow.get('sl_trl_a', 'file')}  | T:  ${flow.get('tm_a', 'file')} | ${flow.get('int', 'file')}`\n    msg.color = \"#fdef55\"\n\n}\n\n\nif (clear === true) { \n    msg.payload = \"\"\n\n}\n\nreturn msg\n\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 870,
        "y": 360,
        "wires": [
            [
                "0d78d5374d6fa4b1"
            ]
        ]
    },
    {
        "id": "0d78d5374d6fa4b1",
        "type": "ui_text",
        "z": "b59048cad1b35242",
        "group": "085d7feec44f7e35",
        "order": 4,
        "width": "2",
        "height": "1",
        "name": "values",
        "label": "",
        "format": "<font color= {{msg.color}} > {{msg.payload}} </font>",
        "layout": "row-spread",
        "className": "values",
        "x": 1030,
        "y": 360,
        "wires": []
    },
    {
        "id": "109746c7dd4d0a30",
        "type": "ui_multistate_switch",
        "z": "b59048cad1b35242",
        "name": "mode",
        "group": "085d7feec44f7e35",
        "order": 8,
        "width": "1",
        "height": "1",
        "label": "",
        "stateField": "payload.state",
        "enableField": "enable",
        "passthroughField": "passthrough",
        "inputMsgField": "inputmsg",
        "rounded": true,
        "useThemeColors": false,
        "hideSelectedLabel": false,
        "multilineLabel": false,
        "passThrough": "always",
        "inputMsg": "all",
        "userInput": "enabled_show",
        "options": [
            {
                "label": "&nbsp;",
                "value": "d",
                "valueType": "str",
                "color": "#1e2223"
            },
            {
                "label": "&nbsp;",
                "value": "y",
                "valueType": "str",
                "color": "#1e2223"
            },
            {
                "label": "<i class=\"fa fa-cloud-upload\"></i>",
                "value": "M",
                "valueType": "str",
                "color": "#ff0000"
            },
            {
                "label": "<i class=\"fa fa-database\"></i>",
                "value": "A",
                "valueType": "str",
                "color": "#0042ad"
            }
        ],
        "topic": "mode",
        "x": 870,
        "y": 400,
        "wires": [
            [
                "13b6034ca4b31a85"
            ]
        ]
    },
    {
        "id": "38d13b2d5c8efbed",
        "type": "function",
        "z": "b59048cad1b35242",
        "name": "FUNC",
        "func": "msgCRYPT={}; msgSET = {}; msgTDV = {};\n\nlet topic = msg.topic\n\nlet {state, amt, tp, tp_trl, sl, sl_trl, tm, currency, exchange, coin, exch, m15, m30, h1, h2, sav, clear = false} = msg.payload\n\nlet b_coin, f_coin, g_coin, win\n\nlet amt_a, tp_a, tp_trl_a, sl_a, sl_trl_a, tm_a, tp_s, sl_s, tp_s_a, sl_s_a, tp_trl_s, tp_trl_s_a, sl_trl_s, sl_trl_s_a, tm_s, tm_s_a, P, L, P_a, L_a, T, T_a\n\n\n    if (!m15) {m15 = false} flow.set ('m15', m15)\n    if (!m30) {m30 = false} flow.set ('m30', m30)\n    if (!h1) {h1 = false} flow.set ('h1', h1)\n    if (!h2) {h2 = false} flow.set ('h2', h2)\n    \n\n\n// ALERT \n\nif ((msg.topic === \"alert\") || (msg.topic === \"reset\")) {\n\nlet {currency, exchange, percent, window, note} = msg.payload\nflow.set('currency', currency)\nflow.set('exchange', exchange)\nflow.set('percent', percent)\nflow.set('note', note)\nflow.set('f_coin', currency + '/USD')\nflow.set('g_coin', currency + '_USDT')\nflow.set('b_coin', currency + 'USDT')\n\n\nmsgTDV.payload = currency+\"USDT\"\n\nif (window === \"10 minutes\") {win = \"10m\"} else if (window === \"15 minutes\") {win = \"15m\"} else if (window === \"5 minutes\") {win = \"5m\"} else if (window === \"3 minutes\") {win = \"3m\"} else if (window == \"1 minutes\") {win = \"1m\"}  \nflow.set('win', win)\n\nreturn [msgCRYPT, null, msgTDV]\n\n}  \n// LOAD\n// if (msg.topic === \"load\") {\n\nif (coin) {flow.set('currency', coin.toUpperCase())}\n\nflow.set('exchange', exch)\n\nmsgTDV.payload = `${flow.get('currency')}USDT`\n\nreturn [msgCRYPT, null, msgTDV]\n//}\n\n\n// SCREENER\n\n\nif (msg.topic === \"screener\") {\n\nvar data = msg.payload[0]\n\nreturn [msgCRYPT, null, msgTDV]\n\n// Save incoming object without property 'window'. Note there are many ways to do this\n// example: delete data.window; msg.payload = data\n// msg.payload = {volume: data.volume, exchange: data.exchange}\n\n} \n// SET \n\n\n\nif (msg.topic === \"mode\") {\n    flow.set('state', state);\n}\n\nif (flow.get('state') === \"M\") {\n\n    // If SET Button pressed\n    if (sav) {\n\n        if ( amt && amt > 19 && amt < 1001 ) {\n            flow.set('amt', amt)\n        } else {\n            amt = null\n        } \n\n        if ( tp && tp > 0 && tp < 16 ) {\n            flow.set('tp', tp);\n            tp_s = true;\n        } else {\n             tp = null;\n             tp_s = false;\n             \n        }\n        \n        flow.set('tp_s', tp_s);\n\n        if ( tp_trl && tp_trl > 0 && tp_trl < 4 ) {\n            flow.set('tp_trl', tp_trl);\n            tp_trl_s = true;\n        } else {\n            tp_trl = null;\n            tp_trl_s = false;\n            \n        } \n        \n        flow.set('tp_trl_s', tp_trl_s);\n\n        if ( sl && tp &&  tp > 0 && tp  < 6 )  {\n            flow.set('sl', sl);\n            sl_s = true;\n        } else {\n            sl = null;\n            sl_s = false;\n            \n        }\n        \n        flow.set('sl_s', sl_s);\n\n        if ( sl_trl &&  sl_trl > 0 && sl_trl < 4 )  {\n            flow.set('sl_trl', sl_trl);\n            sl_trl_s = true;\n        } else {\n            sl_trl = null;\n            sl_trl_s = false;\n            \n        }\n        \n        flow.set('sl_trl_s', sl_trl_s);\n\n        if ( tm && tm > 0 && tm < 4 ) {\n            flow.set('tm', tm)\n            tm_s = true;\n\n        } else {\n            tm = null;\n            tm_s = false;\n            \n        }\n        \n        flow.set('tm_s', tm_s);\n\n    }\n\n\n    \n//    if(tp_s) {P = \"${flow.get('tp')} : ${flow.get('tp_trl')}\"}  else {P = \"\"}  \n//    msg.payload = `${flow.get('amt')}  | L:  ${flow.get('sl')} : ${flow.get('sl_trl')}  | T  ${flow.get('tm')} | ${flow.get('int', 'file')}`\n \n    msgSET.payload = `${flow.get('amt')}  | P:  ${flow.get('tp')} : ${flow.get('tp_trl')}  | L:  ${flow.get('sl')} : ${flow.get('sl_trl')}  | T:  ${flow.get('tm')} | ${flow.get('int', 'file')}`\n    msgSET.color = \"#777777\"\n        return [null, msgSET, null]\n\n    \n\n} else if (flow.get('state') === \"A\") {\n    \n     if (sav) {\n\n        if ( amt &&  amt > 0 && amt < 1001 ) {\n            flow.set('amt_a', amt, 'file')\n        } else {\n            amt_a = null\n        }\n\n        if ( tp &&  tp  > 0 && tp  < 16 ) {\n            flow.set('tp_a', tp, 'file'); tp_s_a = true;\n        } else {\n            tp_a = null; tp_s_a = false;\n        }\n\n        if ( tp_trl &&  tp_trl > 0 && tp_trl  < 4 ) {\n            flow.set('tp_trl_a', tp_trl, 'file'); tp_trl_s_a = true;\n        } else {\n            tp_trl_a = null; tp_trl_s_a = false;\n        }\n\n        if ( sl &&  tp &&  tp > 0 && tp < 6 )  {\n            flow.set('sl_a', sl, 'file'); sl_s_a = true;\n        } else {\n            sl_a = null; sl_s_a = false;\n        }\n\n        if ( sl_trl && sl_trl > 0 && sl_trl < 4 )  {\n            flow.set('sl_trl_a', sl_trl, 'file');sl_trl_s_a = true;\n        } else {\n            sl_trl_a = null; sl_trl_s_a = false;\n        }\n\n        if ( tm &&  tm > 0 && tm < 4 ) {\n            flow.set('tm_a', tm, 'file'); tm_s_a = true;\n        } else {\n            tm_a = null; tm_s_a = false;\n        }\n    }\n\n    msgSET.payload = `${flow.get('amt_a', 'file')} | P:  ${flow.get('tp_a', 'file')} : ${flow.get('tp_trl_a', 'file')} | L:  ${flow.get('sl_a', 'file')} : ${flow.get('sl_trl_a', 'file')}  | T:  ${flow.get('tm_a', 'file')} | ${flow.get('int', 'file')}`\n    msgSET.color = \"#fdef55\"\n        return [null, msgSET, null]\n}\n\nif (clear === true) { \n    msgSET.payload = \"\"\n        return [null, msgSET, null]\n}\n\n\n\n\n\n\n\n    /** \n     * Template literal\n     * `string text ${expression} string text`\n    */",
        "outputs": 3,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 870,
        "y": 240,
        "wires": [
            [],
            [],
            []
        ]
    },
    {
        "id": "250df4ed18e9e93b",
        "type": "ui_template",
        "z": "b59048cad1b35242",
        "group": "085d7feec44f7e35",
        "name": "INPUT",
        "order": 10,
        "width": "4",
        "height": 4,
        "format": "\n<div style=\"padding: 5px 5px 0px 0px\" layout=\"row\">\n\n<div flex=\"50\"> \n\n<div style=\"margin-top: 5px\" layout=\"row\">\n   <div style=\"margin-top:25px\" flex=\"30\"> <md-radio-group ng-model=\"exch\" ng-change=\"changeradio()\" ng-init=\"exch='Gate.io'\">\n      <md-radio-button ng-model=\"exch.Paper\" value=\"Paper\" class=\"md-primary\">P</md-radio-button>\n      <md-radio-button ng-model=\"exch.Binance\" value=\"Binance\" class=\"md-primary\">B</md-radio-button>\n      <md-radio-button ng-model=\"exch.FTX\" value=\"FTX\">F</md-radio-button>\n      <md-radio-button ng-model=\"Gate.io\" data-ng-checked=\"true\" value=\"Gate.io\">G</md-radio-button></md-radio-group> \n   </div>\n \n  <div layout=\"column\" style=\"margin: 10px 0px 0px 0px\" flex=\"55\">\n      <div style=\"margin-left:-10px\" flex=\"\" layout=\"row\">\n         <div style=\"margin-left:0px\"><md-checkbox ng-model=\"m15\" ng-change = \"tdv()\" aria-label=\"m15\"><span style=\"font-size:11px\">15</span></md-checkbox></div>\n         <div style=\"margin-left:7px\"><md-checkbox ng-model=\"m30\" ng-change = \"tdv()\" aria-label=\"m30\"><span style=\"font-size:11px\">30</span></md-checkbox></div>\n         <div style=\"margin-left:7px\"><md-checkbox ng-model=\"h1\" ng-change = \"tdv()\" aria-label=\"h1\"><span style=\"font-size:11px\">1h</span></md-checkbox></div>  \n         <div style=\"margin-left:7px\"><md-checkbox ng-model=\"h2\" ng-change = \"tdv()\" aria-label=\"h2\"><span style=\"font-size:11px\">2h</span></md-checkbox></div>\n      </div> \n    <div flex=\"\" style =\"text-align:center; margin-top:-7px; margin-left:40px;\"><md-input-container><input aria-label=\"coin\" ng-model=\"coin\"></md-input-container></div>\n    <div flex=\"\" style =\"margin-top:0px; margin-left:35px; \"><md-button aria-label=\"load\" class=\"md-accent md-hue-2 md-raised\" ng-click=\"send({topic:load, payload:{exch:exch, coin:coin, m15:m15, m30:m30, h1:h1, h2:h2}})\">LOAD</md-button></div>\n  </div>\n</div>\n</div>\n\n<div flex=\"50\" style=\"border-left:1px solid #434651; padding-left:10px\"> \n<div flex=\"\" layout=\"row\">\n     <div flex=\"22\" style=\"padding:0 5px\">    \n       <div style=\"text-align:center\"><md-input-container><input ng-model=\"tp\" aria-label=\"tp\"><span class=mylabel>TP</span></md-input-container></div> \n     </div>\n\n     <div flex=\"20\" style=\"padding:0 5px\">    \n       <div style=\"text-align:center\"><md-input-container><input ng-model=\"tp_trl\" aria-label=\"tp_trl\"><span class=mylabel>P🡅</span></md-input-container></div> \n     </div>\n\n     <div flex=\"20\" style=\"padding:0 5px\">    \n      <div style=\"text-align:center\"><md-input-container><input ng-model=\"sl\" aria-label=\"sl\"><span class=mylabel>SL</span></md-input-container></div>\n    </div>\n\n     <div flex=\"20\" style=\"padding:0 5px\">    \n    <div style=\"text-align:center\"><md-input-container><input aria-label=\"sl_trl\" ng-model=\"sl_trl\"><span class=mylabel>L🡅</span></md-input-container></div> \n    </div>\n \n    <div flex=\"18\" style=\"padding:0 5px\">\n    <div style=\"text-align:center\"><md-input-container><input aria-label=\"tm\" ng-model=\"tm\"><span class=mylabel>TM</span></md-input-container></div>        \n    </div>\n</div>\n\n<div flex=\"\" style=\"margin: 5px 5px 0px 5px\" layout=\"row\">\n    \n   <div flex=\"40\" layout=\"column\"> \n      <div style=\"margin-top:25px\" flex=\"\" layout=\"row\">\n         <div style=\"padding-left:10px\"><md-checkbox ng-model=\"sav\" aria-label=\"sav\"><i class=\"fa fa-unlock-alt\" aria-hidden=\"true\"></i></md-checkbox></div>  \n         <!-- added ng-change = \"clear_form()\" -->\n         <div style=\"margin-left:10px\"><md-checkbox ng-model=\"clear\" ng-change = \"clear_form()\" aria-label=\"clear\"><i class=\"fa fa-circle-o\" aria-hidden=\"true\"></i></md-checkbox></div>\n      </div> \n     <!-- color:{{msg.colour}} not used so removed. Added ng-click = \"regular_plus()\" to action function --> \n     <div style=\"margin: -10px 0px 0px 5px\" id=\"regular_plus\"><md-button class=\"remote-button\" ng-click=\"clear_form()\"><span style=\"font-size:15px !important; width: 50px !important; color:{{msg.colour}}\" class=\"fa fa-window-restore\"> </span></md-button></div>    \n    </div>\n    <div style=\"margin-left:20px\" flex=\"45\" layout=\"column\">\n <div style=\"margin:5px 0px 0px 15px; text-align:center\"><md-input-container><input aria-label=\"amt\" ng-model=\"amt\"></md-input-container></div>\n       <!-- changed tm:tml to tm:tm as could not find tml, changed aut to sav -->\n       <div style=\"margin:-8px 0px 0px 10px\"><md-button aria-label=\"set\" class=\"md-accent md-hue-2 md-raised\" ng-click=\"send({topic: 'set', payload:{amt:amt, sav:sav, sl_trl:sl_trl, sl:sl, tp:tp, tp_trl:tp_trl, tm:tm, m15:m15, m30:m30, h1:h1, h2:h2}})\">SET</md-button></div>\n  </div>\n </div>\n</div>\n\n\n<script>\n\n(function(scope) {\n\n       // Set local variables. Could also set them to default values\n       let local_amt\n       let local_sl_trl\n       let local_sl\n       let local_tp\n       let local_tp_trl\n       let local_tm\n       let local_coin\n\n       // Variables used in the form\n       scope.amt = local_amt\n       scope.sl_trl = local_sl_trl\n       scope.sl = local_sl\n       scope.tp = local_tp\n       scope.tp_trl = local_tp_trl\n       scope.tm = local_tm\n       scope.coin = local_coin\n\n       scope.clear = false\n       scope.sav = false\n\n       // Clear form\n       scope.clear_form = function() {\n              if (scope.clear === true) {\n                     local_amt = ''\n                     local_sl_trl = ''\n                     local_sl = ''\n                     local_tp = ''\n                     local_tp_trl = ''\n                     local_tm = ''\n                     local_coin = ''\n\n                     showChange()\n              }\n       }\n  \n       scope.tdv = function() {\n              scope.send({topic: 'tdv', payload:{m15:m15, m30:m30, h1:h1, h2:h2}})\n       }\n\n       scope.$watch('msg', function(msg) {\n              // No error checking for properties\n              if(msg) {\n                     local_amt = msg.payload.amt\n                     local_sl_trl = msg.payload.sl_trl\n                     local_sl = msg.payload.sl\n                     local_tp = msg.payload.tp\n                     local_tp_trl = msg.payload.tp_trl\n                     local_tm = msg.payload.tm\n                     scope.clear = msg.payload.clear\n\n                     // Set to false so any incoming msg does not action following function\n                     msg.payload.sav = false                 \n\n                     showChange()\n\n                     scope.send(msg)\n              }\n       })\n    \n       // Update the scope variables to reflect back to the HTML\n       function showChange() {\n              scope.amt = local_amt\n              scope.sl_trl = local_sl_trl\n              scope.sl = local_sl\n              scope.tp = local_tp\n              scope.tp_trl = local_tp_trl\n              scope.tm = local_tm\n              scope.coin = local_coin\n                            \n       }\n\n\n})(scope);\n</script>",
        "storeOutMessages": false,
        "fwdInMessages": true,
        "resendOnRefresh": false,
        "templateScope": "local",
        "className": "setbox",
        "x": 690,
        "y": 320,
        "wires": [
            [
                "13b6034ca4b31a85"
            ]
        ]
    },
    {
        "id": "085d7feec44f7e35",
        "type": "ui_group",
        "name": "LEFT",
        "tab": "7e13e6107768d821",
        "order": 3,
        "disp": false,
        "width": "4",
        "collapse": false,
        "className": ""
    },
    {
        "id": "7e13e6107768d821",
        "type": "ui_tab",
        "name": "CRYPTO",
        "icon": "dashboard",
        "order": 2,
        "disabled": false,
        "hidden": false
    }
]
  • Apocalypse button clears the data stored in the data context
  • New form config was because I was having problems getting the layout right with original, probably because I did not have your CSS files. Ignore it if yours works as well
  • Input clearing, sorry about that my mistake. Replace local[property] = 0 with local[property] = ''
  • Clear on entering the field is my own personal preference, and again can be ignored, just remove the ng-focus = "clear_entry('tp_trl')" entries

I thought that that method was probably easier to understand and has the slight advantage that you only have to have a list of required properties in one place, but either method works. (Please note that I am no expert I get by with persistence & patience)

The up/down arrows in the number fields when you enter the field can be ignored, just type a number. Having a number type allows min & max values to be specified.

Can you comment on this pls ...

You had the clear function assigned to a checkbox - I didn't know that was possible, it seemed equivalent to a button? I was trying to do the same with the with the checkboxes on the left (15, 30, 1h, 2h), assign a function (same one to each: ng-change = "tdv()") which on any change would send a payload with the state of those 4 checkboxes.