Block empty input in Dashboard

Hey guys,

i'm trying to block an empty input (debug says: NaN) of a text input node, so that u only can get a payload on debug if there was a number input of at least one number at the input node, confirmed through button use.

Here's my flow. Thx for any help.

btw: sry for my bad english.

[
    {
        "id": "6c3072aefaf68405",
        "type": "tab",
        "label": "Testflow",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "058fb7e7e0b63923",
        "type": "ui_text_input",
        "z": "6c3072aefaf68405",
        "name": "Input",
        "label": "",
        "tooltip": "",
        "group": "72303c1.198bdc4",
        "order": 1,
        "width": 0,
        "height": 0,
        "passthru": true,
        "mode": "number",
        "delay": 300,
        "topic": "Code",
        "sendOnBlur": true,
        "className": "",
        "topicType": "str",
        "x": 170,
        "y": 340,
        "wires": [
            [
                "5d91137742d5db32"
            ]
        ]
    },
    {
        "id": "6001d4789d59be26",
        "type": "ui_button",
        "z": "6c3072aefaf68405",
        "name": "Button",
        "group": "72303c1.198bdc4",
        "order": 2,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "OK",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "OK",
        "payloadType": "str",
        "topic": "Button",
        "topicType": "str",
        "x": 170,
        "y": 280,
        "wires": [
            [
                "f8c5bcfe904a4e36"
            ]
        ]
    },
    {
        "id": "f8c5bcfe904a4e36",
        "type": "change",
        "z": "6c3072aefaf68405",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "complete",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 460,
        "y": 280,
        "wires": [
            [
                "5d91137742d5db32"
            ]
        ]
    },
    {
        "id": "5d91137742d5db32",
        "type": "join",
        "z": "6c3072aefaf68405",
        "name": "",
        "mode": "custom",
        "build": "object",
        "property": "payload",
        "propertyType": "msg",
        "key": "topic",
        "joiner": "\\n",
        "joinerType": "str",
        "accumulate": false,
        "timeout": "",
        "count": "",
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "",
        "reduceFixup": "",
        "x": 610,
        "y": 340,
        "wires": [
            [
                "7e4faf41bb215ed1",
                "262ad0a7e971897b"
            ]
        ]
    },
    {
        "id": "262ad0a7e971897b",
        "type": "change",
        "z": "6c3072aefaf68405",
        "name": "input reset",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "null",
                "tot": "num"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 190,
        "y": 400,
        "wires": [
            [
                "058fb7e7e0b63923"
            ]
        ]
    },
    {
        "id": "7e4faf41bb215ed1",
        "type": "debug",
        "z": "6c3072aefaf68405",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 810,
        "y": 340,
        "wires": []
    },
    {
        "id": "72303c1.198bdc4",
        "type": "ui_group",
        "name": "Default",
        "tab": "d50f4120.5bc2d",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false
    },
    {
        "id": "d50f4120.5bc2d",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]

Try this, change the join node to use 2 msgs and add a switch node to test if msg.payload.Code is a number

[{"id":"058fb7e7e0b63923","type":"ui_text_input","z":"6c3072aefaf68405","name":"Input","label":"","tooltip":"","group":"72303c1.198bdc4","order":1,"width":0,"height":0,"passthru":true,"mode":"number","delay":300,"topic":"Code","sendOnBlur":true,"className":"","topicType":"str","x":170,"y":340,"wires":[["5d91137742d5db32"]]},{"id":"6001d4789d59be26","type":"ui_button","z":"6c3072aefaf68405","name":"Button","group":"72303c1.198bdc4","order":2,"width":0,"height":0,"passthru":false,"label":"OK","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"OK","payloadType":"str","topic":"Button","topicType":"str","x":170,"y":280,"wires":[["f8c5bcfe904a4e36"]]},{"id":"f8c5bcfe904a4e36","type":"change","z":"6c3072aefaf68405","name":"","rules":[{"t":"set","p":"complete","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":280,"wires":[["5d91137742d5db32"]]},{"id":"5d91137742d5db32","type":"join","z":"6c3072aefaf68405","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":610,"y":340,"wires":[["262ad0a7e971897b","8aa07c3e70103c47"]]},{"id":"262ad0a7e971897b","type":"change","z":"6c3072aefaf68405","name":"input reset","rules":[{"t":"set","p":"payload","pt":"msg","to":"null","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":190,"y":460,"wires":[["058fb7e7e0b63923"]]},{"id":"7e4faf41bb215ed1","type":"debug","z":"6c3072aefaf68405","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1010,"y":340,"wires":[]},{"id":"8aa07c3e70103c47","type":"switch","z":"6c3072aefaf68405","name":"","property":"payload.Code","propertyType":"msg","rules":[{"t":"istype","v":"number","vt":"number"}],"checkall":"true","repair":false,"outputs":1,"x":810,"y":340,"wires":[["7e4faf41bb215ed1"]]},{"id":"72303c1.198bdc4","type":"ui_group","name":"Default","tab":"d50f4120.5bc2d","order":1,"disp":true,"width":"6","collapse":false},{"id":"d50f4120.5bc2d","type":"ui_tab","name":"Home","icon":"dashboard","order":1,"disabled":false,"hidden":false}]
1 Like

Thank you for your answer,

guess it's one step into the right direction. It works for the first empty input, but multiple empty inputs still give a 'NaN' as payload. I'd like to prevent from brute force pushing the button, so you get a notification only after a number input.

For example:
You chose the numbers 10, 20 and 30. After those three random number inputs you get a notification. Now i want to prevent from pushing without a number input, brute force like.

Thank you for your help so far, maybe you come up with a solution. I keep on trying as well.

You could add a switch node prior to dashboard ui-text, to only allow numbers but not NaN using JSONata

[{"id":"c3795151.6a2ec8","type":"inject","z":"6c3072aefaf68405","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"null","payloadType":"json","x":110,"y":420,"wires":[["7bebf6df.970f4"]]},{"id":"7bebf6df.970f4","type":"switch","z":"6c3072aefaf68405","name":"","property":"$type($$.payload)","propertyType":"jsonata","rules":[{"t":"eq","v":"number","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":300,"y":420,"wires":[["058fb7e7e0b63923","6f58a75c.6a2ba"]]},{"id":"24d078f7.0a5d7","type":"inject","z":"6c3072aefaf68405","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"$ceil($random()*10)","payloadType":"jsonata","x":110,"y":560,"wires":[["7bebf6df.970f4"]]},{"id":"d6a23de.be7f2c","type":"function","z":"6c3072aefaf68405","name":"","func":"msg.payload = NaN\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":500,"wires":[["7bebf6df.970f4"]]},{"id":"f75c3dd0.34a0b8","type":"inject","z":"6c3072aefaf68405","name":"string","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"a string","payloadType":"str","x":110,"y":620,"wires":[["7bebf6df.970f4"]]},{"id":"058fb7e7e0b63923","type":"ui_text_input","z":"6c3072aefaf68405","name":"Input","label":"","tooltip":"","group":"72303c1.198bdc4","order":1,"width":0,"height":0,"passthru":true,"mode":"number","delay":300,"topic":"Code","sendOnBlur":true,"className":"","topicType":"str","x":510,"y":340,"wires":[[]]},{"id":"6f58a75c.6a2ba","type":"debug","z":"6c3072aefaf68405","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":520,"y":420,"wires":[]},{"id":"9c29c734.c2676","type":"inject","z":"6c3072aefaf68405","name":"NaN","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":500,"wires":[["d6a23de.be7f2c"]]},{"id":"72303c1.198bdc4","type":"ui_group","name":"Default","tab":"d50f4120.5bc2d","order":1,"disp":true,"width":"6","collapse":false},{"id":"d50f4120.5bc2d","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]
1 Like

I resolved it with your help.

I had to turn off the ' If msg arrives on input, pass through to output:' option at the text input node. My reset loop payload for the text input node passed through, that caused the problem with NaN after multiple inputs.

Thank you, took me hours till now. :slight_smile:

I tried that as well and it would work as well, thank you too.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.