# Multi-state switch + passthrough / msg parts

**URL:** <https://discourse.nodered.org/t/multi-state-switch-passthrough-msg-parts/70069>\
**Category:** General\
**Created:** [3 November 2022 23:29 UTC](https://discourse.nodered.org/t/multi-state-switch-passthrough-msg-parts/70069 "2022-11-03T23:29:31Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [10 November 2022 17:21 UTC](https://discourse.nodered.org/t/multi-state-switch-passthrough-msg-parts/70069/22 "2022-11-10T17:21:32Z")

</div>

Hope these all work...

1. Done
2. Done
3. Example working

Just one thought, at the moment you can select more than 1 time, is that what you intended?

Would you post your setbox CSS file so that I can get my copy to look like yours? 😀

Showing changes to function

```auto
       scope.m15 = false
       scope.m30 = false
       scope.h1 = false
       scope.h2 = false

       // Clear form
       scope.clear_form = function() {
              local_amt = ''
              local_sl_trl = ''
              local_sl = ''
              local_tp = ''
              local_tp_trl = ''
              local_tm = ''
              local_coin = ''

              showChange()

       }
  
       scope.tdv = function(boxChecked) {
              scope.send({topic: 'tdv', payload:{m15: scope.m15, m30: scope.m30, h1: scope.h1, h2: scope.h2}})

       }

```

```auto
[{"id":"9814b6e83a2c8ddd","type":"change","z":"d69bda8308d00eeb","name":"Currency Defaults","rules":[{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"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":450,"y":480,"wires":[["ecbe445a1df09c3f","427dd8c9300133e1"]]},{"id":"dcae8eef8641461b","type":"change","z":"d69bda8308d00eeb","name":"Form Defaults","rules":[{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"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":440,"y":300,"wires":[["f8068258c9fe415a","8ae906e22a6fc9ce"]]},{"id":"ecbe445a1df09c3f","type":"link out","z":"d69bda8308d00eeb","name":"link out 34","mode":"link","links":["d1da4326b4ca3757"],"x":575,"y":540,"wires":[]},{"id":"37ab719d1e96f5e5","type":"link in","z":"d69bda8308d00eeb","name":"link in 10","links":[],"x":245,"y":360,"wires":[["dcae8eef8641461b","9814b6e83a2c8ddd"]]},{"id":"37755b5ae569b01c","type":"function","z":"d69bda8308d00eeb","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":850,"y":300,"wires":[["be5d13054b91c01e","6693d184f84d71f0"]]},{"id":"be5d13054b91c01e","type":"ui_text","z":"d69bda8308d00eeb","group":"29525d7c67fd22a4","order":2,"width":3,"height":1,"name":"values","label":"","format":"<font color= {{msg.color}} > {{msg.payload}} </font>","layout":"row-spread","className":"values","x":1070,"y":300,"wires":[]},{"id":"c4c964234a682810","type":"ui_multistate_switch","z":"d69bda8308d00eeb","name":"mode","group":"29525d7c67fd22a4","order":4,"width":2,"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":340,"wires":[["37755b5ae569b01c","7286bcae0568bf2c","53cd765aaf814d43"]]},{"id":"53cd765aaf814d43","type":"function","z":"d69bda8308d00eeb","name":"FUNC","func":"// Missing assignments\nconst msgCRYPT={}; \nconst msgSET = {}; \nconst 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\nif (!m15) {\n m15 = false\n}\nflow.set ('m15', m15)\n\nif (!m30) {\n m30 = false\n}\nflow.set ('m30', m30)\n\nif (!h1) {\n h1 = false\n}\nflow.set ('h1', h1)\n\nif (!h2) {\n h2 = false\n\n}\nflow.set ('h2', h2)\n\n // Test of Load button\n if (topic.toLowerCase() === 'load') {\n return [msg, null, null]\n\n }\n\n\n// ALERT \nif ((msg.topic === \"alert\") || (msg.topic === \"reset\")) {\n\n let {currency, exchange, percent, window, note} = msg.payload\n flow.set('currency', currency)\n flow.set('exchange', exchange)\n flow.set('percent', percent)\n flow.set('note', note)\n flow.set('f_coin', currency + '/USD')\n flow.set('g_coin', currency + '_USDT')\n flow.set('b_coin', currency + 'USDT')\n\n\n msgTDV.payload = currency + \"USDT\"\n\n if (window === \"10 minutes\") {\n win = \"10m\"\n } else if (window === \"15 minutes\") {\n win = \"15m\"\n } else if (window === \"5 minutes\") {\n win = \"5m\"\n } else if (window === \"3 minutes\") {\n win = \"3m\"\n } else if (window == \"1 minutes\") {\n win = \"1m\"\n } \n\n flow.set('win', win)\n\n return [msgCRYPT, null, msgTDV]\n\n}\n\n\n// Check as moved the } to include return in 'if' block\nif (coin) {\n flow.set('currency', coin.toUpperCase())\n flow.set('exchange', exch)\n\n msgTDV.payload = `${flow.get('currency')}USDT`\n\n return [msgCRYPT, null, msgTDV]\n}\n\n\n\n// SCREENER\nif (msg.topic === \"screener\") {\n let data = msg.payload[0]\n\n return [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\n// SET \nif (msg.topic === \"mode\") {\n flow.set('state', state);\n\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\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\n return [null, msgSET, null] \n}\n\nif (clear === true) { \n msgSET.payload = \"\"\n\n return [null, msgSET, null]\n\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":1130,"y":160,"wires":[["9de5166ed381165f"],["3cec316eb141e997"],["679c3a9a867b750c"]]},{"id":"f8068258c9fe415a","type":"ui_template","z":"d69bda8308d00eeb","group":"29525d7c67fd22a4","name":"INPUT","order":5,"width":8,"height":5,"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\"> \n <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>\n </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('m15')\" 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('m30')\" 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('h1')\" 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('h2')\" 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;\">\n <md-input-container><input aria-label = \"coin\" ng-model = \"coin\"></md-input-container>\n </div>\n <div flex=\"\" style = \"margin-top:0px; margin-left:35px; \">\n <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>\n </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 = \"apocalypse\" ng-change = \"apocalypse()\" aria-label = \"apocalypse\"><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\"><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 scope.m15 = false\n scope.m30 = false\n scope.h1 = false\n scope.h2 = false\n\n // Clear form\n scope.clear_form = function() {\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(boxChecked) {\n scope.send({topic: 'tdv', payload:{m15: scope.m15, m30: scope.m30, h1: scope.h1, h2: scope.h2}})\n\n }\n\n scope.change_radio = function(){\n scope.send({topic: 'Exchange', payload: 'None'})\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":630,"y":240,"wires":[["37755b5ae569b01c","6bdc77e313b0aa7d","53cd765aaf814d43"]]},{"id":"427dd8c9300133e1","type":"debug","z":"d69bda8308d00eeb","name":"Currency Defaults","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":690,"y":480,"wires":[]},{"id":"26ccf8cf3164821c","type":"inject","z":"d69bda8308d00eeb","name":"Set Defaultd Manually","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":320,"wires":[["dcae8eef8641461b","9814b6e83a2c8ddd","8d1d5b384969e0bf"]]},{"id":"8ae906e22a6fc9ce","type":"debug","z":"d69bda8308d00eeb","name":"Default Values","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":420,"y":220,"wires":[]},{"id":"6bdc77e313b0aa7d","type":"debug","z":"d69bda8308d00eeb","name":"Form Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":850,"y":220,"wires":[]},{"id":"7286bcae0568bf2c","type":"debug","z":"d69bda8308d00eeb","name":"Mode Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":850,"y":420,"wires":[]},{"id":"6693d184f84d71f0","type":"debug","z":"d69bda8308d00eeb","name":"Display","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1080,"y":360,"wires":[]},{"id":"9de5166ed381165f","type":"debug","z":"d69bda8308d00eeb","name":"Function Output 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1430,"y":120,"wires":[]},{"id":"3cec316eb141e997","type":"debug","z":"d69bda8308d00eeb","name":"Function Output 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1430,"y":160,"wires":[]},{"id":"679c3a9a867b750c","type":"debug","z":"d69bda8308d00eeb","name":"Function Output 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1430,"y":200,"wires":[]},{"id":"8d1d5b384969e0bf","type":"change","z":"d69bda8308d00eeb","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":440,"y":360,"wires":[["c4c964234a682810"]]},{"id":"29525d7c67fd22a4","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}]

```

---

<div class="post-metadata">

**Author:** ![interscope101](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@interscope101](https://discourse.nodered.org/u/interscope101)\
**Post date:** [10 November 2022 20:06 UTC](https://discourse.nodered.org/t/multi-state-switch-passthrough-msg-parts/70069/23 "2022-11-10T20:06:18Z")

</div>

Couple of clarifications:

1. We're sending an initialization defaults payload. Is there any reason not to save (some of them) as flow variables right in the inject node? These checkbox states are declared in the form - are these meant to be defaults as well - do they override the injection payload defaults?

Then we have "msg.payload.sav = false" below - I understand the objective of that, but what is the relation to the above " scope.sav = true"

```auto
 scope.$watch('msg', function(msg) {
             if(msg) {   
                    scope.clear = msg.payload.clear
                    // Set to false so any incoming msg does not action following function
                    msg.payload.sav = false                 
             }
      })
   

```

1. I want to assign the clear input function to button (below the clear checkbox). I tried setting  
`<md-button class="remote-button" ng-click="clear_form()"> ` but that doesn't work.

2. If I am keeping our earlier data handling method, what is the best way to clear the stored memory; for the apocalypse function I want to use a third switch mode state - we had "A", "M" and now an "E" (see screenshot), so if that position is selected and SET button clicked it happens. Then I think the code would go here:

```auto
} else if (flow.get('state') === "E") {
    
     msg.payload = " **ERASE ALL**"
     msg.color = "red"
}

```

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/7/972bafa0f93ce7b8a26018da5dd11c1d6f9e97a1.png)

Here is the full CSS file

```auto

<style>
/*
It is reasnoble to declare the colors as CSS variables
so they can be easily called by name where needed.

You can see that in many places the variables are not used. Change it!
*/

:root {
  --color-green-primary: rgb(51, 204, 51);
  --color-green-secondary: rgb(26, 101, 26);
  --color-red-primary: rgb(255, 0, 0);
  --color-red-secondary: rgba(153,0,0,1);
  --color-gray-primary:rgba(19,23,34,1);
  --color-gray-secondary:rgba(30,34,45,1);
  --color-text-primary: rgb(209, 212, 220);
  --color-text-primary: rgb(209, 212, 220);
  --color-widget-border: rgb(84, 78, 78);
}

/*
All CSS adjustments are commented out.
Turn rules on one by one and see the changes.
Don't use too many elements cos it wil be confusing
Start with simple elements like text, slider or button

Many of elements like buttons have states, 
those rules must be found and adjusted also.
*/
.nr-dashboard-theme .nr-dashboard-gauge text {
    fill: #eeeeee;
    margin: 8px;
    font-size: 20px !important;
}

#gauge_56 > svg > text:nth-child(9) > tspan, #gauge_56 > svg > text:nth-child(8) > tspan {display:none !important;}

.tabulator-row.tabulator-selectable:hover {
	background-color: #000 !important;
	cursor: pointer
}

body.nr-dashboard-theme md-content {
    background: #131722 !important;
}

.hide {
    display: none !important;
}

.tradingview-widget-copyright {
    display: none !important;
}

body.nr-dashboard-theme md-content md-card {
    background-color: #33333300;
    text-shadow: none;
    box-shadow: 0 -1px 5px 1px #00000045;
    border-radius: 5px;
}

.md-toolbar {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    font-size: 16px;
    position: relative;
    width: 100%;
    z-index: 2;
}

.md-toolbar-tools {
    align-items: center;
    box-sizing: border-box;
    display: flex;
    flex-direction: row;
    font-size: 20px;
    font-weight: 400;
    height: 40px;
    letter-spacing: .005em;
    margin: 0;
    max-height: 40px;
    padding: 0 10px;
    width: 100%;
}

@media (max-width: 959px) and (min-width: 0) and (orientation: portrait)
<style>
.md-toolbar {
    min-height: 40px;
    height: 40px;
    max-height: 40px;
}

.masonry-container {
    position: relative;
    width: 100%;
    height:100%;
    margin: 0 auto;
    background: rgb(255,0,0);
    background: linear-gradient(180deg, var(--color-gray-primary) 0%, var(--color-gray-secondary) 100%);
}

.nr-dashboard-cardcontainer {
    position: relative;
/* box-shadow: inset 0px 1px 4px 0px #000000bb; */
    border-radius: 5px !important;
    box-shadow: none;
    
}

.nr-dashboard-theme .nr-dashboard-template {
    background-color: #1e222d !important;
}

.nr-dashboard-theme ui-card-panel {
    background-color: #33333300;
    color:var(--color-text-primary);
    border-radius: 5px !important;
/* box-shadow: 0 0 8px 0px #00000080;*/
    border:none;
    box-shadow: none !important;
}

body.nr-dashboard-theme md-content md-card {
    background-color: #33333300 !important;
    color: var(--color-text-primary);
/* text-shadow: 4px 2px 4px #00000045;*/
    text-shadow: none !important;
    box-shadow: 0 -1px 5px 1px #00000045;
    border-radius: 5px !important;
    border: 1px solid var(--color-widget-border);
}

.nr-dashboard-theme ui-card-panel p.nr-dashboard-cardtitle {
    color: var(--color-text-primary);
}

.md-button {
    display: inline-block;
    position: relative;
    cursor: pointer;
    min-height: 36px;
    min-width: 50px;
    line-height: 36px;
    vertical-align: middle;
    align-items: center;
    text-align: center;
    border-radius: 5px;
    box-sizing: border-box;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    outline: none;
    border: 0;
    padding: 0 6px;
    margin: 6px 8px;
    background: transparent;
    color:var(--color-text-primary);
    white-space: nowrap;
    text-transform: uppercase;
    font-weight: 500;
    font-size: 14px;
    font-style: inherit;
    font-variant: inherit;
    font-family: inherit;
    text-decoration: none;
    overflow: hidden;
    transition: box-shadow .4s cubic-bezier(.25,.8,.25,1),background-color .4s cubic-bezier(.25,.8,.25,1);
}

.nr-dashboard-theme .nr-dashboard-button .md-button {
    background-color: #88888800;
    color:var(--color-text-primary);
}

.nr-dashboard-theme .nr-dashboard-button .md-button:hover {
    background-color: #88888855;
}

md-slider .md-thumb {
    z-index: 1;
    position: absolute;
    left: -10px;
    top: 14px;
    width: 20px;
    height: 20px;
    border-radius: 10px;
    -webkit-transform: scale(.7);
    transform: scale(.7);
    transition: all .4s cubic-bezier(.25,.8,.25,1);
    box-shadow: 0 0 6px #00000070;
}

.tabulator .tabulator-header {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    border-bottom: 1px solid #434651 !important;
    background-color: #131722 !important;
    color: #637c93 !important;
    font-weight: 600 !important;
    line-height: 20px;
    font-size: 11px !important;
    height: 34px !important;
    font-family: Open Sans,helvetica,arial,sans-serif; 

}
.tabulator .tabulator-header {
        height: 30px !important;
}
.tabulator .tabulator-header .tabulator-col {
    display: inline-block;
    position: relative;
    box-sizing: border-box;
    border-right: 1px solid #434651 !important;
    background-color: #131722 !important;
    text-align: center;
    vertical-align: bottom;
    overflow: hidden;
  {
        height: 30px !important;
}
}

.tabulator-row {
    position: relative;
    box-sizing: border-box;
    min-height: 30px !important;
    background-color: #1e222d !important;
    font-family: Open Sans,helvetica,arial,sans-serif; 
    color: #728faa !important;
    line-height: 21px !important;
    text-align: center;
    
}

.tabulator-row:nth-child(2n) {
    background-color: #131722 !important;
    font-family: Open Sans,helvetica,arial,sans-serif; 
    color: #728faa !important;
}

.tabulator-row .tabulator-cell {
    display: inline-block;
    position: relative;
    box-sizing: border-box;
    padding: 6px !important;
    border-right: 1px solid #434651 !important;
    color: #728faa;
    font-weight: 500;
}

.tabulator .tabulator-tableHolder .tabulator-table {
    position: relative;
    display: inline-block;
    background-color: #666;
    white-space: nowrap;
    overflow: visible;
    color: #d1d4dc;
    font-size: 12px;
}

.tabulator .tabulator-header .tabulator-col.tabulator-sortable[aria-sort=none] .tabulator-col-content .tabulator-arrow {
    border-top: none;
    border-bottom: 6px solid #444;
}

.nr-dashboard-template {
    padding: 3px 3px 0px 3px !important; 
}

.nr-dashboard-theme .nr-dashboard-textinput input {
    color: #eeeeee;
    font-family: inherit;
    text-transform: uppercase;
    text-align: center;
    font-weight: 600;
    font-size: 12pt;
    letter-spacing: 1pt;
    height: 38px;
}

.nr-dashboard-textinput md-input-container {
    padding: 0px;
    margin: 0px;
    background-color: #111111;
}

md-radio-button .md-off {
    border-color: #fff !important;
}

md-radio-button.md-checked .md-on {
    background-color: #fff !important;
}

md-radio-button .md-off, md-radio-button .md-on {
    border-color: #777 !important;
}

md-radio-button {
    min-height: 28px !important;
    margin-left: 20px !important;
    margin-bottom: 0px !important;
    margin-top: 0px !important;
}

md-radio-button .md-label {
    position: absolute;
    top: 18%;
    font-size: 10pt;
    margin-left: -10px !important
}

md-radio-button .md-off, md-radio-button .md-on {
    border-radius: 50%;
    box-sizing: border-box;
    height: 15px !important;
    left: 0;
    position: absolute;
    top: 0;
    width: 15px !important;
}

.nr-dashboard-theme .nr-dashboard-template .md-button {
    background-color: #1e222d;
    margin: 0;
    min-height: 36px;
    min-width: 75px;
    margin-left: 2px;
    margin-top: 3px;
    font-size: 9pt;
    letter-spacing: 1pt;
}

md-radio-button .md-container {
    box-sizing: border-box;
    cursor: pointer;
    display: inline-block;
    height: 15px !important;
    left: 0;
    position: absolute;
    right: auto;
    top: 50%;
    transform: translateY(-50%);
    width: 15px !important;
    margin-left: 10px !important;
}

md-radio-button .md-container .md-ripple-container {
    bottom: -10px !important;
    display: block;
    height: auto;
    left: -10px !important;
    position: absolute;
    right: -10px !important;
    top: -10px !important;
    width: auto;
}

.nr-dashboard-text p {
    margin-right: 10px;
}

.md-button.md-hue-2.md-accent.md-raised {
    background-color: #142e61;
    border: 1px solid #434651;
}

.md-button.md-hue-2.md-accent.md-raised:not([disabled]):hover {
        background-color: rgb(41,121,255);
}

.nr-dashboard-theme .nr-dashboard-switch md-switch .md-thumb {
    background-color: red; 
}

.nr-dashboard-theme .nr-dashboard-switch md-switch.md-checked .md-thumb {
    background-color: #609f70;
}

.nr-dashboard-theme .nr-dashboard-switch md-switch .mode {
    background-color: blue !important; 
}

.nr-dashboard-theme .nr-dashboard-switch md-switch.md-checked .mode {
    background-color: green !important;
}

.nr-dashboard-theme .nr-dashboard-button .md-button {
    background-color: #1e222d;
    color: #bbb !important;
    font-weight: bold;
    letter-spacing: .5pt;
}

.tabulator-row .tabulator-cell {
    display: inline-block;
    position: relative;
    box-sizing: border-box;
    padding: 6px !important;
    border-right: 1px solid #434651 !important;
    color: #728faa;
    font-weight: 500;
    font-size: 9pt;
}

md-checkbox .md-container {
    left: auto;
    margin: -5px 0px 0px 0px !important;
    right: -3px;
    top: 0%;
}

md-checkbox .md-label {
    top: 0px;
    color: #728faa;
    margin: -15px 0px 0px 0px;
}

md-checkbox {
    min-height: 10px;
    width: 100%;
    margin: 0px 11px 0px 0px;
}

md-checkbox .md-icon {
   height: 16px;
   width: 16px;
   top: 1px;
}

md-checkbox.md-checked .md-icon:after {
    height: 9px;
}

md-checkbox.md-checked .md-icon {
    background-color: #282e3c;
}

md-checkbox .md-icon {
    background-color: #000;
    border: 1px solid #434651 !important;
}

md-checkbox:last-of-type {
    margin-left: 0px;
}

md-checkbox .md-container {
    left: auto;
    margin: 0px 0px 0px 0px;
    right: -3px;
    top: 0%;
}

.setbox {
    margin-right: 0px !important;
    padding-right: 0px !important;
}

.tabulator .tabulator-tableholder {
    background-color: #1e222d;
}

md-checkbox.md-default-theme[disabled]:not(.md-checked) .md-icon, md-checkbox[disabled]:not(.md-checked) .md-icon {
    display: none;
}

.nr-dashboard-text p {
    margin-right: 0px;
    text-align: center;
}

.coin {
    color: #2962ff !important;
    font-size: 11pt;
}

.values {
    font-size: 11px !important;
    font-weight: normal !important;
}

.buy {
    font-weight: bold !important;
}

.nr-dashboard-text .value {
    font-weight: normal;
    letter-spacing: .3pt;
    font-size: 9pt !important;
} 

md-input-container {
    display: inline-block;
    margin: 2px 0px 0px 0px !important;
    margin-top: 10px;
    margin-right: 0px;
    margin-bottom: 0px;
    margin-left: 0px;
    padding: 2px 0px 0px 0px;
    height: 45px;
    position: relative;
    vertical-align: middle;
}

md-input-container .md-input {
    background: none;
    border-radius: 3px;
    border-style: solid !important;
    border-width: 1px !important;
    box-sizing: border-box;
    display: block;
    float: left;
    height: 28px !important;
    line-height: 26px;
    order: 2;
    padding: 1px !important;
    width: 100%;
    background-color: #111 !important;
    text-align: center;
    font-size: 10pt;
    letter-spacing: .5pt;
  // width: 80px;
    text-transform: uppercase;
    border-color: #434651 !important;
    color: #ddd;
}

md-select .md-select-icon, md-select .md-select-value.md-select-placeholder {
   color: #728faa !important;
    font-size: 9pt;
}

md-option {
    align-items: center;
    cursor: pointer;
    display: flex;
    height: 34px;
    padding: 0 5px 0px 20px;
    position: relative;
    transition: background .15s linear;
    width: auto;
    font-size: 10pt;
}

body.nr-dashboard-theme md-content {
// background: #131444 !important;
   background: #000 !important;
}
md-select-menu md-content md-option:not([disabled]).md-focused {
      background: #000 !important;
}

.nr-dashboard-theme md-select-menu, .nr-dashboard-theme md-select-menu md-option {
    background-color: #131722;
    color: #728faa;
    font-weight: bold;
    font-size: 10pt;
    letter-spacing: 1pt;
}

.md-select-value>span:not(.md-select-icon) {
    flex: 1 1 auto;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #728faa;
   // font-weight: bold;
    font-size: 10pt;
}

md-select-menu md-content {
    max-height: 220px !important;
    min-height: 48px;
    min-width: 40px !important;
}

.nr-dashboard-theme .md-select-menu-container {
    max-height: 85%;
    overflow-y: auto;
    border: 1px solid #000;
    margin-top: -13px;
    margin-left: -97px;
    border-radius: 10px;
}

.md-select-value {
    margin-bottom: auto;
    min-height: 26px;
    min-width: 38px;
    padding: 2px 2px 1px 0;
    position: relative;
}

.nr-dashboard-switch p {
    padding: 0 0 0 10px;
    font-size: 9pt;
    color: #728faa;
}

.nr-dashboard-switch md-switch {
    padding: 0px;
    margin-left: 0px !important;
}

.remote-button
 {
    color: #728faa !important;
    min-height: 30px !important;
    padding-right: 0px 3px !important;
    min-width: 30px !important;
    font-size: 14pt !important;
    width: 50px !important ;
}

.mode-button {
    margin: 0;
    min-height: 28px !important;
    min-width: 50px !important;
    margin-left: 2px;
    margin-top: 1px !important;
    font-size: 9pt;
    letter-spacing: 1pt;
    color: #728faa !important;
}

.nr-dashboard-theme .nr-dashboard-template .md-button {
    background-color: #1e222d;
    margin: 0;
    min-height: 36px;
    min-width: 75px !important;
    margin-left: 2px;
    margin-top: 3px;
    font-size: 9pt;
    letter-spacing: 1pt;
}

.multistate-switch-button {
    text-align: center;
    z-index: 1;
    outline: none;
    user-select: none;
    cursor: pointer;
    line-height: 18pt !important;
    font-size: 10pt !important;
}

.multistate-switch-slider {

    height: 14pt !important;
    margin-top: 0pt !important;
    width: 14pt !important;
    margin-left: -1pt !important;
}

.multistate-switch-body {
    margin-left: 0px !important;
}

.multistate-switch-round {
    border-radius: 1em;
    margin-left: -1pt !important;
}

.fa {
    display: inline-block;
  color: #728faa !important;
    font-size: 11px!important;
    
}

.mylabel {
    font-size: 9pt;
    letter-spacing: .5pt !important;
    color: #728faa;
}
      
/*
Advanced stuff - dynamic change of card CSS

Classes here can be used to make colored stripe at the top of card
Usage is not in here, but they are added to md-card when needed within another template

.carderr {
    background: rgb(255,0,0);
    background: linear-gradient(180deg, var(--color-red-primary) 0px, var(--color-red-secondary) 3px, rgba(80,80,80,1) 4px, rgba(45,45,45,1) 100%);
}

.nr-dashboard-text .value {
    font-weight: normal;
    letter-spacing: .5pt;
    font-size: 11pt;
}

.cardok {
    background: rgb(39,255,0);
    background: linear-gradient(180deg, var(--color-green-primary) 0px, var(--color-green-secondary) 3px, rgba(70,70,70,1) 4px, rgba(40,40,40,1) 100%);
}
*/
</style>

```

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [10 November 2022 22:06 UTC](https://discourse.nodered.org/t/multi-state-switch-passthrough-msg-parts/70069/24 "2022-11-10T22:06:18Z")

</div>

1. `scope.clear` is overwritten by the default ` msg` but none of the others are, but that is easily done,  
just put

```auto
scope.m15 = msg.payload.m15
scope.m30 = msg.payload.m30
scope.h1 = msg.payload.h1
scope.h2 = msg.payload.h2

```

after `scope.clear` in the `scope.$watch('msg', function(msg)` function

I have actually set all those to `false` in my copy of the Form. They should be set however you want them when the Form is initialised

1. I have fixed this in the latest flow that I sent, the function was looking for a value from the check box. The function is now;

```auto
       // Clear form
       scope.clear_form = function() {
              local_amt = ''
              local_sl_trl = ''
              local_sl = ''
              local_tp = ''
              local_tp_trl = ''
              local_tm = ''
              local_coin = ''

              showChange()

       }

```

There is a `color: {{msg.colour}}` in the button icon style section that as far as I can tell is not used.  
This also leaves the `fa-circle-o checkbox` with nothing to do

1. That looks good. You would also have to flow.set(\*) all the data that you want to delete. There are also somewhere in the forum examples of 'are you sure' pop up boxes.

Thank you for the CSS file. Below is the way to have` input type="number"` without the spinners

```auto
<style>
       input::-webkit-outer-spin-button,
       input::-webkit-inner-spin-button {
              display: none;
       }
       
</style>

```

---

<div class="post-metadata">

**Author:** ![interscope101](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@interscope101](https://discourse.nodered.org/u/interscope101)\
**Post date:** [13 November 2022 02:08 UTC](https://discourse.nodered.org/t/multi-state-switch-passthrough-msg-parts/70069/25 "2022-11-13T02:08:13Z")

</div>

Hello again! All of the functionality is working, but having problem with defaults initialization.

1)The "mode" switch defaults to correct "M" state (at least most of the time), but the values set display does not (shows "A" state on load).  
2) The 15m, 30m ... checkboxes don't get set to at all (15m true, rest are fault).

Setting ANY scope.var to msg.payload.var (scope.m15 = msg.payload.m15) seems to break the while form.

```auto
[
    {
        "id": "090e52f59b7bda42",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "275aa32c6fa4dcb0",
        "type": "inject",
        "z": "090e52f59b7bda42",
        "name": "RESET",
        "props": [],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "x": 690,
        "y": 480,
        "wires": [
            [
                "2a064e66a0c51842"
            ]
        ]
    },
    {
        "id": "481adffce533f298",
        "type": "ui_button",
        "z": "090e52f59b7bda42",
        "name": "",
        "group": "085d7feec44f7e35",
        "order": 13,
        "width": "1",
        "height": "1",
        "passthru": false,
        "label": "RESET",
        "tooltip": "",
        "color": "#ccc",
        "bgcolor": "#131722",
        "className": "",
        "icon": "",
        "payload": "{\"flag\":\"reset\"}",
        "payloadType": "json",
        "topic": "",
        "topicType": "str",
        "x": 690,
        "y": 400,
        "wires": [
            [
                "2a064e66a0c51842"
            ]
        ]
    },
    {
        "id": "2a064e66a0c51842",
        "type": "change",
        "z": "090e52f59b7bda42",
        "name": "dfl",
        "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": "true",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.state",
                "pt": "msg",
                "to": "M",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.currency",
                "pt": "msg",
                "to": "SOL",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.exchange",
                "pt": "msg",
                "to": "Gate.io",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.m15",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.m30",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.h1",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.h2",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.real",
                "pt": "msg",
                "to": "#:(file)::real",
                "tot": "flow"
            },
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "reset",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 690,
        "y": 440,
        "wires": [
            [
                "db98c1687754fd81"
            ]
        ]
    },
    {
        "id": "38e187e15ecfd08f",
        "type": "ui_text",
        "z": "090e52f59b7bda42",
        "group": "085d7feec44f7e35",
        "order": 5,
        "width": "2",
        "height": "1",
        "name": "Msg",
        "label": "",
        "format": "<font color= {{msg.color}}> {{msg.payload}} </font>",
        "layout": "row-center",
        "className": "message",
        "x": 1190,
        "y": 460,
        "wires": []
    },
    {
        "id": "e9ad7a684c6b2626",
        "type": "link in",
        "z": "090e52f59b7bda42",
        "name": "link in 11",
        "links": [
            "3d141ed8289b1366",
            "5885b0d821405c26",
            "da3050726f647f80",
            "d2bb57edc33af090",
            "6003251c0935397b",
            "aa4b137e74b368ef"
        ],
        "x": 1095,
        "y": 460,
        "wires": [
            [
                "38e187e15ecfd08f"
            ]
        ]
    },
    {
        "id": "d909dd51d7af2354",
        "type": "link out",
        "z": "090e52f59b7bda42",
        "name": "link out 37",
        "mode": "link",
        "links": [],
        "x": 1085,
        "y": 360,
        "wires": []
    },
    {
        "id": "86f430d99d15412c",
        "type": "link in",
        "z": "090e52f59b7bda42",
        "name": "link in 12",
        "links": [
            "f832f23448befebe",
            "db98c1687754fd81"
        ],
        "x": 875,
        "y": 480,
        "wires": [
            [
                "00ca07b0b99228be"
            ]
        ]
    },
    {
        "id": "677d18036667e118",
        "type": "function",
        "z": "090e52f59b7bda42",
        "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, m15, m30, h1, h2, 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, is15m, is30m, is1h, is2h\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('rl')}`\n msg.color = \"#fd9795\"\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\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('rl_a')}`\n msg.color = \"#fdef55\"\n\n} else if (flow.get('state') === \"E\") {\n \n msg.payload = \"** ERASE ALL **\"\n msg.color = \"red\"\n}\n\n\nif (clear === true) { \n msg.payload = \"\"\n\n}\n\nreturn msg\n\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 970,
        "y": 400,
        "wires": [
            [
                "c6b41b7fcb4a4f0a"
            ]
        ]
    },
    {
        "id": "c6b41b7fcb4a4f0a",
        "type": "ui_text",
        "z": "090e52f59b7bda42",
        "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": 1150,
        "y": 400,
        "wires": []
    },
    {
        "id": "7996ccee0266727b",
        "type": "ui_multistate_switch",
        "z": "090e52f59b7bda42",
        "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": "<i class=\"fa fa-square-o\" style=\"color:red !important\"></i>",
                "value": "E",
                "valueType": "str",
                "color": "#ff0000"
            },
            {
                "label": "&nbsp;",
                "value": "y",
                "valueType": "str",
                "color": "#1e2223"
            },
            {
                "label": "<i class=\"fa fa-list-ul\" aria-hidden=\"true\"></i>",
                "value": "M",
                "valueType": "str",
                "color": "#0042ad"
            },
            {
                "label": "<i class=\"fa fa-database\"></i>",
                "value": "A",
                "valueType": "str",
                "color": "#0042ad"
            }
        ],
        "topic": "mode",
        "x": 970,
        "y": 440,
        "wires": [
            [
                "677d18036667e118"
            ]
        ]
    },
    {
        "id": "00ca07b0b99228be",
        "type": "ui_multistate_switch",
        "z": "090e52f59b7bda42",
        "name": "real",
        "group": "085d7feec44f7e35",
        "order": 4,
        "width": "1",
        "height": "1",
        "label": "",
        "stateField": "payload.real",
        "enableField": "enable",
        "passthroughField": "passthrough",
        "inputMsgField": "inputmsg",
        "rounded": true,
        "useThemeColors": false,
        "hideSelectedLabel": false,
        "multilineLabel": false,
        "passThrough": "always",
        "inputMsg": "all",
        "userInput": "enabled_show",
        "options": [
            {
                "label": "⇊",
                "value": "mP_aP",
                "valueType": "str",
                "color": "#ff0000"
            },
            {
                "label": "⇅",
                "value": "mR_aP",
                "valueType": "str",
                "color": "#4581a5"
            },
            {
                "label": "⇵",
                "value": "mP_aR",
                "valueType": "str",
                "color": "#4581a5"
            },
            {
                "label": "⇈",
                "value": "mR_aR",
                "valueType": "str",
                "color": "#008502"
            }
        ],
        "topic": "real",
        "x": 970,
        "y": 480,
        "wires": [
            [
                "6f7a260ea44d28ae"
            ]
        ]
    },
    {
        "id": "6f7a260ea44d28ae",
        "type": "change",
        "z": "090e52f59b7bda42",
        "name": "real",
        "rules": [
            {
                "t": "set",
                "p": "#:(file)::real",
                "pt": "flow",
                "to": "payload.real",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 970,
        "y": 520,
        "wires": [
            [
                "319a3befe38ffa6a"
            ]
        ]
    },
    {
        "id": "96e972f4713e1cf4",
        "type": "ui_template",
        "z": "090e52f59b7bda42",
        "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 layout=\"row\">\n <div style=\"margin: 0px 0px 0px 2px\" id=\"regular_plus\"><md-button class=\"remote-button\" style=\"min-width:30px !important; width:30px !important;\" ng-click=\"clear_form()\"><span style=\"font-size:13px !important; color:{{msg.colour}}\" class=\"fa fa-superpowers\"> </span></md-button></div> \n <div style=\"margin:20px 0px 0px 20px\" 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>\n\n <div style=\"margin-top: 5px\" layout=\"row\">\n <div style=\"margin-top:15px\" flex=\"30\"> <md-radio-group ng-model=\"exchange\" ng-change=\"changeradio()\" ng-init=\"exchange='Gate.io'\">\n <md-radio-button ng-model=\"exchange.Paper\" value=\"Paper\" class=\"md-primary\">P</md-radio-button>\n <md-radio-button ng-model=\"exchange.Binance\" value=\"Binance\" class=\"md-primary\">B</md-radio-button>\n <md-radio-button ng-model=\"exchange.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=\"60\">\n <div flex=\"\" style =\"text-align:center; margin-top:10px; margin-left:58px;\"><md-input-container><input aria-label=\"currency\" ng-model=\"currency\"></md-input-container></div>\n <div flex=\"\" style =\"margin-top:-5px; margin-left:50px; \"><md-button aria-label=\"load\" class=\"md-accent md-hue-2 md-raised\" ng-click=\"send({topic: 'load', payload:{exchange:exchange, currency:currency}})\">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=\"margin-left:30px\"><md-checkbox ng-model=\"clear\" ng-disabled=\"true\" ng-change = \"clear_form()\" aria-label=\"clear\"></md-checkbox></div>\n </div>\n <div style=\"margin-left:45px;margin-top:-13px\"><md-checkbox ng-model=\"sav\" aria-label=\"sav\"><i class=\"fa fa-unlock-alt\" aria-hidden=\"true\"></i></md-checkbox></div> \n </div>\n <div style=\"margin-left:20px\" flex=\"45\" layout=\"column\">\n <div style=\"margin:10px 0px 0px 15px; text-align:center\"><md-input-container><input aria-label=\"amt\" ng-model=\"amt\"></md-input-container></div>\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_currency\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_currency\n\n scope.clear = false\n scope.sav = true\n scope.m15 = false\n scope.m30 = false\n scope.h1 = false\n scope.h2 = false\n// scope.m15 = msg.payload.m15\n// scope.m30 = msg.payload.m30\n// scope.h1 = msg.payload.h1\n// scope.h2 = msg.payload.h2\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_currency = ''\n\n showChange()\n // }\n }\n \n scope.tdv = function(boxChecked) {\n scope.send({topic: 'tdv', payload:{m15:scope.m15, m30:scope.m30, h1:scope.h1, h2:scope.h2}})\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 local_m15 = msg.payload.m15\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.currency = local_currency\n \n }\n\n\n})(scope);\n</script>",
        "storeOutMessages": false,
        "fwdInMessages": true,
        "resendOnRefresh": false,
        "templateScope": "local",
        "className": "setbox",
        "x": 970,
        "y": 360,
        "wires": [
            [
                "677d18036667e118",
                "d909dd51d7af2354"
            ]
        ]
    },
    {
        "id": "db98c1687754fd81",
        "type": "link out",
        "z": "090e52f59b7bda42",
        "name": "link out 38",
        "mode": "link",
        "links": [
            "da85bf31a241c263",
            "86f430d99d15412c",
            "70d8fbfd8d88c41d"
        ],
        "x": 785,
        "y": 440,
        "wires": []
    },
    {
        "id": "da85bf31a241c263",
        "type": "link in",
        "z": "090e52f59b7bda42",
        "name": "link in 13",
        "links": [
            "db98c1687754fd81"
        ],
        "x": 875,
        "y": 360,
        "wires": [
            [
                "96e972f4713e1cf4"
            ]
        ]
    },
    {
        "id": "70d8fbfd8d88c41d",
        "type": "link in",
        "z": "090e52f59b7bda42",
        "name": "link in 14",
        "links": [
            "db98c1687754fd81"
        ],
        "x": 875,
        "y": 440,
        "wires": [
            [
                "7996ccee0266727b"
            ]
        ]
    },
    {
        "id": "319a3befe38ffa6a",
        "type": "link out",
        "z": "090e52f59b7bda42",
        "name": "link out 40",
        "mode": "link",
        "links": [],
        "x": 1065,
        "y": 520,
        "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
    }
]

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/6/b6965340c6c1970695756b0e4f88767fbb34bb0f.png)

