Hi there, I've been going in circles trying to get this (seemingly simple) config. I have a UI input template sending data to UI text node display. From the same input there is going to be two independent sets of data, one flow.set in memory (A) the other in filesystem (B) depending on a state of a toggle switch.
In other words if the switch is set in A position the data that's being entered/submitted is getting stored in set A and the UI text node is showing that set. You can toggle back and forth to see the two sets.
My approach was to place the switch before the function so the function receives both data and switch status to determine how to handle the data.
Everything is working EXCEPT I can't figure out how to combine/separate data and switch status msg. even though this multistate switch has a specific "state" field. The only way I can read it in the function is if it's set on "payload" but then it interferes with the input data. A different value frees up the data passthrough but then I can't find a way to read it.
Here is that piece of the flow but the function is blank (simper than the mess I have). Thank you guys!
[
{
"id": "d50cb6ebd3a83f2c",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "86adc926e9fd3301",
"type": "ui_template",
"z": "d50cb6ebd3a83f2c",
"group": "085d7feec44f7e35",
"name": "form",
"order": 10,
"width": "2",
"height": "3",
"format": "\n<div flex=\"\" style=\"margin 3px 0px 0px 7px\" layout=\"row\">\n\n<div flex=\"35\" style=\"padding:0 5px\"> \n <div layout=\"column\">\n <div><md-input-container><input aria-label=\"amt\" ng-model=\"amt\"></md-input-container></div> \n <div layout=\"row\">\n <div style =\"margin-left:-13px\"><md-checkbox ng-model=\"aut\" aria-label=\"aut\"></md-checkbox></div> \n <div style =\"margin-left:13px\"><md-checkbox ng-model=\"sl_trl\" aria-label=\"sl_trl\">🡅</md-checkbox></div> \n </div>\n </div> \n </div>\n\n<div flex=\"15\" style=\"padding:0 5px\"> \n\n <div style=\"text-align:center\"><md-input-container><input ng-model=\"sl\" aria-label=\"sl\"><span class=mylabel>SL</span></md-input-container></div>\n\n</div>\n\n<div flex=\"20\" style=\"padding:0 5px\"> \n\n <div style=\"text-align:center\"><md-input-container><input ng-model=\"tp\" aria-label=\"tp\"><span class=mylabel>TP</span></md-input-container></div> \n</div>\n<div flex=\"15\" style=\"padding:0 5px\">\n\n <div style=\"text-align:center\"><md-input-container><input aria-label=\"tp_trl\" ng-model=\"tp_trl\"><span class=mylabel>TR</span></md-input-container></div> \n\n</div>\n<div flex=\"15\" style=\"padding:0 5px\">\n\n <div style=\"text-align:center\"><md-input-container><input aria-label=\"tm\" ng-model=\"tm\"><span class=mylabel>T</span></md-input-container></div> \n\n</div>\n\n</div>\n\n<div flex=\"\" layout=\"row\">\n <div flex=\"40\" id=\"regular_plus\" style = \"margin-left:2px; padding: 0px 5x;\" ><md-button class=\"md-button remote-button\"><span style=\"color:{{msg.colour}}\" class=\"fa fa-repeat\"> </span></md-button></div>\n <div flex=\"60\" style = \"text-align:center; margin: 0px 5px 0px 10px; padding-left: 7px;\"><md-button aria-label=\"set\" class=\"md-accent md-hue-2 md-raised\" ng-click=\"send({payload:{amt:amt, aut:aut, sl_trl:sl_trl, sl:sl, tp:tp, tp_trl:tp_trl, tm:tml}})\">SET</md-button></div>\n</div>\n\n<script>\n\n(function($scope) {\n \n$('#regular_plus').on('click', function(e) {\n e.preventDefault(); //prevent default behavior\n $scope.send({\"topic\":\"regular_plus\",\"payload\": \"vol-up\"});\n});\n \n})(scope);\n</script>",
"storeOutMessages": false,
"fwdInMessages": true,
"resendOnRefresh": false,
"templateScope": "local",
"className": "setbox",
"x": 490,
"y": 320,
"wires": [
[
"fbc2463f5e25697a"
]
]
},
{
"id": "fbc2463f5e25697a",
"type": "ui_multistate_switch",
"z": "d50cb6ebd3a83f2c",
"name": "multi-switch",
"group": "085d7feec44f7e35",
"order": 6,
"width": "1",
"height": "1",
"label": "",
"stateField": "state",
"enableField": "enable",
"passthroughField": "passthrough",
"inputMsgField": "inputmsg",
"rounded": true,
"useThemeColors": false,
"hideSelectedLabel": false,
"multilineLabel": false,
"passThrough": "always",
"inputMsg": "all",
"userInput": "enabled_show",
"options": [
{
"label": " ",
"value": "x",
"valueType": "str",
"color": "#1e2223"
},
{
"label": "A",
"value": "A",
"valueType": "str",
"color": "#0042ad"
},
{
"label": " ",
"value": "y",
"valueType": "str",
"color": "#1e2223"
},
{
"label": "M",
"value": "M",
"valueType": "str",
"color": "#ff0000"
}
],
"topic": "switch",
"x": 630,
"y": 320,
"wires": [
[
"573015edc6bb81f1"
]
]
},
{
"id": "573015edc6bb81f1",
"type": "function",
"z": "d50cb6ebd3a83f2c",
"name": "function 1",
"func": "\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 780,
"y": 320,
"wires": [
[
"3941c8d39fb0b5e2"
]
]
},
{
"id": "deea311bab3c6bc3",
"type": "change",
"z": "d50cb6ebd3a83f2c",
"name": "defaults",
"rules": [
{
"t": "set",
"p": "payload.amt",
"pt": "msg",
"to": "20",
"tot": "str"
},
{
"t": "set",
"p": "payload.sl",
"pt": "msg",
"to": "3",
"tot": "str"
},
{
"t": "set",
"p": "payload.tp",
"pt": "msg",
"to": "5",
"tot": "str"
},
{
"t": "set",
"p": "payload.tp_trl",
"pt": "msg",
"to": "",
"tot": "str"
},
{
"t": "set",
"p": "payload.sl_trl",
"pt": "msg",
"to": "true",
"tot": "bool"
},
{
"t": "set",
"p": "payload.tm",
"pt": "msg",
"to": "1",
"tot": "str"
},
{
"t": "set",
"p": "payload.aut",
"pt": "msg",
"to": "false",
"tot": "bool"
},
{
"t": "set",
"p": "payload.flag",
"pt": "msg",
"to": "set",
"tot": "str"
},
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "set",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 370,
"y": 320,
"wires": [
[
"86adc926e9fd3301"
]
]
},
{
"id": "3941c8d39fb0b5e2",
"type": "ui_text",
"z": "d50cb6ebd3a83f2c",
"group": "085d7feec44f7e35",
"order": 3,
"width": "2",
"height": "1",
"name": "display",
"label": "",
"format": "<font color= {{msg.color}} > {{msg.payload}} </font>",
"layout": "row-spread",
"className": "values",
"x": 910,
"y": 320,
"wires": []
},
{
"id": "085d7feec44f7e35",
"type": "ui_group",
"name": "LEFT",
"tab": "7e13e6107768d821",
"order": 3,
"disp": false,
"width": "4",
"collapse": false,
"className": ""
},
{
"id": "7e13e6107768d821",
"type": "ui_tab",
"name": "CRYPTO",
"icon": "dashboard",
"order": 2,
"disabled": false,
"hidden": false
}
]