And the code:
[
{
"id": "ddcb9a8fa2a64d97",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "30bbe92eccf6533c",
"type": "ui-switch",
"z": "ddcb9a8fa2a64d97",
"name": "Main switch ",
"label": "Main switch",
"group": "563923e71d7c611b",
"order": 1,
"width": "4",
"height": "1",
"passthru": false,
"decouple": false,
"topic": "topic",
"topicType": "msg",
"style": "",
"className": "",
"layout": "row-spread",
"clickableArea": "switch",
"onvalue": "true",
"onvalueType": "bool",
"onicon": "",
"oncolor": "",
"offvalue": "false",
"offvalueType": "bool",
"officon": "",
"offcolor": "",
"x": 110,
"y": 100,
"wires": [
[]
]
},
{
"id": "c6695bcad5b82094",
"type": "ui-radio-group",
"z": "ddcb9a8fa2a64d97",
"group": "563923e71d7c611b",
"name": "On/Off Mode",
"label": "On/Off Mode",
"order": 2,
"width": "4",
"height": "1",
"columns": "3",
"passthru": false,
"options": [
{
"label": "Off",
"value": 0,
"type": "num"
},
{
"label": "SP 1",
"value": "1",
"type": "str"
},
{
"label": "SP 2",
"value": "2",
"type": "str"
},
{
"label": "Time schedule",
"value": "3",
"type": "str"
},
{
"label": "BMS",
"value": "4",
"type": "str"
}
],
"payload": "",
"topic": "topic",
"topicType": "msg",
"className": "",
"x": 110,
"y": 160,
"wires": [
[
"5d93b0b8f7ef96f1"
]
]
},
{
"id": "d3ac467fc898dde7",
"type": "ui-dropdown",
"z": "ddcb9a8fa2a64d97",
"group": "725eedac6f9efa62",
"name": "",
"label": "Select Mode:",
"tooltip": "",
"order": 1,
"width": "2",
"height": "1",
"passthru": false,
"multiple": false,
"chips": false,
"clearable": false,
"options": [
{
"label": "Off",
"value": 0,
"type": "num"
},
{
"label": "On Setpoint 1",
"value": 1,
"type": "num"
},
{
"label": "On Setpoint 2",
"value": 2,
"type": "num"
}
],
"payload": "",
"topic": "topic",
"topicType": "msg",
"className": "",
"typeIsComboBox": true,
"x": 110,
"y": 220,
"wires": [
[
"15eb70e47a885e8b"
]
]
},
{
"id": "9577911508f25647",
"type": "ui-dropdown",
"z": "ddcb9a8fa2a64d97",
"group": "725eedac6f9efa62",
"name": "Day of the week",
"label": "Select day of the week",
"tooltip": "",
"order": 2,
"width": "2",
"height": "1",
"passthru": false,
"multiple": true,
"chips": false,
"clearable": false,
"options": [
{
"label": "Mon",
"value": "Mon",
"type": "str"
},
{
"label": "Tue",
"value": "Tue",
"type": "str"
},
{
"label": "Wed",
"value": "Wed",
"type": "str"
},
{
"label": "Thur",
"value": "Thu",
"type": "str"
},
{
"label": "Fri",
"value": "Fri",
"type": "str"
},
{
"label": "Sat",
"value": "Sat",
"type": "str"
},
{
"label": "Sun",
"value": "Sun",
"type": "str"
}
],
"payload": "",
"topic": "topic",
"topicType": "msg",
"className": "",
"typeIsComboBox": true,
"x": 120,
"y": 260,
"wires": [
[
"ff8c1768fae7e6b0"
]
]
},
{
"id": "859d855337534b86",
"type": "ui-dropdown",
"z": "ddcb9a8fa2a64d97",
"group": "725eedac6f9efa62",
"name": "Hour",
"label": "Select hour",
"tooltip": "",
"order": 3,
"width": "2",
"height": "1",
"passthru": false,
"multiple": false,
"chips": false,
"clearable": false,
"options": [
{
"label": "0",
"value": 0,
"type": "num"
},
{
"label": "1",
"value": 1,
"type": "num"
},
{
"label": "2",
"value": 2,
"type": "num"
},
{
"label": "3",
"value": 3,
"type": "num"
},
{
"label": "4",
"value": 4,
"type": "num"
},
{
"label": "5",
"value": 5,
"type": "num"
},
{
"label": "6",
"value": 6,
"type": "num"
},
{
"label": "7",
"value": 7,
"type": "num"
},
{
"label": "8",
"value": 8,
"type": "num"
},
{
"label": "9",
"value": 9,
"type": "num"
},
{
"label": "10",
"value": 10,
"type": "num"
},
{
"label": "11",
"value": 11,
"type": "num"
},
{
"label": "12",
"value": 12,
"type": "num"
},
{
"label": "13",
"value": 13,
"type": "num"
},
{
"label": "14",
"value": 14,
"type": "num"
},
{
"label": "15",
"value": 15,
"type": "num"
},
{
"label": "16",
"value": 16,
"type": "num"
},
{
"label": "17",
"value": 17,
"type": "num"
},
{
"label": "18",
"value": 18,
"type": "num"
},
{
"label": "19",
"value": 19,
"type": "num"
},
{
"label": "20",
"value": 20,
"type": "num"
},
{
"label": "21",
"value": 21,
"type": "num"
},
{
"label": "22",
"value": 22,
"type": "num"
},
{
"label": "23",
"value": 23,
"type": "num"
}
],
"payload": "",
"topic": "topic",
"topicType": "msg",
"className": "",
"typeIsComboBox": true,
"x": 90,
"y": 300,
"wires": [
[
"4f0d65f1a1fc3301"
]
]
},
{
"id": "17b1e96da49fdaaa",
"type": "ui-dropdown",
"z": "ddcb9a8fa2a64d97",
"group": "725eedac6f9efa62",
"name": "Minutes",
"label": "Select minutes",
"tooltip": "",
"order": 4,
"width": "2",
"height": "1",
"passthru": false,
"multiple": false,
"chips": false,
"clearable": false,
"options": [
{
"label": "00",
"value": 0,
"type": "num"
},
{
"label": "15",
"value": 15,
"type": "num"
},
{
"label": "30",
"value": 30,
"type": "num"
},
{
"label": "45",
"value": 45,
"type": "num"
}
],
"payload": "",
"topic": "topic",
"topicType": "msg",
"className": "",
"typeIsComboBox": true,
"x": 100,
"y": 340,
"wires": [
[
"9bb20f32dd1a0b70"
]
]
},
{
"id": "15eb70e47a885e8b",
"type": "change",
"z": "ddcb9a8fa2a64d97",
"name": "Set mode variable",
"rules": [
{
"t": "set",
"p": "timer_mode",
"pt": "flow",
"to": "payload",
"tot": "msg"
},
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "timer_mode",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 330,
"y": 220,
"wires": [
[]
]
},
{
"id": "ff8c1768fae7e6b0",
"type": "change",
"z": "ddcb9a8fa2a64d97",
"name": "Set day variable",
"rules": [
{
"t": "set",
"p": "timer_days",
"pt": "flow",
"to": "payload",
"tot": "msg"
},
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "timer_day",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 320,
"y": 260,
"wires": [
[]
]
},
{
"id": "4f0d65f1a1fc3301",
"type": "change",
"z": "ddcb9a8fa2a64d97",
"name": "Set hours",
"rules": [
{
"t": "set",
"p": "timer_hours",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 300,
"y": 300,
"wires": [
[]
]
},
{
"id": "9bb20f32dd1a0b70",
"type": "change",
"z": "ddcb9a8fa2a64d97",
"name": "Set minutes",
"rules": [
{
"t": "set",
"p": "timer_minutes",
"pt": "flow",
"to": "payload",
"tot": "msg"
},
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "timer_minutes",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 310,
"y": 340,
"wires": [
[]
]
},
{
"id": "92c31bb665982dae",
"type": "function",
"z": "ddcb9a8fa2a64d97",
"name": "Calculate Payloads",
"func": "let topic = msg.topic\nlet payload = msg.payload;\nif (topic == \"export-all\") {\n let timer_qta = payload.result.length\n timer_qta++;\n flow.set(\"timer_no\",timer_qta);\n let cronDayString = \"\";\n let cronCode = [];\n let days = flow.get(\"timer_days\");\n\n for (let i = 0; i < days.length; i++) {\n if (i == 0) {\n cronDayString = days[0];\n } else {\n cronDayString = cronDayString + \",\" + days[i];\n }\n } \n let cronString = \"\" + flow.get(\"timer_minutes\") + \" \" + flow.get(\"timer_hours\") +\n \" * * \" + cronDayString;\n\n let newMsg = {payload:cronString};\n flow.set(\"timer_exp\",cronString)\n return [newMsg,null];\n} else {\n return [null,msg];\n}\n\n\n",
"outputs": 2,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 490,
"y": 380,
"wires": [
[
"622e301800b00253"
],
[]
]
},
{
"id": "f6d064dcef013879",
"type": "ui-button",
"z": "ddcb9a8fa2a64d97",
"group": "725eedac6f9efa62",
"name": "",
"label": "Add",
"order": 5,
"width": "1",
"height": "1",
"emulateClick": false,
"tooltip": "",
"color": "",
"bgcolor": "",
"className": "",
"icon": "",
"iconPosition": "left",
"payload": "1",
"payloadType": "num",
"topic": "export-all",
"topicType": "str",
"buttonColor": "#35bc3c",
"textColor": "",
"iconColor": "",
"enableClick": true,
"enablePointerdown": false,
"pointerdownPayload": "",
"pointerdownPayloadType": "str",
"enablePointerup": false,
"pointerupPayload": "",
"pointerupPayloadType": "str",
"x": 90,
"y": 380,
"wires": [
[
"c5b68b8851f7ad68"
]
]
},
{
"id": "c5b68b8851f7ad68",
"type": "cronplus",
"z": "ddcb9a8fa2a64d97",
"name": "",
"outputField": "payload",
"timeZone": "",
"storeName": "",
"commandResponseMsgOutput": "output1",
"defaultLocation": "",
"defaultLocationType": "default",
"outputs": 1,
"options": [],
"x": 300,
"y": 380,
"wires": [
[
"92c31bb665982dae"
]
]
},
{
"id": "622e301800b00253",
"type": "change",
"z": "ddcb9a8fa2a64d97",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{}",
"tot": "json"
},
{
"t": "set",
"p": "payload.expression",
"pt": "msg",
"to": "timer_exp",
"tot": "flow"
},
{
"t": "set",
"p": "payload.command",
"pt": "msg",
"to": "add",
"tot": "str"
},
{
"t": "set",
"p": "payload.type",
"pt": "msg",
"to": "str",
"tot": "str"
},
{
"t": "set",
"p": "payload.payload",
"pt": "msg",
"to": "timer_mode",
"tot": "flow"
},
{
"t": "set",
"p": "payload.name",
"pt": "msg",
"to": "timer_no",
"tot": "flow"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 710,
"y": 380,
"wires": [
[
"c5b68b8851f7ad68"
]
]
},
{
"id": "5d93b0b8f7ef96f1",
"type": "switch",
"z": "ddcb9a8fa2a64d97",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "neq",
"v": "3",
"vt": "num"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 290,
"y": 160,
"wires": [
[
"a3a5c26d658e4bca"
],
[
"3eb9aa88b1876c04"
]
]
},
{
"id": "a3a5c26d658e4bca",
"type": "change",
"z": "ddcb9a8fa2a64d97",
"name": "Disable/Enable Time schedule",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{\"group\":{\"disable\":[\"Time schedule\"]}}",
"tot": "json"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 530,
"y": 140,
"wires": [
[
"26121ae8a26dd1a2"
]
]
},
{
"id": "3eb9aa88b1876c04",
"type": "change",
"z": "ddcb9a8fa2a64d97",
"name": "Disable/Enable Time schedule",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{\"group\":{\"enable\":[\"Time schedule\"]}}",
"tot": "json"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 530,
"y": 180,
"wires": [
[
"26121ae8a26dd1a2"
]
]
},
{
"id": "26121ae8a26dd1a2",
"type": "ui-control",
"z": "ddcb9a8fa2a64d97",
"name": "",
"ui": "3fedce26f17c2af3",
"events": "all",
"x": 780,
"y": 160,
"wires": [
[]
]
},
{
"id": "563923e71d7c611b",
"type": "ui-group",
"name": "Main",
"page": "030442f538d24487",
"width": "4",
"height": "1",
"order": 1,
"showTitle": true,
"className": "",
"visible": "true",
"disabled": "false",
"groupType": "default"
},
{
"id": "725eedac6f9efa62",
"type": "ui-group",
"name": "Time schedule",
"page": "030442f538d24487",
"width": "8",
"height": "1",
"order": 2,
"showTitle": true,
"className": "",
"visible": "true",
"disabled": false,
"groupType": "default"
},
{
"id": "3fedce26f17c2af3",
"type": "ui-base",
"name": "AHU Controller",
"path": "/dashboard",
"appIcon": "",
"includeClientData": true,
"acceptsClientConfig": [
"ui-notification",
"ui-control"
],
"showPathInSidebar": false,
"showPageTitle": true,
"navigationStyle": "fixed",
"titleBarStyle": "fixed"
},
{
"id": "030442f538d24487",
"type": "ui-page",
"name": "Status",
"ui": "3fedce26f17c2af3",
"path": "/page1",
"icon": "home",
"layout": "flex",
"theme": "dc8d8991ed6af6a1",
"breakpoints": [
{
"name": "Default",
"px": "0",
"cols": "3"
},
{
"name": "Tablet",
"px": "576",
"cols": "6"
},
{
"name": "Small Desktop",
"px": "768",
"cols": "9"
},
{
"name": "Desktop",
"px": "1024",
"cols": "12"
}
],
"order": 1,
"className": "",
"visible": true,
"disabled": false
},
{
"id": "dc8d8991ed6af6a1",
"type": "ui-theme",
"name": "Default Theme",
"colors": {
"surface": "#ffffff",
"primary": "#0094ce",
"bgPage": "#eeeeee",
"groupBg": "#fde2fc",
"groupOutline": "#121212"
},
"sizes": {
"density": "comfortable",
"pagePadding": "12px",
"groupGap": "12px",
"groupBorderRadius": "4px",
"widgetGap": "12px"
}
}
]