---

<div class="post-metadata">

**Author:** ![interscope101](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@interscope101](https://discourse.nodered.org/u/interscope101)\
**Post date:** [13 November 2022 20:23 UTC](https://discourse.nodered.org/t/multi-state-switch-passthrough-msg-parts/70069/26 "2022-11-13T20:23:14Z")

</div>

I am now seeing a new issue that I can't track down. On reset inject I am getting two identical msg loads outputs - something is duplicating them.

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [13 November 2022 21:12 UTC](https://discourse.nodered.org/t/multi-state-switch-passthrough-msg-parts/70069/27 "2022-11-13T21:12:52Z")

</div>

1. Set `scope.m15` to `true`

```auto
       scope.clear = false
       scope.sav = false
       scope.m15 = true
       scope.m30 = false
       scope.h1 = false
       scope.h2 = false

```

1. In the `Mode Default change node` set `msg.payload.state` to 'M'

I also added `change_radio()` and amended the `Gate.io radio button` HTML

```auto
md-radio-group ng-model = "exchange" ng-change = "change_radio()" ng-init = "exchange = Gate.io"

<md-radio-button ng-model="exchange['Gate.io']" data-ng-checked="true" value="Gate.io">G</md-radio-button></md-radio-group>

```

```auto
       scope.exchange = 'Gate.io'

       scope.change_radio = function(){ 
              scope.send({topic: 'Exchange', payload: scope.exchange})
       }

```

and amended the `scope.$watch(`) function

```auto
                     scope.m15 = msg.payload.m15
                     scope.exchange = msg.payload.exchange

```

You may also wish to include a few more entries in the `clear_form()` function

---

<div class="post-metadata">

**Author:** ![interscope101](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@interscope101](https://discourse.nodered.org/u/interscope101)\
**Post date:** [13 November 2022 21:27 UTC](https://discourse.nodered.org/t/multi-state-switch-passthrough-msg-parts/70069/28 "2022-11-13T21:27:20Z")

</div>

I had this line originally

```auto
     <div style="margin-top:15px" flex="30"> <md-radio-group ng-model="exchange" ng-change="changeradio()" ng-init="exchange='Gate.io'">

```

you changed "changeradio()" to "change\_radio()" ?

When you say amended `scope.$watch(` ), do you mean (there is no other $watch function)

```auto
scope.$watch('msg', function(msg) {
              // No error checking for properties
              if(msg) {
                     local_amt = msg.payload.amt
                     local_sl_trl = msg.payload.sl_trl
                     local_sl = msg.payload.sl
                     local_tp = msg.payload.tp
                     local_tp_trl = msg.payload.tp_trl
                     local_tm = msg.payload.tm
                     scope.clear = msg.payload.clear
                     local_m15 = msg.payload.m15

                     // Set to false so any incoming msg does not action following function
                     msg.payload.sav = false                 

                     showChange()

                     scope.send(msg)

```

---

<div class="post-metadata">

**Author:** ![interscope101](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@interscope101](https://discourse.nodered.org/u/interscope101)\
**Post date:** [13 November 2022 21:36 UTC](https://discourse.nodered.org/t/multi-state-switch-passthrough-msg-parts/70069/29 "2022-11-13T21:36:05Z")

</div>

The mode switch is defaulting to "M" but not the display text (onload it is showing "A" variables)

```auto
/**
 * 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, m15, m30, h1, h2, sav, clear = false} = msg.payload
let 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, is15m, is30m, is1h, is2h, TP, SL, TMO, TPT, SLT

let topic = msg.topic

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

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

    // If SET Button pressed
    if (sav) {

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

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

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

        if ( sl && sl > 0 && sl < 6 ) {
            flow.set('sl', sl);
            sl_s = true;
        } else {
            sl = null;
            sl_s = false;
        }
        flow.set('sl_s', sl_s);

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

        if ( tm && tm > 0 && tm < 4 ) {
            flow.set('tm', tm)
            tm_s = true;

        } else {
            tm = null;
            tm_s = false;
        }
        flow.set('tm_s', tm_s);

    }

    if (flow.get('tp_trl_s')) {TPT = ":"+flow.get('tp_trl')} else {TPT = ""}
    if (flow.get('sl_trl_s')) {SLT = ":"+flow.get('sl_trl')} else {SLT = ""}
    
    if (flow.get('tp_s')) {TP = " P "+flow.get('tp') +TPT+" |"} else {TP = ""}
    if (flow.get('sl_s')) {SL = " L "+flow.get('sl') +SLT+" |"} else {SL = ""}
    if (flow.get('tm_s')) {TMO = " T "+flow.get('tm') +" |"} else {TMO = ""}
     
    
    msg.payload = "$"+ flow.get('amt') + " |"+ TP + SL + TMO + " "+flow.get('rl', 'file')
  

// 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('rl')}`
    msg.color = "#fd9795"

} 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'); tp_s_a = true;
        } else {
            tp_a = null; tp_s_a = false;
        }
        flow.set('tp_s_a', tp_s_a, 'file')

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

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

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

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

    }

    if (flow.get('tp_trl_s_a', 'file')) {TPT = ":"+flow.get('tp_trl_a', 'file')} else {TPT = ""}
    if (flow.get('sl_trl_s_a', 'file')) {SLT = ":"+flow.get('sl_trl_a', 'file')} else {SLT = ""}
    
    if (flow.get('tp_s_a', 'file')) {TP = " P "+flow.get('tp_a', 'file') +TPT+" |"} else {TP = ""}
    if (flow.get('sl_s_a', 'file')) {SL = " L "+flow.get('sl_a', 'file') +SLT+" |"} else {SL = ""}
    if (flow.get('tm_s_a', 'file')) {TMO = " T "+flow.get('tm_a', 'file') +" |"} else {TMO = ""}
     
    
    msg.payload = "$"+ flow.get('amt_a', 'file') + " |"+ TP + SL + TMO + " "+flow.get('rl_a', 'file')

// 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('rl_a')}`
    msg.color = "#fdef55"

} else if (flow.get('state') === "E") {
    if (sav) {
     flow.set('tp', undefined); flow.set('tp_a', undefined, 'file')
     flow.set('tp_s', undefined); flow.set('tp_s_a', undefined, 'file') 
     flow.set('tp_trl', undefined); flow.set('tp_trl_a', undefined, 'file') 
     flow.set('tp_trl_s', undefined); flow.set('tp_trl_s_a', undefined, 'file')
     
    flow.set('sl', undefined); flow.set('sl_a', undefined, 'file')
    flow.set('sl_s', undefined); flow.set('sl_s_a', undefined, 'file')
    flow.set('sl_trl', undefined); flow.set('sl_trl_a', undefined, 'file')
    flow.set('sl_trl_s', undefined); flow.set('sl_trl_s_a', undefined, 'file')
    
    flow.set('tm', undefined); flow.set('tm_a', undefined, 'file')
    flow.set('tm_s', undefined); flow.set('tm_s_a', undefined, 'file')
        
    }    
     msg.payload = " **ERASE ALL**"
     msg.color = "red"
}

if (clear === true) { 
    msg.payload = ""

}

return msg

```

---

<div class="post-metadata">

**Author:** ![interscope101](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@interscope101](https://discourse.nodered.org/u/interscope101)\
**Post date:** [13 November 2022 22:00 UTC](https://discourse.nodered.org/t/multi-state-switch-passthrough-msg-parts/70069/30 "2022-11-13T22:00:45Z")

</div>

On default inject I get 4 duplicate sets of msg coming out of input node. Is each button action generating it?

```auto
[
    {
        "id": "a2a981a7f41d5620",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "b8614632402fac89",
        "type": "group",
        "z": "a2a981a7f41d5620",
        "style": {
            "stroke": "#999999",
            "stroke-opacity": "1",
            "fill": "none",
            "fill-opacity": "1",
            "label": true,
            "label-position": "nw",
            "color": "#a4a4a4"
        },
        "nodes": [
            "0df9da90968a826c",
            "33aed74faff35593",
            "d3d4a74dc2f5fc95",
            "fec705f939d7cdf4",
            "4f5bf1d37d47ce7c",
            "fd3f95207f106bc3",
            "66128eddf556f5df",
            "d9e644a25948270f",
            "b80d3b8d8177ffdb",
            "dd9324908a8e381b",
            "fb73c36aa3697b3e"
        ],
        "x": 664,
        "y": 239,
        "w": 392,
        "h": 242
    },
    {
        "id": "ec10addf34548b4e",
        "type": "inject",
        "z": "a2a981a7f41d5620",
        "name": "RESET",
        "props": [],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "x": 470,
        "y": 340,
        "wires": [
            [
                "7d21d17a6dd3129f"
            ]
        ]
    },
    {
        "id": "4c72b17ff58f750e",
        "type": "ui_button",
        "z": "a2a981a7f41d5620",
        "name": "",
        "group": "085d7feec44f7e35",
        "order": 13,
        "width": "1",
        "height": "1",
        "passthru": false,
        "label": "RESET",
        "tooltip": "",
        "color": "#ccc",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "{\"flag\":\"reset\"}",
        "payloadType": "json",
        "topic": "",
        "topicType": "str",
        "x": 470,
        "y": 260,
        "wires": [
            [
                "7d21d17a6dd3129f"
            ]
        ]
    },
    {
        "id": "7d21d17a6dd3129f",
        "type": "change",
        "z": "a2a981a7f41d5620",
        "name": "dfl",
        "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": "true",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.state",
                "pt": "msg",
                "to": "M",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.currency",
                "pt": "msg",
                "to": "SOL",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.exchange",
                "pt": "msg",
                "to": "Gate.io",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.m15",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.m30",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.h1",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.h2",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.real",
                "pt": "msg",
                "to": "#:(file)::real",
                "tot": "flow"
            },
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "reset",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 470,
        "y": 300,
        "wires": [
            [
                "1e35026b8625bc02"
            ]
        ]
    },
    {
        "id": "a39fd5d0828547e5",
        "type": "ui_button",
        "z": "a2a981a7f41d5620",
        "name": "refresh",
        "group": "085d7feec44f7e35",
        "order": 14,
        "width": "1",
        "height": "1",
        "passthru": false,
        "label": "<i class=\"fa fa-refresh\" aria-hidden=\"true\" style=\"font-size:15px !important\"></i>",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "refresh",
        "icon": "",
        "payload": "{\"flag\":\"reset\",\"currency\":\"SOL\",\"exchange\":\"Binance\"}",
        "payloadType": "json",
        "topic": "topic",
        "topicType": "str",
        "x": 470,
        "y": 220,
        "wires": [
            [
                "500ec01fc2f917a7"
            ]
        ]
    },
    {
        "id": "1e35026b8625bc02",
        "type": "link out",
        "z": "a2a981a7f41d5620",
        "name": "link out 38",
        "mode": "link",
        "links": [
            "b80d3b8d8177ffdb",
            "dd9324908a8e381b",
            "33aed74faff35593"
        ],
        "x": 565,
        "y": 300,
        "wires": []
    },
    {
        "id": "500ec01fc2f917a7",
        "type": "link out",
        "z": "a2a981a7f41d5620",
        "name": "link out 39",
        "mode": "link",
        "links": [
            "d967eb6899fe105b"
        ],
        "x": 565,
        "y": 220,
        "wires": []
    },
    {
        "id": "0df9da90968a826c",
        "type": "link out",
        "z": "a2a981a7f41d5620",
        "g": "b8614632402fac89",
        "name": "link out 40",
        "mode": "link",
        "links": [
            "d967eb6899fe105b"
        ],
        "x": 915,
        "y": 280,
        "wires": []
    },
    {
        "id": "33aed74faff35593",
        "type": "link in",
        "z": "a2a981a7f41d5620",
        "g": "b8614632402fac89",
        "name": "link in 14",
        "links": [
            "f832f23448befebe",
            "1e35026b8625bc02"
        ],
        "x": 705,
        "y": 400,
        "wires": [
            [
                "fd3f95207f106bc3"
            ]
        ]
    },
    {
        "id": "d3d4a74dc2f5fc95",
        "type": "function",
        "z": "a2a981a7f41d5620",
        "g": "b8614632402fac89",
        "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, m15, m30, h1, h2, 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, is15m, is30m, is1h, is2h, TP, SL, TMO, TPT, SLT\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 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 flow.set('tp_trl_s', tp_trl_s);\n\n if ( sl && sl > 0 && sl < 6 ) {\n flow.set('sl', sl);\n sl_s = true;\n } else {\n sl = null;\n 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);\n sl_trl_s = true;\n } else {\n sl_trl = null;\n 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)\n tm_s = true;\n\n } else {\n tm = null;\n tm_s = false;\n }\n flow.set('tm_s', tm_s);\n\n }\n\n\n if (flow.get('tp_trl_s')) {TPT = \":\"+flow.get('tp_trl')} else {TPT = \"\"}\n if (flow.get('sl_trl_s')) {SLT = \":\"+flow.get('sl_trl')} else {SLT = \"\"}\n \n if (flow.get('tp_s')) {TP = \" P \"+flow.get('tp') +TPT+\" |\"} else {TP = \"\"}\n if (flow.get('sl_s')) {SL = \" L \"+flow.get('sl') +SLT+\" |\"} else {SL = \"\"}\n if (flow.get('tm_s')) {TMO = \" T \"+flow.get('tm') +\" |\"} else {TMO = \"\"}\n \n \n msg.payload = \"$\"+ flow.get('amt') + \" |\"+ TP + SL + TMO + \" \"+flow.get('rl', 'file')\n \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('rl')}`\n msg.color = \"#fd9795\"\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 flow.set('tp_s_a', tp_s_a, 'file')\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 flow.set('tp_trl_s_a', tp_trl_s_a, 'file')\n\n if ( sl && sl > 0 && sl < 6 ) {\n flow.set('sl_a', sl, 'file'); sl_s_a = true;\n } else {\n sl_a = null; sl_s_a = false;\n }\n flow.set('sl_s_a', sl_s_a, 'file')\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 flow.set('sl_trl_s_a', sl_trl_s_a, 'file')\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 flow.set('tm_s_a', tm_s_a, 'file')\n\n }\n\n\n if (flow.get('tp_trl_s_a', 'file')) {TPT = \":\"+flow.get('tp_trl_a', 'file')} else {TPT = \"\"}\n if (flow.get('sl_trl_s_a', 'file')) {SLT = \":\"+flow.get('sl_trl_a', 'file')} else {SLT = \"\"}\n \n if (flow.get('tp_s_a', 'file')) {TP = \" P \"+flow.get('tp_a', 'file') +TPT+\" |\"} else {TP = \"\"}\n if (flow.get('sl_s_a', 'file')) {SL = \" L \"+flow.get('sl_a', 'file') +SLT+\" |\"} else {SL = \"\"}\n if (flow.get('tm_s_a', 'file')) {TMO = \" T \"+flow.get('tm_a', 'file') +\" |\"} else {TMO = \"\"}\n \n \n msg.payload = \"$\"+ flow.get('amt_a', 'file') + \" |\"+ TP + SL + TMO + \" \"+flow.get('rl_a', 'file')\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('rl_a')}`\n msg.color = \"#fdef55\"\n\n} else if (flow.get('state') === \"E\") {\n if (sav) {\n flow.set('tp', undefined); flow.set('tp_a', undefined, 'file')\n flow.set('tp_s', undefined); flow.set('tp_s_a', undefined, 'file') \n flow.set('tp_trl', undefined); flow.set('tp_trl_a', undefined, 'file') \n flow.set('tp_trl_s', undefined); flow.set('tp_trl_s_a', undefined, 'file')\n \n flow.set('sl', undefined); flow.set('sl_a', undefined, 'file')\n flow.set('sl_s', undefined); flow.set('sl_s_a', undefined, 'file')\n flow.set('sl_trl', undefined); flow.set('sl_trl_a', undefined, 'file')\n flow.set('sl_trl_s', undefined); flow.set('sl_trl_s_a', undefined, 'file')\n \n flow.set('tm', undefined); flow.set('tm_a', undefined, 'file')\n flow.set('tm_s', undefined); flow.set('tm_s_a', undefined, 'file')\n \n } \n msg.payload = \" **ERASE ALL** \"\n msg.color = \"red\"\n}\n\n\nif (clear === true) { \n msg.payload = \"\"\n\n}\n\nreturn msg\n\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 800,
        "y": 320,
        "wires": [
            [
                "fec705f939d7cdf4"
            ]
        ]
    },
    {
        "id": "fec705f939d7cdf4",
        "type": "ui_text",
        "z": "a2a981a7f41d5620",
        "g": "b8614632402fac89",
        "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": 980,
        "y": 320,
        "wires": []
    },
    {
        "id": "4f5bf1d37d47ce7c",
        "type": "ui_multistate_switch",
        "z": "a2a981a7f41d5620",
        "g": "b8614632402fac89",
        "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": "<i class=\"fa fa-square-o\" style=\"color:red !important\"></i>",
                "value": "E",
                "valueType": "str",
                "color": "#ff0000"
            },
            {
                "label": "&nbsp;",
                "value": "y",
                "valueType": "str",
                "color": "#1e2223"
            },
            {
                "label": "<i class=\"fa fa-list-ul\" aria-hidden=\"true\"></i>",
                "value": "M",
                "valueType": "str",
                "color": "#0042ad"
            },
            {
                "label": "<i class=\"fa fa-database\"></i>",
                "value": "A",
                "valueType": "str",
                "color": "#0042ad"
            }
        ],
        "topic": "mode",
        "x": 800,
        "y": 360,
        "wires": [
            [
                "d3d4a74dc2f5fc95"
            ]
        ]
    },
    {
        "id": "fd3f95207f106bc3",
        "type": "ui_multistate_switch",
        "z": "a2a981a7f41d5620",
        "g": "b8614632402fac89",
        "name": "real",
        "group": "085d7feec44f7e35",
        "order": 4,
        "width": "1",
        "height": "1",
        "label": "",
        "stateField": "payload.real",
        "enableField": "enable",
        "passthroughField": "passthrough",
        "inputMsgField": "inputmsg",
        "rounded": true,
        "useThemeColors": false,
        "hideSelectedLabel": false,
        "multilineLabel": false,
        "passThrough": "always",
        "inputMsg": "all",
        "userInput": "enabled_show",
        "options": [
            {
                "label": "⇊",
                "value": "mP_aP",
                "valueType": "str",
                "color": "#ff0000"
            },
            {
                "label": "⇅",
                "value": "mR_aP",
                "valueType": "str",
                "color": "#4581a5"
            },
            {
                "label": "⇵",
                "value": "mP_aR",
                "valueType": "str",
                "color": "#4581a5"
            },
            {
                "label": "⇈",
                "value": "mR_aR",
                "valueType": "str",
                "color": "#008502"
            }
        ],
        "topic": "real",
        "x": 800,
        "y": 400,
        "wires": [
            [
                "66128eddf556f5df"
            ]
        ]
    },
    {
        "id": "66128eddf556f5df",
        "type": "change",
        "z": "a2a981a7f41d5620",
        "g": "b8614632402fac89",
        "name": "real",
        "rules": [
            {
                "t": "set",
                "p": "#:(file)::real",
                "pt": "flow",
                "to": "payload.real",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 800,
        "y": 440,
        "wires": [
            [
                "fb73c36aa3697b3e"
            ]
        ]
    },
    {
        "id": "d9e644a25948270f",
        "type": "ui_template",
        "z": "a2a981a7f41d5620",
        "g": "b8614632402fac89",
        "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 layout=\"row\">\n <div style=\"margin: 0px 0px 0px 2px\" id=\"regular_plus\"><md-button class=\"remote-button\" style=\"min-width:30px !important; width:30px !important;\" ng-click=\"clear_form()\"><span style=\"font-size:13px !important; color:{{msg.colour}}\" class=\"fa fa-superpowers\"> </span></md-button></div> \n <div style=\"margin:20px 0px 0px 20px\" 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>\n\n <div style=\"margin-top: 5px\" layout=\"row\">\n <div style=\"margin-top:15px\" flex=\"30\"> <md-radio-group ng-model=\"exchange\" ng-change=\"changeradio()\" ng-init=\"exchange='Gate.io'\">\n <md-radio-button ng-model=\"exchange.Paper\" value=\"Paper\" class=\"md-primary\">P</md-radio-button>\n <md-radio-button ng-model=\"exchange.Binance\" value=\"Binance\" class=\"md-primary\">B</md-radio-button>\n <md-radio-button ng-model=\"exchange.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=\"60\">\n <div flex=\"\" style =\"text-align:center; margin-top:10px; margin-left:58px;\"><md-input-container><input aria-label=\"currency\" ng-model=\"currency\"></md-input-container></div>\n <div flex=\"\" style =\"margin-top:-5px; margin-left:50px; \"><md-button aria-label=\"load\" class=\"md-accent md-hue-2 md-raised\" ng-click=\"send({topic: 'load', payload:{exchange:exchange, currency:currency}})\">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=\"margin-left:30px\"><md-checkbox ng-model=\"clear\" ng-disabled=\"true\" ng-change = \"clear_form()\" aria-label=\"clear\"></md-checkbox></div>\n </div>\n <div style=\"margin-right: 35px; margin-left:10px;margin-top:-13px\"><md-checkbox ng-model=\"sav\" aria-label=\"sav\"><i class=\"fa fa-unlock-alt\" aria-hidden=\"true\"></i></md-checkbox></div> \n </div>\n <div style=\"margin-left:20px\" flex=\"45\" layout=\"column\">\n <div style=\"margin:10px 0px 0px 15px; text-align:center\"><md-input-container><input aria-label=\"amt\" ng-model=\"amt\"></md-input-container></div>\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_currency\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_currency\n scope.exchange = 'Gate.io'\n scope.clear = false\n scope.sav = true\n scope.m15 = true\n scope.m30 = false\n scope.h1 = false\n scope.h2 = false\n// scope.m15 = msg.payload.m15\n// scope.m30 = msg.payload.m30\n// scope.h1 = msg.payload.h1\n// scope.h2 = msg.payload.h2\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_currency = ''\n\n showChange()\n // }\n }\n \n scope.tdv = function(boxChecked) {\n scope.send({topic: 'tdv', payload:{m15:scope.m15, m30:scope.m30, h1:scope.h1, h2:scope.h2}})\n\n }\n \n scope.change_radio = function(){ \n scope.send({topic: 'Exchange', payload: scope.exchange})\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 scope.m15 = msg.payload.m15\n scope.exchange = msg.payload.exchange\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.currency = local_currency\n \n }\n\n\n})(scope);\n</script>",
        "storeOutMessages": false,
        "fwdInMessages": true,
        "resendOnRefresh": false,
        "templateScope": "local",
        "className": "setbox",
        "x": 800,
        "y": 280,
        "wires": [
            [
                "d3d4a74dc2f5fc95",
                "0df9da90968a826c"
            ]
        ]
    },
    {
        "id": "b80d3b8d8177ffdb",
        "type": "link in",
        "z": "a2a981a7f41d5620",
        "g": "b8614632402fac89",
        "name": "link in 15",
        "links": [
            "1e35026b8625bc02"
        ],
        "x": 705,
        "y": 280,
        "wires": [
            [
                "d9e644a25948270f"
            ]
        ]
    },
    {
        "id": "dd9324908a8e381b",
        "type": "link in",
        "z": "a2a981a7f41d5620",
        "g": "b8614632402fac89",
        "name": "link in 16",
        "links": [
            "1e35026b8625bc02"
        ],
        "x": 705,
        "y": 360,
        "wires": [
            [
                "4f5bf1d37d47ce7c"
            ]
        ]
    },
    {
        "id": "fb73c36aa3697b3e",
        "type": "link out",
        "z": "a2a981a7f41d5620",
        "g": "b8614632402fac89",
        "name": "link out 41",
        "mode": "link",
        "links": [],
        "x": 895,
        "y": 440,
        "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
    }
]

```

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [13 November 2022 23:00 UTC](https://discourse.nodered.org/t/multi-state-switch-passthrough-msg-parts/70069/31 "2022-11-13T23:00:17Z")

</div>

Try;

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

```

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [13 November 2022 23:03 UTC](https://discourse.nodered.org/t/multi-state-switch-passthrough-msg-parts/70069/32 "2022-11-13T23:03:39Z")

</div>

I am not seeing that. Input node I have;

```auto
[{"id":"d482b241ec9cd656","type":"ui_template","z":"1515b9a41857fcf0","group":"101683f3a5931d3a","name":"INPUT","order":7,"width":8,"height":4,"format":"\n<div style=\"padding: 5px 5px 0px 0px\" layout=\"row\">\n\n<div flex=\"50\"> \n\n <div layout=\"row\">\n <div style=\"margin: 0px 0px 0px 2px\" id=\"regular_plus\"><md-button class=\"remote-button\" style=\"min-width:30px !important; width:30px !important;\" ng-click=\"clear_form()\"><span style=\"font-size:13px !important; color:{{msg.colour}}\" class=\"fa fa-superpowers\"> </span></md-button></div> \n <div style=\"margin:20px 0px 0px 20px\" 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>\n\n <div style=\"margin-top: 5px\" layout=\"row\">\n <div style=\"margin-top:15px\" flex=\"30\"> <md-radio-group ng-model=\"exchange\" ng-change=\"change_radio()\" ng-init=\"exchange=Gate.io\">\n <md-radio-button ng-model=\"exchange.Paper\" value=\"Paper\" class=\"md-primary\">P</md-radio-button>\n <md-radio-button ng-model=\"exchange.Binance\" value=\"Binance\" class=\"md-primary\">B</md-radio-button>\n <md-radio-button ng-model=\"exchange['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=\"60\">\n <div flex=\"\" style =\"text-align:center; margin-top:10px; margin-left:58px;\"><md-input-container><input aria-label=\"currency\" ng-model=\"currency\"></md-input-container></div>\n <div flex=\"\" style =\"margin-top:-5px; margin-left:50px; \"><md-button aria-label=\"load\" class=\"md-accent md-hue-2 md-raised\" ng-click=\"send({topic: 'load', payload:{exchange:exchange, currency:currency}})\">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=\"margin-left:30px\"><md-checkbox ng-model=\"clear\" ng-disabled=\"true\" ng-change = \"clear_form()\" aria-label=\"clear\"></md-checkbox></div>\n </div>\n <div style=\"margin-left:45px;margin-top:-13px\"><md-checkbox ng-model=\"sav\" aria-label=\"sav\"><i class=\"fa fa-unlock-alt\" aria-hidden=\"true\"></i></md-checkbox></div> \n </div>\n <div style=\"margin-left:20px\" flex=\"45\" layout=\"column\">\n <div style=\"margin:10px 0px 0px 15px; text-align:center\"><md-input-container><input aria-label=\"amt\" ng-model=\"amt\"></md-input-container></div>\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 \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 scope.m15 = true\n scope.m30 = false\n scope.h1 = false\n scope.h2 = false\n scope.exchange = 'Gate.io'\n\n // Clear form\n scope.clear_form = function() {\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: scope.m15, m30: scope.m30, h1: scope.h1, h2: scope.h2}})\n\n }\n\n scope.change_radio = function(){\n scope.send({topic: 'Exchange', payload: scope.exchange})\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 scope.m15 = msg.payload.m15\n scope.exchange = msg.payload.exchange\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":970,"y":360,"wires":[["8b5e1fedf4689991","42821d474305280f","67a6f65d4632c0ca"]],"info":"\r\n\r\n // Set local variables. Could also set them to default values\r\n let local_amt\r\n let local_sl_trl\r\n let local_sl\r\n let local_tp\r\n let local_tp_trl\r\n let local_tm\r\n let local_currency\r\n\r\n // Variables used in the form\r\n scope.amt = local_amt\r\n scope.sl_trl = local_sl_trl\r\n scope.sl = local_sl\r\n scope.tp = local_tp\r\n scope.tp_trl = local_tp_trl\r\n scope.tm = local_tm\r\n scope.coin = local_currency\r\n\r\n scope.clear = false\r\n scope.sav = true\r\n scope.m15 = true\r\n scope.m30 = false\r\n scope.h1 = false\r\n scope.h2 = false\r\n scope.exchange = \"Gate.io\"\r\n\r\n scope.change_radio = function(){\r\n scope.send({topic: 'Exchange', payload: scope.exchange})\r\n }\r\n\r\n // Clear form\r\n scope.clear_form = function() {\r\n // if (scope.clear === true) {\r\n local_amt = ''\r\n local_sl_trl = ''\r\n local_sl = ''\r\n local_tp = ''\r\n local_tp_trl = ''\r\n local_tm = ''\r\n local_currency = ''\r\n\r\n showChange()\r\n // }\r\n }\r\n \r\n scope.tdv = function() {\r\n scope.send({topic: 'tdv', payload:{m15:scope.m15, m30:scope.m30, h1:scope.h1, h2:scope.h2}})\r\n\r\n }\r\n\r\n scope.$watch('msg', function(msg) {\r\n // No error checking for properties\r\n if(msg) {\r\n local_amt = msg.payload.amt\r\n local_sl_trl = msg.payload.sl_trl\r\n local_sl = msg.payload.sl\r\n local_tp = msg.payload.tp\r\n local_tp_trl = msg.payload.tp_trl\r\n local_tm = msg.payload.tm\r\n scope.clear = msg.payload.clear\r\n scope.exchange = msg.payload.exchange\r\n scope.m15 = msg.payload.m15\r\n\r\n // Set to false so any incoming msg does not action following function\r\n msg.payload.sav = false \r\n\r\n showChange()\r\n\r\n scope.send(msg)\r\n }\r\n })\r\n \r\n // Update the scope variables to reflect back to the HTML\r\n function showChange() {\r\n scope.amt = local_amt\r\n scope.sl_trl = local_sl_trl\r\n scope.sl = local_sl\r\n scope.tp = local_tp\r\n scope.tp_trl = local_tp_trl\r\n scope.tm = local_tm\r\n scope.currency = local_currency\r\n \r\n }\r\n"},{"id":"101683f3a5931d3a","type":"ui_group","name":"Last","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}]

```

---

<div class="post-metadata">

**Author:** ![interscope101](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@interscope101](https://discourse.nodered.org/u/interscope101)\
**Post date:** [13 November 2022 23:10 UTC](https://discourse.nodered.org/t/multi-state-switch-passthrough-msg-parts/70069/33 "2022-11-13T23:10:56Z")

</div>

Here is are the 4 duplicates I get on initial load or manual reset (same thing)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/c/5c0c052e98e2f56ad35a206e2277fbcd1ff95d62.png)

Here is the config (default injects, input) that just generated that

```auto
[
    {
        "id": "a2a981a7f41d5620",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "af944d3c015db054",
        "type": "inject",
        "z": "a2a981a7f41d5620",
        "name": "RESET",
        "props": [],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "x": 490,
        "y": 420,
        "wires": [
            [
                "b299256510eeffc7"
            ]
        ]
    },
    {
        "id": "be23ea8f35736f10",
        "type": "ui_button",
        "z": "a2a981a7f41d5620",
        "name": "",
        "group": "085d7feec44f7e35",
        "order": 13,
        "width": "1",
        "height": "1",
        "passthru": false,
        "label": "RESET",
        "tooltip": "",
        "color": "#ccc",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "{\"flag\":\"reset\"}",
        "payloadType": "json",
        "topic": "",
        "topicType": "str",
        "x": 490,
        "y": 340,
        "wires": [
            [
                "b299256510eeffc7"
            ]
        ]
    },
    {
        "id": "b299256510eeffc7",
        "type": "change",
        "z": "a2a981a7f41d5620",
        "name": "dfl",
        "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": "2",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.sl",
                "pt": "msg",
                "to": "3",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.sl_trl",
                "pt": "msg",
                "to": "1",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.tm",
                "pt": "msg",
                "to": "2",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.sav",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.state",
                "pt": "msg",
                "to": "M",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.currency",
                "pt": "msg",
                "to": "SOL",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.exchange",
                "pt": "msg",
                "to": "Gate.io",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.m15",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.m30",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.h1",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.h2",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.real",
                "pt": "msg",
                "to": "#:(file)::real",
                "tot": "flow"
            },
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "reset",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 490,
        "y": 380,
        "wires": [
            [
                "c665e247692129fd",
                "4bd4f21efc1d71ad",
                "92eabe42b0a2297e"
            ]
        ]
    },
    {
        "id": "30696f8dfa29cdc4",
        "type": "function",
        "z": "a2a981a7f41d5620",
        "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, m15, m30, h1, h2, 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, is15m, is30m, is1h, is2h, TP, SL, TMO, TPT, SLT\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 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 flow.set('tp_trl_s', tp_trl_s);\n\n if ( sl && sl > 0 && sl < 6 ) {\n flow.set('sl', sl);\n sl_s = true;\n } else {\n sl = null;\n 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);\n sl_trl_s = true;\n } else {\n sl_trl = null;\n 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)\n tm_s = true;\n\n } else {\n tm = null;\n tm_s = false;\n }\n flow.set('tm_s', tm_s);\n\n }\n\n\n if (flow.get('tp_trl_s')) {TPT = \":\"+flow.get('tp_trl')} else {TPT = \"\"}\n if (flow.get('sl_trl_s')) {SLT = \":\"+flow.get('sl_trl')} else {SLT = \"\"}\n \n if (flow.get('tp_s')) {TP = \" P \"+flow.get('tp') +TPT+\" |\"} else {TP = \"\"}\n if (flow.get('sl_s')) {SL = \" L \"+flow.get('sl') +SLT+\" |\"} else {SL = \"\"}\n if (flow.get('tm_s')) {TMO = \" T \"+flow.get('tm') +\" |\"} else {TMO = \"\"}\n \n \n msg.payload = \"$\"+ flow.get('amt') + \" |\"+ TP + SL + TMO + \" \"+flow.get('rl', 'file')\n \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('rl')}`\n msg.color = \"#fd9795\"\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 flow.set('tp_s_a', tp_s_a, 'file')\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 flow.set('tp_trl_s_a', tp_trl_s_a, 'file')\n\n if ( sl && sl > 0 && sl < 6 ) {\n flow.set('sl_a', sl, 'file'); sl_s_a = true;\n } else {\n sl_a = null; sl_s_a = false;\n }\n flow.set('sl_s_a', sl_s_a, 'file')\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 flow.set('sl_trl_s_a', sl_trl_s_a, 'file')\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 flow.set('tm_s_a', tm_s_a, 'file')\n\n }\n\n\n if (flow.get('tp_trl_s_a', 'file')) {TPT = \":\"+flow.get('tp_trl_a', 'file')} else {TPT = \"\"}\n if (flow.get('sl_trl_s_a', 'file')) {SLT = \":\"+flow.get('sl_trl_a', 'file')} else {SLT = \"\"}\n \n if (flow.get('tp_s_a', 'file')) {TP = \" P \"+flow.get('tp_a', 'file') +TPT+\" |\"} else {TP = \"\"}\n if (flow.get('sl_s_a', 'file')) {SL = \" L \"+flow.get('sl_a', 'file') +SLT+\" |\"} else {SL = \"\"}\n if (flow.get('tm_s_a', 'file')) {TMO = \" T \"+flow.get('tm_a', 'file') +\" |\"} else {TMO = \"\"}\n \n \n msg.payload = \"$\"+ flow.get('amt_a', 'file') + \" |\"+ TP + SL + TMO + \" \"+flow.get('rl_a', 'file')\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('rl_a')}`\n msg.color = \"#fdef55\"\n\n} else if (flow.get('state') === \"E\") {\n if (sav) {\n flow.set('tp', undefined); flow.set('tp_a', undefined, 'file')\n flow.set('tp_s', undefined); flow.set('tp_s_a', undefined, 'file') \n flow.set('tp_trl', undefined); flow.set('tp_trl_a', undefined, 'file') \n flow.set('tp_trl_s', undefined); flow.set('tp_trl_s_a', undefined, 'file')\n \n flow.set('sl', undefined); flow.set('sl_a', undefined, 'file')\n flow.set('sl_s', undefined); flow.set('sl_s_a', undefined, 'file')\n flow.set('sl_trl', undefined); flow.set('sl_trl_a', undefined, 'file')\n flow.set('sl_trl_s', undefined); flow.set('sl_trl_s_a', undefined, 'file')\n \n flow.set('tm', undefined); flow.set('tm_a', undefined, 'file')\n flow.set('tm_s', undefined); flow.set('tm_s_a', undefined, 'file')\n \n } \n msg.payload = \" **ERASE ALL** \"\n msg.color = \"red\"\n}\n\n\nif (clear === true) { \n msg.payload = \"\"\n\n}\n\nreturn msg\n\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 740,
        "y": 360,
        "wires": [
            [
                "2137beab2b7a27de"
            ]
        ]
    },
    {
        "id": "2137beab2b7a27de",
        "type": "ui_text",
        "z": "a2a981a7f41d5620",
        "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": 920,
        "y": 360,
        "wires": []
    },
    {
        "id": "4bd4f21efc1d71ad",
        "type": "ui_multistate_switch",
        "z": "a2a981a7f41d5620",
        "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": "<i class=\"fa fa-square-o\" style=\"color:red !important\"></i>",
                "value": "E",
                "valueType": "str",
                "color": "#ff0000"
            },
            {
                "label": "&nbsp;",
                "value": "y",
                "valueType": "str",
                "color": "#1e2223"
            },
            {
                "label": "<i class=\"fa fa-list-ul\" aria-hidden=\"true\"></i>",
                "value": "M",
                "valueType": "str",
                "color": "#0042ad"
            },
            {
                "label": "<i class=\"fa fa-database\"></i>",
                "value": "A",
                "valueType": "str",
                "color": "#0042ad"
            }
        ],
        "topic": "mode",
        "x": 740,
        "y": 400,
        "wires": [
            [
                "30696f8dfa29cdc4"
            ]
        ]
    },
    {
        "id": "92eabe42b0a2297e",
        "type": "ui_multistate_switch",
        "z": "a2a981a7f41d5620",
        "name": "real",
        "group": "085d7feec44f7e35",
        "order": 4,
        "width": "1",
        "height": "1",
        "label": "",
        "stateField": "payload.real",
        "enableField": "enable",
        "passthroughField": "passthrough",
        "inputMsgField": "inputmsg",
        "rounded": true,
        "useThemeColors": false,
        "hideSelectedLabel": false,
        "multilineLabel": false,
        "passThrough": "always",
        "inputMsg": "all",
        "userInput": "enabled_show",
        "options": [
            {
                "label": "⇊",
                "value": "mP_aP",
                "valueType": "str",
                "color": "#ff0000"
            },
            {
                "label": "⇅",
                "value": "mR_aP",
                "valueType": "str",
                "color": "#4581a5"
            },
            {
                "label": "⇵",
                "value": "mP_aR",
                "valueType": "str",
                "color": "#4581a5"
            },
            {
                "label": "⇈",
                "value": "mR_aR",
                "valueType": "str",
                "color": "#008502"
            }
        ],
        "topic": "real",
        "x": 740,
        "y": 440,
        "wires": [
            [
                "b45a5d8711ee43ed"
            ]
        ]
    },
    {
        "id": "b45a5d8711ee43ed",
        "type": "change",
        "z": "a2a981a7f41d5620",
        "name": "real",
        "rules": [
            {
                "t": "set",
                "p": "#:(file)::real",
                "pt": "flow",
                "to": "payload.real",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 740,
        "y": 480,
        "wires": [
            [
                "f2a035278dbdbe9a"
            ]
        ]
    },
    {
        "id": "c665e247692129fd",
        "type": "ui_template",
        "z": "a2a981a7f41d5620",
        "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 layout=\"row\">\n <div style=\"margin: 0px 0px 0px 2px\" id=\"regular_plus\"><md-button class=\"remote-button\" style=\"min-width:30px !important; width:30px !important;\" ng-click=\"clear_form()\"><span style=\"font-size:13px !important; color:{{msg.colour}}\" class=\"fa fa-superpowers\"> </span></md-button></div> \n <div style=\"margin:20px 0px 0px 20px\" 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>\n\n <div style=\"margin-top: 5px\" layout=\"row\">\n <div style=\"margin-top:15px\" flex=\"30\"> <md-radio-group ng-model=\"exchange\" ng-change=\"changeradio()\" ng-init=\"exchange='Gate.io'\">\n <md-radio-button ng-model=\"exchange.Paper\" value=\"Paper\" class=\"md-primary\">P</md-radio-button>\n <md-radio-button ng-model=\"exchange.Binance\" value=\"Binance\" class=\"md-primary\">B</md-radio-button>\n <md-radio-button ng-model=\"exchange.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=\"60\">\n <div flex=\"\" style =\"text-align:center; margin-top:10px; margin-left:58px;\"><md-input-container><input aria-label=\"currency\" ng-model=\"currency\"></md-input-container></div>\n <div flex=\"\" style =\"margin-top:-5px; margin-left:50px; \"><md-button aria-label=\"load\" class=\"md-accent md-hue-2 md-raised\" ng-click=\"send({topic: 'load', payload:{exchange:exchange, currency:currency}})\">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=\"margin-left:30px\"><md-checkbox ng-model=\"clear\" ng-disabled=\"true\" ng-change = \"clear_form()\" aria-label=\"clear\"></md-checkbox></div>\n </div>\n <div style=\"margin-right: 35px; margin-left:10px;margin-top:-13px\"><md-checkbox ng-model=\"sav\" aria-label=\"sav\"><i class=\"fa fa-unlock-alt\" aria-hidden=\"true\"></i></md-checkbox></div> \n </div>\n <div style=\"margin-left:20px\" flex=\"45\" layout=\"column\">\n <div style=\"margin:10px 0px 0px 15px; text-align:center\"><md-input-container><input aria-label=\"amt\" ng-model=\"amt\"></md-input-container></div>\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_currency\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_currency\n scope.exchange = 'Gate.io'\n scope.clear = false\n scope.sav = true\n scope.m15 = true\n scope.m30 = false\n scope.h1 = false\n scope.h2 = false\n// scope.m15 = msg.payload.m15\n// scope.m30 = msg.payload.m30\n// scope.h1 = msg.payload.h1\n// scope.h2 = msg.payload.h2\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_currency = ''\n\n showChange()\n // }\n }\n \n scope.tdv = function(boxChecked) {\n scope.send({topic: 'tdv', payload:{m15:scope.m15, m30:scope.m30, h1:scope.h1, h2:scope.h2}})\n\n }\n \n scope.change_radio = function(){ \n scope.send({topic: 'Exchange', payload: scope.exchange})\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 scope.m15 = msg.payload.m15\n scope.exchange = msg.payload.exchange\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.currency = local_currency\n \n }\n\n\n})(scope);\n</script>",
        "storeOutMessages": false,
        "fwdInMessages": true,
        "resendOnRefresh": false,
        "templateScope": "local",
        "className": "setbox",
        "x": 740,
        "y": 320,
        "wires": [
            [
                "30696f8dfa29cdc4",
                "a778899025c99839"
            ]
        ]
    },
    {
        "id": "f2a035278dbdbe9a",
        "type": "link out",
        "z": "a2a981a7f41d5620",
        "name": "link out 41",
        "mode": "link",
        "links": [],
        "x": 835,
        "y": 480,
        "wires": []
    },
    {
        "id": "a778899025c99839",
        "type": "debug",
        "z": "a2a981a7f41d5620",
        "name": "debug 3",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 930,
        "y": 300,
        "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
    }
]

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/c/2cc157c8198e2e6fe253b538c7bad8d8e00143d3.png)

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [14 November 2022 20:12 UTC](https://discourse.nodered.org/t/multi-state-switch-passthrough-msg-parts/70069/34 "2022-11-14T20:12:31Z")

</div>

I only got 2 copies, but it is because you are sending the dfl msg to both INPUT & mode. Set the `mode node` to `Passthrough 'Never'` (Probably also do the same for the `real node`)

---

<div class="post-metadata">

**Author:** ![interscope101](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@interscope101](https://discourse.nodered.org/u/interscope101)\
**Post date:** [14 November 2022 20:36 UTC](https://discourse.nodered.org/t/multi-state-switch-passthrough-msg-parts/70069/35 "2022-11-14T20:36:11Z")

</div>

Made no difference. Did you try?

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [14 November 2022 22:38 UTC](https://discourse.nodered.org/t/multi-state-switch-passthrough-msg-parts/70069/36 "2022-11-14T22:38:14Z")

</div>

I did and it worked with the flow extract you provided. (as I said, I only had 2 repeats, 1 from INPUT & 1 from mode)

Check the output from mode on reset with a debug node

---

<div class="post-metadata">

**Author:** ![interscope101](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@interscope101](https://discourse.nodered.org/u/interscope101)\
**Post date:** [15 November 2022 04:35 UTC](https://discourse.nodered.org/t/multi-state-switch-passthrough-msg-parts/70069/37 "2022-11-15T04:35:12Z")

</div>

After turning off pass-through on all the switches I end up with 2 (down from 4) - debug showing nothing coming out of switches. What's odd is that on initialization there 1 msg, but with manual inject there are 2 - yet it's the same node. Found a "de-duplicate node" that seems to solve the problem, but a mystery.

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [17 November 2022 01:14 UTC](https://discourse.nodered.org/t/multi-state-switch-passthrough-msg-parts/70069/38 "2022-11-17T01:14:11Z")

</div>

> [@Buckskin](#):
>
> ```auto
> if (msg.topic === "mode" || msg.topic === 'reset') {
> flow.set('state', state);
> }
> 
> ```

Another option, instead of the above

```auto
if (msg.topic === 'reset') {
    msg.payload = {}    

    return
}

```

---

<div class="post-metadata">

**Author:** ![interscope101](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@interscope101](https://discourse.nodered.org/u/interscope101)\
**Post date:** [17 November 2022 02:32 UTC](https://discourse.nodered.org/t/multi-state-switch-passthrough-msg-parts/70069/39 "2022-11-17T02:32:17Z")

</div>

Thanks. One thing that I still can't get working right is the default mode. The switch does get set to "M" "visually" but the text display shows "A" set ... and I think the state is actually not defined at this point.

```auto
/**
 * 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, m15, m30, h1, h2, sav, clear = false} = msg.payload
let 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, is15m, is30m, is1h, is2h, TP, SL, TMO, TPT, SLT

let topic = msg.topic

let real = flow.get('real', 'file')

if (real === "mP_aP") {rl = "*"; rl_a = "*"} else  
if (real === "mR_aP") {rl = "R"; rl_a = "*"} else   
if (real === "mP_aR") {rl = "*"; rl_a = "R"} else  
if (real === "mR_aR") {rl = "R"; rl_a = "R"}  

flow.set('rl', rl, 'file'); flow.set('rl_a', rl_a, 'file')

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

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

    // If SET Button pressed
    if (sav) {

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

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

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

        if ( sl && sl > 0 && sl < 6 ) {
            flow.set('sl', sl);
            sl_s = true;
        } else {
            sl = null;
            sl_s = false;
        }
        flow.set('sl_s', sl_s);

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

        if ( tm && tm > 0 && tm < 4 ) {
            flow.set('tm', tm)
            tm_s = true;

        } else {
            tm = null;
            tm_s = false;
        }
        flow.set('tm_s', tm_s);

    }

    if (flow.get('tp_trl_s')) {TPT = ":"+flow.get('tp_trl')} else {TPT = ""}
    if (flow.get('sl_trl_s')) {SLT = ":"+flow.get('sl_trl')} else {SLT = ""}
    
    if (flow.get('tp_s')) {TP = " P "+flow.get('tp') +TPT+" |"} else {TP = ""}
    if (flow.get('sl_s')) {SL = " L "+flow.get('sl') +SLT+" |"} else {SL = ""}
    if (flow.get('tm_s')) {TMO = " T "+flow.get('tm') +" |"} else {TMO = ""}
     
    
    msg.payload = "$"+ flow.get('amt') + " |"+ TP + SL + TMO + " "+flow.get('rl', 'file')
  

// 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('rl')}`
    msg.color = "#fd9795"

} 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'); tp_s_a = true;
        } else {
            tp_a = null; tp_s_a = false;
        }
        flow.set('tp_s_a', tp_s_a, 'file')

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

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

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

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

    }

    if (flow.get('tp_trl_s_a', 'file')) {TPT = ":"+flow.get('tp_trl_a', 'file')} else {TPT = ""}
    if (flow.get('sl_trl_s_a', 'file')) {SLT = ":"+flow.get('sl_trl_a', 'file')} else {SLT = ""}
    
    if (flow.get('tp_s_a', 'file')) {TP = " P "+flow.get('tp_a', 'file') +TPT+" |"} else {TP = ""}
    if (flow.get('sl_s_a', 'file')) {SL = " L "+flow.get('sl_a', 'file') +SLT+" |"} else {SL = ""}
    if (flow.get('tm_s_a', 'file')) {TMO = " T "+flow.get('tm_a', 'file') +" |"} else {TMO = ""}
     
    
    msg.payload = "$"+ flow.get('amt_a', 'file') + " |"+ TP + SL + TMO + " "+flow.get('rl_a', 'file')

// 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('rl_a')}`
    msg.color = "#fdef55"

} else if (flow.get('state') === "E") {
    if (sav) {
     flow.set('tp', undefined); flow.set('tp_a', undefined, 'file')
     flow.set('tp_s', undefined); flow.set('tp_s_a', undefined, 'file') 
     flow.set('tp_trl', undefined); flow.set('tp_trl_a', undefined, 'file') 
     flow.set('tp_trl_s', undefined); flow.set('tp_trl_s_a', undefined, 'file')
     
    flow.set('sl', undefined); flow.set('sl_a', undefined, 'file')
    flow.set('sl_s', undefined); flow.set('sl_s_a', undefined, 'file')
    flow.set('sl_trl', undefined); flow.set('sl_trl_a', undefined, 'file')
    flow.set('sl_trl_s', undefined); flow.set('sl_trl_s_a', undefined, 'file')
    
    flow.set('tm', undefined); flow.set('tm_a', undefined, 'file')
    flow.set('tm_s', undefined); flow.set('tm_s_a', undefined, 'file')
        
    }    
     msg.payload = " **ERASE ALL**"
     msg.color = "blue"

    
} else if (flow.get('state') === "S") {
    
     msg.payload = " **SELL MODE**"
     msg.color = "red"
}

if (clear === true) { 
    msg.payload = ""

}

return msg

```

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [17 November 2022 20:28 UTC](https://discourse.nodered.org/t/multi-state-switch-passthrough-msg-parts/70069/40 "2022-11-17T20:28:29Z")

</div>

I thought that the default mode (or reset) should not show anything in the text node? With the previous addition to the function node the only time that text is displayed is once the Set command is given.

---

<div class="post-metadata">

**Author:** ![interscope101](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@interscope101](https://discourse.nodered.org/u/interscope101)\
**Post date:** [17 November 2022 21:01 UTC](https://discourse.nodered.org/t/multi-state-switch-passthrough-msg-parts/70069/41 "2022-11-17T21:01:39Z")

</div>

Really? The text is always displayed (maybe I missed that update) - as it should, since it gets default values (there is no need to set those). And since the mode switch defaults to "M" the text (and the state) should be consistent with that.

[Previous page](https://discourse.nodered.org/t/multi-state-switch-passthrough-msg-parts/70069.md?page=1)

[Next page](https://discourse.nodered.org/t/multi-state-switch-passthrough-msg-parts/70069.md?page=3)
