It should be that:
[
{
"id": "ee8099c2e47c91c1",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "2b60c3632b00a3c1",
"type": "ui_template",
"z": "ee8099c2e47c91c1",
"group": "589e25a60e4fbcd4",
"name": "3 Switches",
"order": 1,
"width": 0,
"height": 0,
"format": "<style>\n .sw md-switch.md-checked .md-thumb-container {\n transform: none !important;\n }\n\n .nr-dashboard-theme .nr-dashboard-template md-switch.md-checked:not([disabled]) .md-thumb {\n background-color: #ccc;\n }\n\n .nr-dashboard-theme .nr-dashboard-template md-switch .md-bar .myswitch {\n background-color: rgba(111, 111, 111, 0.5);\n display: none;\n }\n\n .nr-dashboard-theme .nr-dashboard-template md-switch.md-checked:not([disabled]) .md-thumb {\n background-color: #609f70;\n }\n\n .nr-dashboard-theme .nr-dashboard-template md-switch .md-bar {\n background-color: rgba(111, 111, 111, 0.5);\n display: none;\n }\n\n .sw md-switch .md-container {\n margin-right: 3px;\n width: 25px;\n }\n\n .nr-dashboard-theme .nr-dashboard-template md-switch .md-thumb {\n background-color: red;\n }\n\n md-switch {\n align-items: center;\n height: 30px;\n line-height: 18px;\n margin: 0px;\n margin-left: inherit;\n margin-right: 16px;\n }\n\n .sw md-switch .md-label {\n font-size: 13px;\n color: #728faa;\n letter-spacing: 1px;\n font-weight: bold;\n }\n\n md-switch .md-thumb .md-ripple-container {\n display: none;\n }\n</style>\n\n<div class=\"sw\" style=\"margin-top: 1px\" layout=\"row\">\n <div style=\"margin-left: 7px\" ng-cloak>\n <md-switch id=\"C\" ng-model=\"data.c\" aria-label=\"C\" ng-true-value=\"'on'\" ng-false-value=\"'off'\"\n ng-change=\"onChange('c')\">C</md-switch>\n </div>\n <div style=\"margin-left: 7px\" ng-cloak>\n <md-switch id=\"B\" ng-model=\"data.b\" aria-label=\"B\" ng-true-value=\"'on'\" ng-false-value=\"'off'\"\n ng-change=\"onChange('b')\">B</md-switch>\n </div>\n <div style=\"margin-left: 5px\" ng-cloak>\n <md-switch id=\"G\" ng-model=\"data.g\" aria-label=\"G\" ng-true-value=\"'on'\" ng-false-value=\"'off'\"\n ng-change=\"onChange('g')\">G</md-switch>\n </div>\n <div style=\"margin-left: 15px\" ng-cloak>\n <md-switch id=\"S\" ng-model=\"data.s\" aria-label=\"G\" ng-true-value=\"'on'\" ng-false-value=\"'off'\"\n ng-change=\"onChange('s')\">SIM</md-switch>\n </div>\n\n</div>\n\n<script>\n (function(scope) {\n scope.data = {\n c: 'off',\n b: 'off',\n g: 'off',\n s: 'off'\n };\n\n scope.onChange = function(key) {\n scope.send({topic:'switch', payload:scope.data, keys:[key]});\n };\n \n //handle arriving messages\n scope.$watch('msg', function(msg) {\n if(msg !== undefined && msg !== null){\n try{\n switch(msg.topic) {\n case \"remote\":\n let keys = [];\n Object.keys(msg.payload).forEach((element)=>{\n keys.push(element);\n scope.data[element] = msg.payload[element];\n })\n scope.send({topic:'switch', payload:scope.data, keys:keys});\n break;\n case \"switch\":\n Object.keys(msg.payload).forEach((element)=>{\n scope.data[element] = msg.payload[element];\n })\n break;\n default:\n break;\n }\n }catch(err){\n console.error(err);\n }\n }\n });\n })(scope);\n</script>",
"storeOutMessages": true,
"fwdInMessages": false,
"resendOnRefresh": true,
"templateScope": "local",
"className": "",
"x": 830,
"y": 460,
"wires": [
[
"44d0a7ae835a5465"
]
]
},
{
"id": "d1c52a884a979ca7",
"type": "ui_button",
"z": "ee8099c2e47c91c1",
"name": "",
"group": "2cad8ed8b01011d8",
"order": 0,
"width": 0,
"height": 0,
"passthru": false,
"label": "button",
"tooltip": "",
"color": "",
"bgcolor": "",
"className": "",
"icon": "",
"payload": "",
"payloadType": "str",
"topic": "topic",
"topicType": "msg",
"x": 1630,
"y": 120,
"wires": [
[]
]
},
{
"id": "d3b058c0990ce6de",
"type": "inject",
"z": "ee8099c2e47c91c1",
"name": "Switch all",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "remote",
"payload": "{\"c\":\"off\",\"b\":\"on\",\"g\":\"on\",\"s\":\"off\"}",
"payloadType": "json",
"x": 380,
"y": 460,
"wires": [
[
"2b60c3632b00a3c1"
]
]
},
{
"id": "3d794b2f2131b5b4",
"type": "debug",
"z": "ee8099c2e47c91c1",
"name": "msgBSend",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1430,
"y": 340,
"wires": []
},
{
"id": "18b67b41f34d8625",
"type": "function",
"z": "ee8099c2e47c91c1",
"name": "function 1",
"func": "\nlet msgBSend = {}; \nlet msgBGate = {}; \nlet msgGSend = {}; \nlet msgGGate = {}; \nlet msgS = {}; \nlet msgCGate = {};\n\nmsgBGate.topic = \"control\"\nmsgGGate.topic = \"control\"\nmsgCGate.topic = \"control\"\n\nif (msg.payload.b == \"on\") {\n\n msgBSend.payload = \"alwaysResendValue\"\n msgBSend.resend_force = true\n msgBSend.resend_ignore = false\n msgBSend.resend_interval = parseFloat(flow.get('freq')) * 60\n\n msgBGate.payload = \"queue\"\n\n\n} else\n\n if (msg.payload.b == \"off\") {\n\n msgBSend.resend_messages = false\n msgBSend.resend_ignore = true\n\n msgBGate.payload = \"close\"\n\n\n } else\n\n if (msg.payload.g == \"on\") {\n\n msgGSend.payload = \"alwaysResendValue\"\n msgGSend.resend_force = true\n msgGSend.resend_ignore = false\n msgGSend.resend_interval = parseFloat(flow.get('freq')) * 60\n\n msgGGate.payload = \"queue\"\n\n\n } else\n\n if (msg.payload.g == \"off\") {\n\n msgGSend.resend_messages = false\n msgGSend.resend_ignore = true\n\n msgGGate.payload = \"close\"\n\n\n } else\n\n if (msg.payload.s == \"on\") {\n\n msgS.payload = true\n\n } else if\n\n (msg.payload.s == \"off\") {\n\n msgS.payload = false\n\n\n } else if\n\n (msg.payload.c == \"on\") {\n\n msgCGate.payload = \"open\"\n\n } else if\n\n (msg.payload.c == \"off\") {\n\n msgCGate.payload = \"close\"\n\n }\n\n//return [msgBSend, msgBGate, msgGSend, msgGGate, msgS, msgCGate];\n",
"outputs": 6,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1180,
"y": 460,
"wires": [
[
"3d794b2f2131b5b4"
],
[
"e0905309cf9ffcb4"
],
[
"343330fb1acf23de"
],
[
"03fd276c98a1b3bb"
],
[
"68d9272c615d5471"
],
[
"078d4fc1e511e860"
]
]
},
{
"id": "e0905309cf9ffcb4",
"type": "debug",
"z": "ee8099c2e47c91c1",
"name": "msgBGate",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1430,
"y": 380,
"wires": []
},
{
"id": "343330fb1acf23de",
"type": "debug",
"z": "ee8099c2e47c91c1",
"name": "msgGSend",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1430,
"y": 420,
"wires": []
},
{
"id": "03fd276c98a1b3bb",
"type": "debug",
"z": "ee8099c2e47c91c1",
"name": "msgGGate",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1430,
"y": 460,
"wires": []
},
{
"id": "68d9272c615d5471",
"type": "debug",
"z": "ee8099c2e47c91c1",
"name": "msgS",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1410,
"y": 500,
"wires": []
},
{
"id": "078d4fc1e511e860",
"type": "debug",
"z": "ee8099c2e47c91c1",
"name": "msgCGate",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1430,
"y": 540,
"wires": []
},
{
"id": "44d0a7ae835a5465",
"type": "switch",
"z": "ee8099c2e47c91c1",
"name": "",
"property": "topic",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "switch",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 990,
"y": 460,
"wires": [
[
"18b67b41f34d8625",
"42babbf18e629479"
]
]
},
{
"id": "44f0e986cc1f44a6",
"type": "inject",
"z": "ee8099c2e47c91c1",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "b",
"payload": "on",
"payloadType": "str",
"x": 390,
"y": 380,
"wires": [
[
"86696ae4089992d9"
]
]
},
{
"id": "86696ae4089992d9",
"type": "change",
"z": "ee8099c2e47c91c1",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{\t topic:payload\t}",
"tot": "jsonata"
},
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "remote",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 630,
"y": 300,
"wires": [
[
"2b60c3632b00a3c1"
]
]
},
{
"id": "fe92bb87d069c48d",
"type": "inject",
"z": "ee8099c2e47c91c1",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "c",
"payload": "on",
"payloadType": "str",
"x": 390,
"y": 320,
"wires": [
[
"86696ae4089992d9"
]
]
},
{
"id": "3b646e91c80f71be",
"type": "inject",
"z": "ee8099c2e47c91c1",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "g",
"payload": "on",
"payloadType": "str",
"x": 390,
"y": 260,
"wires": [
[
"86696ae4089992d9"
]
]
},
{
"id": "3d0bb2a570294877",
"type": "inject",
"z": "ee8099c2e47c91c1",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "s",
"payload": "on",
"payloadType": "str",
"x": 390,
"y": 200,
"wires": [
[
"86696ae4089992d9"
]
]
},
{
"id": "42babbf18e629479",
"type": "debug",
"z": "ee8099c2e47c91c1",
"name": "debug 1",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1160,
"y": 280,
"wires": []
},
{
"id": "589e25a60e4fbcd4",
"type": "ui_group",
"name": "Group 1",
"tab": "29d816a6f2669734",
"order": 1,
"disp": true,
"width": 6
},
{
"id": "2cad8ed8b01011d8",
"type": "ui_group",
"name": "Group 1",
"tab": "fdade815ef4911c1",
"order": 1,
"disp": true,
"width": 6
},
{
"id": "29d816a6f2669734",
"type": "ui_tab",
"name": "Tab 1",
"icon": "dashboard",
"order": 1
},
{
"id": "fdade815ef4911c1",
"type": "ui_tab",
"name": "Tab 2",
"icon": "dashboard",
"order": 2
}
]