Feedback for a flow

Hello everyone,
I am new to Node-RED and recently created a flow for controlling shellies via a dashboard.
Since I have nobody I could get some feedback from, I thought to come here and share my flow.

I was specifically looking for a better way to add the seperate buttons, since I am currently adding a new group for each unit.

Thanks in advance
-Jan

[
    {
        "id": "53dea74fb60818b9",
        "type": "subflow",
        "name": "Shellyinfo",
        "info": "",
        "category": "",
        "in": [
            {
                "x": 140,
                "y": 180,
                "wires": [
                    {
                        "id": "985b46457dc33d13"
                    }
                ]
            }
        ],
        "out": [
            {
                "x": 1100,
                "y": 80,
                "wires": [
                    {
                        "id": "903c245cf7208ba2",
                        "port": 1
                    },
                    {
                        "id": "466ccaf852ddbafc",
                        "port": 0
                    }
                ]
            },
            {
                "x": 920,
                "y": 200,
                "wires": [
                    {
                        "id": "29492bab8d88f197",
                        "port": 0
                    }
                ]
            },
            {
                "x": 920,
                "y": 280,
                "wires": [
                    {
                        "id": "29492bab8d88f197",
                        "port": 1
                    }
                ]
            }
        ],
        "env": [],
        "meta": {},
        "color": "#DDAA99"
    },
    {
        "id": "5a73d051bbe1ee13",
        "type": "http request",
        "z": "53dea74fb60818b9",
        "name": "Request Info",
        "method": "GET",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 410,
        "y": 180,
        "wires": [
            [
                "29492bab8d88f197",
                "903c245cf7208ba2"
            ]
        ]
    },
    {
        "id": "6ce4ab78cea87fce",
        "type": "catch",
        "z": "53dea74fb60818b9",
        "name": "",
        "scope": [
            "5a73d051bbe1ee13"
        ],
        "uncaught": false,
        "x": 270,
        "y": 260,
        "wires": [
            []
        ]
    },
    {
        "id": "29492bab8d88f197",
        "type": "function",
        "z": "53dea74fb60818b9",
        "name": "connection status",
        "func": "\nif(typeof msg.payload === \"string\"){\n\nif(msg.payload.substr(23, 8) === \"TIMEDOUT\"){\n    \n   \n    let id=\"Offline\";\n    var stat=false;\n    return [{ payload: stat }, {status : id},];\n\n    }\n}\n\n\nvar state = (msg.payload[\"switch:0\"].output)\n\nif ((state == true) || (state == false)){\n    \n    \n    let id=\"Online\";\n    return [{payload:state},{status : id}];\n    \n}\n\n\n\n",
        "outputs": 2,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 670,
        "y": 200,
        "wires": [
            [],
            []
        ]
    },
    {
        "id": "81106714a44faedc",
        "type": "http request",
        "z": "53dea74fb60818b9",
        "d": true,
        "g": "85366ee2c240511b",
        "name": "ON",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "http://10.50.8.18/relay/0?turn=on",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 1350,
        "y": 460,
        "wires": [
            []
        ]
    },
    {
        "id": "aac3c13d70d08a1a",
        "type": "http request",
        "z": "53dea74fb60818b9",
        "d": true,
        "g": "85366ee2c240511b",
        "name": "OFF",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "http://10.50.8.18/relay/0?turn=off",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 1350,
        "y": 500,
        "wires": [
            []
        ]
    },
    {
        "id": "74a931c04d6a295b",
        "type": "http request",
        "z": "53dea74fb60818b9",
        "d": true,
        "g": "85366ee2c240511b",
        "name": "Request Status",
        "method": "GET",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "http://10.50.8.18/relay/0?ison",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 440,
        "y": 500,
        "wires": [
            [
                "f08f547ca839a9be",
                "c668c33ea78af815"
            ]
        ]
    },
    {
        "id": "58e1a6fceaa08c76",
        "type": "ui_gauge",
        "z": "53dea74fb60818b9",
        "d": true,
        "g": "85366ee2c240511b",
        "name": "Leistung",
        "group": "d8a93b295651180e",
        "order": 2,
        "width": 6,
        "height": 4,
        "gtype": "gage",
        "title": "Leistung",
        "label": "Watt",
        "format": "{{msg.payload[\"switch:0\"].apower}}",
        "min": 0,
        "max": "2500",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "diff": false,
        "className": "",
        "x": 560,
        "y": 660,
        "wires": []
    },
    {
        "id": "a34bd3ad0a3087f0",
        "type": "http request",
        "z": "53dea74fb60818b9",
        "d": true,
        "g": "85366ee2c240511b",
        "name": "Request Info",
        "method": "GET",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "http://10.50.8.18/rpc/shelly.GetStatus",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 370,
        "y": 660,
        "wires": [
            [
                "58e1a6fceaa08c76"
            ]
        ]
    },
    {
        "id": "cccef1fa728ad75e",
        "type": "ui_text",
        "z": "53dea74fb60818b9",
        "d": true,
        "g": "85366ee2c240511b",
        "group": "d8a93b295651180e",
        "order": 2,
        "width": 0,
        "height": 0,
        "name": "status",
        "label": "",
        "format": "{{msg.status}}",
        "layout": "row-left",
        "className": "",
        "style": false,
        "font": "",
        "fontSize": 16,
        "color": "#000000",
        "x": 1170,
        "y": 620,
        "wires": []
    },
    {
        "id": "197643be4d3c4747",
        "type": "catch",
        "z": "53dea74fb60818b9",
        "d": true,
        "g": "85366ee2c240511b",
        "name": "",
        "scope": "group",
        "uncaught": false,
        "x": 790,
        "y": 620,
        "wires": [
            [
                "c668c33ea78af815"
            ]
        ]
    },
    {
        "id": "fb3a1d75da8a3fb7",
        "type": "link in",
        "z": "53dea74fb60818b9",
        "d": true,
        "g": "85366ee2c240511b",
        "name": "shelly",
        "links": [
            "6e57c3b844ee43a4"
        ],
        "x": 305,
        "y": 540,
        "wires": [
            [
                "74a931c04d6a295b",
                "a34bd3ad0a3087f0"
            ]
        ]
    },
    {
        "id": "f08f547ca839a9be",
        "type": "change",
        "z": "53dea74fb60818b9",
        "d": true,
        "g": "85366ee2c240511b",
        "name": "extract ison",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "msg.payload.ison",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 630,
        "y": 500,
        "wires": [
            [
                "5be143866fb6e5a3"
            ]
        ]
    },
    {
        "id": "2fdbb3ebc56d8ef3",
        "type": "switch",
        "z": "53dea74fb60818b9",
        "d": true,
        "g": "85366ee2c240511b",
        "name": "an/aus",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 1190,
        "y": 480,
        "wires": [
            [
                "81106714a44faedc"
            ],
            [
                "aac3c13d70d08a1a"
            ]
        ]
    },
    {
        "id": "5be143866fb6e5a3",
        "type": "ui_switch",
        "z": "53dea74fb60818b9",
        "d": true,
        "g": "85366ee2c240511b",
        "name": "",
        "label": "AN/AUS",
        "tooltip": "",
        "group": "d8a93b295651180e",
        "order": 1,
        "width": 6,
        "height": 1,
        "passthru": true,
        "decouple": "false",
        "topic": "topic",
        "topicType": "msg",
        "style": "",
        "onvalue": "true",
        "onvalueType": "bool",
        "onicon": "offline_pin",
        "oncolor": "#25e712",
        "offvalue": "false",
        "offvalueType": "bool",
        "officon": "highlight_off",
        "offcolor": "#cb3234",
        "animate": true,
        "className": "",
        "x": 1040,
        "y": 480,
        "wires": [
            [
                "2fdbb3ebc56d8ef3"
            ]
        ]
    },
    {
        "id": "c668c33ea78af815",
        "type": "function",
        "z": "53dea74fb60818b9",
        "d": true,
        "g": "85366ee2c240511b",
        "name": "con.status",
        "func": "if (msg.payload.ison == true || msg.payload.ison == false){\n    var id=\"Online\";\n    return [null,{status : id}];\n}\n\nif(msg.payload.substr(23, 8) ==\"TIMEDOUT\"){\n    var id=\"Offline\";\n    var off=false;\n    return [{ payload: off }, {status : id},];\n}\n\n",
        "outputs": 2,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1010,
        "y": 620,
        "wires": [
            [
                "5be143866fb6e5a3"
            ],
            [
                "cccef1fa728ad75e"
            ]
        ]
    },
    {
        "id": "985b46457dc33d13",
        "type": "change",
        "z": "53dea74fb60818b9",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "url",
                "pt": "msg",
                "to": "msg.shelly&'rpc/shelly.GetStatus'",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 250,
        "y": 180,
        "wires": [
            [
                "5a73d051bbe1ee13"
            ]
        ]
    },
    {
        "id": "903c245cf7208ba2",
        "type": "switch",
        "z": "53dea74fb60818b9",
        "name": "filter error",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "RequestError",
                "vt": "str"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 660,
        "y": 160,
        "wires": [
            [
                "466ccaf852ddbafc"
            ],
            []
        ]
    },
    {
        "id": "466ccaf852ddbafc",
        "type": "change",
        "z": "53dea74fb60818b9",
        "name": "0W",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"switch:0\":{\"apower\":0}}",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 850,
        "y": 80,
        "wires": [
            []
        ]
    },
    {
        "id": "85366ee2c240511b",
        "type": "group",
        "z": "53dea74fb60818b9",
        "name": "Shelly 9",
        "style": {
            "label": true
        },
        "nodes": [
            "81106714a44faedc",
            "aac3c13d70d08a1a",
            "74a931c04d6a295b",
            "58e1a6fceaa08c76",
            "a34bd3ad0a3087f0",
            "cccef1fa728ad75e",
            "197643be4d3c4747",
            "fb3a1d75da8a3fb7",
            "f08f547ca839a9be",
            "2fdbb3ebc56d8ef3",
            "5be143866fb6e5a3",
            "c668c33ea78af815"
        ],
        "x": 264,
        "y": 419
    },
    {
        "id": "d8a93b295651180e",
        "type": "ui_group",
        "name": "Shelly 9",
        "tab": "52fcd4b2f772d383",
        "order": 3,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "52fcd4b2f772d383",
        "type": "ui_tab",
        "name": "Unverwendete shellys",
        "icon": "dashboard",
        "order": 5,
        "disabled": false,
        "hidden": true
    },
    {
        "id": "9e25da9d9e02e634",
        "type": "subflow",
        "name": "Controll Plug",
        "info": "",
        "category": "",
        "in": [
            {
                "x": 80,
                "y": 360,
                "wires": [
                    {
                        "id": "6237b75b2b51e57f"
                    }
                ]
            }
        ],
        "out": [],
        "env": [],
        "meta": {},
        "color": "#DDAA99"
    },
    {
        "id": "fcf870c7b18d4025",
        "type": "http request",
        "z": "9e25da9d9e02e634",
        "name": "Command shelly",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 770,
        "y": 360,
        "wires": [
            []
        ]
    },
    {
        "id": "6237b75b2b51e57f",
        "type": "switch",
        "z": "9e25da9d9e02e634",
        "name": "an/aus",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 290,
        "y": 360,
        "wires": [
            [
                "b689ceb06654a9e6"
            ],
            [
                "66a927cd6a2ab865"
            ]
        ]
    },
    {
        "id": "b689ceb06654a9e6",
        "type": "change",
        "z": "9e25da9d9e02e634",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "url",
                "pt": "msg",
                "to": "msg.shelly&'relay/0?turn=on'",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 530,
        "y": 300,
        "wires": [
            [
                "fcf870c7b18d4025"
            ]
        ]
    },
    {
        "id": "66a927cd6a2ab865",
        "type": "change",
        "z": "9e25da9d9e02e634",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "url",
                "pt": "msg",
                "to": "msg.shelly&'relay/0?turn=off'",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 530,
        "y": 420,
        "wires": [
            [
                "fcf870c7b18d4025"
            ]
        ]
    },
    {
        "id": "c55eefe4a3a0e765",
        "type": "catch",
        "z": "9e25da9d9e02e634",
        "name": "",
        "scope": [
            "fcf870c7b18d4025"
        ],
        "uncaught": false,
        "x": 730,
        "y": 420,
        "wires": [
            []
        ]
    },
    {
        "id": "9395cb1108b9311a",
        "type": "tab",
        "label": "Shelly Plug Controll ",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "c3ada784e202d1d3",
        "type": "group",
        "z": "9395cb1108b9311a",
        "name": "Refresh",
        "style": {
            "label": true
        },
        "nodes": [
            "67fade5098a57e50",
            "58d38372dd5dc289",
            "569f6180f2f6e9c9",
            "bb5b57301c40b2d2"
        ],
        "x": 14,
        "y": 19,
        "w": 402,
        "h": 122
    },
    {
        "id": "30f3ae33d9d3d89f",
        "type": "group",
        "z": "9395cb1108b9311a",
        "name": "Shelly1",
        "style": {
            "label": true
        },
        "nodes": [
            "d7632c03c8f25529",
            "a14af018da02ee4d",
            "9c1f46e2254c21ec",
            "cc8171792ed40236",
            "3ac23fb49aebaa23",
            "a6d3e35c05a073c7",
            "a30e137f7efe769c",
            "1b6bc5b9af1c17a7",
            "455976210436c5d1"
        ],
        "x": 84,
        "y": 199,
        "w": 1282,
        "h": 162
    },
    {
        "id": "67fade5098a57e50",
        "type": "link out",
        "z": "9395cb1108b9311a",
        "g": "c3ada784e202d1d3",
        "name": "Refresh",
        "mode": "link",
        "links": [
            "48509d47d797f6d9",
            "5c4a0154de1f8a82",
            "d9b27faffd855c0e",
            "1eff00d9d2c33510",
            "ead8637b2ca3251d",
            "8e80c38bd31aa2b1",
            "1b6bc5b9af1c17a7",
            "c24fd76751b8a1cd",
            "8fc6201345280e64",
            "5f9c6d7f2cb17b67",
            "5ca4093f03902c33",
            "9d8368fc0d70be11",
            "b701209c844c4e36",
            "56e2a304f1dfbcf7",
            "e3e80e87ee8a392a",
            "f72240e6e2fdd15d",
            "9817b3bdaa8ade48",
            "2bdadacc50b11fde",
            "5d65b6e35d25e969"
        ],
        "x": 375,
        "y": 60,
        "wires": []
    },
    {
        "id": "58d38372dd5dc289",
        "type": "ui_ui_control",
        "z": "9395cb1108b9311a",
        "g": "c3ada784e202d1d3",
        "name": "",
        "events": "all",
        "x": 120,
        "y": 60,
        "wires": [
            [
                "bb5b57301c40b2d2"
            ]
        ]
    },
    {
        "id": "569f6180f2f6e9c9",
        "type": "inject",
        "z": "9395cb1108b9311a",
        "d": true,
        "g": "c3ada784e202d1d3",
        "name": "Request Switch status",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "5",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 170,
        "y": 100,
        "wires": [
            [
                "67fade5098a57e50"
            ]
        ]
    },
    {
        "id": "bb5b57301c40b2d2",
        "type": "delay",
        "z": "9395cb1108b9311a",
        "g": "c3ada784e202d1d3",
        "name": "slow refresh",
        "pauseType": "rate",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "2",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 270,
        "y": 60,
        "wires": [
            [
                "67fade5098a57e50"
            ]
        ]
    },
    {
        "id": "d7632c03c8f25529",
        "type": "change",
        "z": "9395cb1108b9311a",
        "g": "30f3ae33d9d3d89f",
        "name": "http://10.50.8.10/",
        "rules": [
            {
                "t": "set",
                "p": "shelly",
                "pt": "msg",
                "to": "http://10.50.8.10/",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 250,
        "y": 280,
        "wires": [
            [
                "455976210436c5d1"
            ]
        ]
    },
    {
        "id": "a14af018da02ee4d",
        "type": "ui_gauge",
        "z": "9395cb1108b9311a",
        "g": "30f3ae33d9d3d89f",
        "name": "Leistung",
        "group": "edcf6818e8245ec7",
        "order": 2,
        "width": 6,
        "height": 4,
        "gtype": "gage",
        "title": "Leistung",
        "label": "Watt",
        "format": "{{msg.payload[\"switch:0\"].apower}}",
        "min": 0,
        "max": "2500",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "diff": false,
        "className": "",
        "x": 560,
        "y": 240,
        "wires": []
    },
    {
        "id": "9c1f46e2254c21ec",
        "type": "ui_switch",
        "z": "9395cb1108b9311a",
        "g": "30f3ae33d9d3d89f",
        "name": "",
        "label": "AN/AUS",
        "tooltip": "",
        "group": "edcf6818e8245ec7",
        "order": 1,
        "width": 6,
        "height": 1,
        "passthru": true,
        "decouple": "false",
        "topic": "topic",
        "topicType": "msg",
        "style": "",
        "onvalue": "true",
        "onvalueType": "bool",
        "onicon": "offline_pin",
        "oncolor": "#25e712",
        "offvalue": "false",
        "offvalueType": "bool",
        "officon": "highlight_off",
        "offcolor": "#cb3234",
        "animate": true,
        "className": "",
        "x": 720,
        "y": 260,
        "wires": [
            [
                "a30e137f7efe769c"
            ]
        ]
    },
    {
        "id": "cc8171792ed40236",
        "type": "ui_text",
        "z": "9395cb1108b9311a",
        "g": "30f3ae33d9d3d89f",
        "group": "edcf6818e8245ec7",
        "order": 2,
        "width": 0,
        "height": 0,
        "name": "status",
        "label": "",
        "format": "{{msg.status}}",
        "layout": "row-left",
        "className": "",
        "style": false,
        "font": "",
        "fontSize": 16,
        "color": "#000000",
        "x": 550,
        "y": 320,
        "wires": []
    },
    {
        "id": "3ac23fb49aebaa23",
        "type": "subflow:9e25da9d9e02e634",
        "z": "9395cb1108b9311a",
        "g": "30f3ae33d9d3d89f",
        "name": "Controll Plug",
        "x": 1270,
        "y": 320,
        "wires": []
    },
    {
        "id": "a6d3e35c05a073c7",
        "type": "change",
        "z": "9395cb1108b9311a",
        "g": "30f3ae33d9d3d89f",
        "name": "http://10.50.8.10/",
        "rules": [
            {
                "t": "set",
                "p": "shelly",
                "pt": "msg",
                "to": "http://10.50.8.10/",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1090,
        "y": 320,
        "wires": [
            [
                "3ac23fb49aebaa23"
            ]
        ]
    },
    {
        "id": "a30e137f7efe769c",
        "type": "switch",
        "z": "9395cb1108b9311a",
        "g": "30f3ae33d9d3d89f",
        "name": "änderungs gate",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "neq",
                "v": "",
                "vt": "prev"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 900,
        "y": 320,
        "wires": [
            [
                "a6d3e35c05a073c7"
            ]
        ]
    },
    {
        "id": "1b6bc5b9af1c17a7",
        "type": "link in",
        "z": "9395cb1108b9311a",
        "g": "30f3ae33d9d3d89f",
        "name": "shelly",
        "links": [
            "67fade5098a57e50"
        ],
        "x": 125,
        "y": 280,
        "wires": [
            [
                "d7632c03c8f25529"
            ]
        ]
    },
    {
        "id": "4f9c0c7ead51cb46",
        "type": "ui_ui_control",
        "z": "9395cb1108b9311a",
        "name": "warning",
        "events": "connect",
        "x": 500,
        "y": 60,
        "wires": [
            [
                "437fc0736359157e"
            ]
        ]
    },
    {
        "id": "7af4e585403d30a9",
        "type": "ui_toast",
        "z": "9395cb1108b9311a",
        "position": "top right",
        "displayTime": "10",
        "highlight": "red",
        "sendall": true,
        "outputs": 0,
        "ok": "OK",
        "cancel": "",
        "raw": false,
        "className": "",
        "topic": "",
        "name": "",
        "x": 1180,
        "y": 80,
        "wires": []
    },
    {
        "id": "437fc0736359157e",
        "type": "change",
        "z": "9395cb1108b9311a",
        "name": "warn text",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "Please be careful and don't make rapid changes.",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "The buttons turn on the power to the computers. ",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 640,
        "y": 60,
        "wires": [
            [
                "cd685ebb4b157083"
            ]
        ]
    },
    {
        "id": "cd685ebb4b157083",
        "type": "delay",
        "z": "9395cb1108b9311a",
        "name": "",
        "pauseType": "delay",
        "timeout": "0.5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 810,
        "y": 60,
        "wires": [
            [
                "1ab2ff1d637886a1",
                "4b3a5d2900287456"
            ]
        ]
    },
    {
        "id": "1ab2ff1d637886a1",
        "type": "delay",
        "z": "9395cb1108b9311a",
        "name": "",
        "pauseType": "delay",
        "timeout": "1",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 1000,
        "y": 80,
        "wires": [
            [
                "7af4e585403d30a9"
            ]
        ]
    },
    {
        "id": "4b3a5d2900287456",
        "type": "change",
        "z": "9395cb1108b9311a",
        "name": "empty",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 970,
        "y": 40,
        "wires": [
            [
                "40e2e317f0f85d3c"
            ]
        ]
    },
    {
        "id": "40e2e317f0f85d3c",
        "type": "ui_ui_control",
        "z": "9395cb1108b9311a",
        "name": "reload page",
        "events": "all",
        "x": 1110,
        "y": 40,
        "wires": [
            []
        ]
    },
    {
        "id": "455976210436c5d1",
        "type": "subflow:53dea74fb60818b9",
        "z": "9395cb1108b9311a",
        "g": "30f3ae33d9d3d89f",
        "name": "",
        "x": 420,
        "y": 280,
        "wires": [
            [
                "a14af018da02ee4d"
            ],
            [
                "9c1f46e2254c21ec",
                "a30e137f7efe769c"
            ],
            [
                "cc8171792ed40236"
            ]
        ]
    },
    {
        "id": "edcf6818e8245ec7",
        "type": "ui_group",
        "name": "HAG Hallenmonitor",
        "tab": "a2d46a71b9db5230",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "a2d46a71b9db5230",
        "type": "ui_tab",
        "name": "Halle3",
        "icon": "dashboard",
        "order": 4,
        "disabled": false,
        "hidden": false
    }
]

Hi There,

Having a quick look, I would say:

  • Good use of switch and change, you have avoided the use of the function node for those things. Especially since you have used jsonata which removes the need to use a function node in many cases.

  • Code formatting could be improved, for example:

becomes:

But also jsonata expressions: msg.shelly&'relay/0?turn=on' could become msg.shelly & 'relay/0?turn=on' to improve readability.

  • avoid duplication of constant values, you have two nodes that set msg.shelly - use a global or environment value instead.

becomes:

(for example)

2 Likes

Couple of notes.

When sharing a flow, it can be helpful to share an image from the Editor showing the flow as this will often save people having to load the flow into a test system.

In terms of function nodes vs JSONata - just note that, for high throughput, function nodes are sometimes preferred since JSONata has quite an overhead. If using JSONata, try to ensure you minimise the number of calls to it. In addition, sometimes complex logic may be easier to follow in a function node rather than having a complex flow with many nodes. Ultimately though, there is no absolute right or wrong answer and a lot depends on your knowledge and experience.

2 Likes

What I did was take the flow and import into the serverless NodeRED and view in that. Can't execute the flow but for purposes of viewing/understanding the flow, that's fine.

I won't go into why the forum could integrate the flowviewer so that images are generated automagically.

Good advice. For viewable and understandability, I find a change better than function since there are less side-effects when using a change node (and no computation possible).

It's a pity that JSONata has this overhead since in an ideal world, there would be a node for msg/flow/global modifications and a node for functionality to do computation and both would have the same amount of overhead.

Not sure that is possible with Discourse. Though it would certainly be nice.

It is very much a balancing act. Once a flow reaches a certain level of complexity, most people will want to look for creative ways to simplify it.


In this example, you can see several possible approaches all used depending on the flow of logic and how I was feeling the day(s) I wrote it! :slight_smile:

True, though worth remembering that JSONata, like other transformation languages (XLST for example) has a cognitive load as well as a processing/memory load. For most people, certain transformation tasks will be really obvious and simple with JSONata and others will leave you sweating with mental stress and a feeling of utter inadequacy for days! :person_shrugging: JavaScript, like other procedural style languages, has a more linear mental load.

1 Like

Wow it never occurred to me to try \n in the group name, that's excellent.
I still wish we could put text both at the top and the bottom of the group.

Yes, though you do need to remember to include spaces around it. It is a shame that it can't simply take Markdown instead, that would be a LOT nicer.

Well, I guess we have to stop somewhere. You can always add a comment node of course.

I would suggest not using msg. as that forces compatibility mode. Either omit msg or use $$.

Version 1.6 did , but newer version 2 is comparable with javascript using the JSONata functions as exampled here JSONATA Array Filtering - #4 by E1cid

2 Likes

Good to know. That just leaves the cognitive load then. :smile:

That would be subjectively relevant to each individuals cognitive functionality i suppose.

1 Like

First off thanks to TotallyInformation, I will post screenshots in the future.
Glad to hear that JSONata doesn't add problems since I switched from functions to these
expressions for certain things.
But I will pay attention to it in the future.

I added an intializer for the global variables like gregorius sugguested.

@E1cid could you explain what you mean by
"I would suggest not using msg. as that forces compatibility mode. Either omit msg or use $$.", please?

Lastly, is there a way to get around having multiple coppies of the group "Shelly1" for more devices?

Thanks for the great advice
-Jan

It is explained in the editor if you click compatibility mode enabled

1 Like