[SOLVED] Use of Reboot/Shutdown node

Hi,

I use the following nodes to reboot my Rpi. I'm using a notification node to ask the user if to proceed or not. If 'OK' is chosen, then a 'true' is sent to the Reboot node and the board reboots.
Then in theory, if a 'Cancel' is pressed, nothing should happen. However, the board reboots.
When 'Cancel' is pressed I'm sending out a 'null' but the Reboot node accepts it as a valid cmd.

How do I fix it?
TIA

[
    {
        "id": "56a42e6a89d16cd3",
        "type": "restart",
        "z": "9a2012d7b4e48ade",
        "name": "Reboot",
        "x": 320,
        "y": 220,
        "wires": []
    },
    {
        "id": "bc997f0a3f2f5cdf",
        "type": "ui_toast",
        "z": "9a2012d7b4e48ade",
        "position": "dialog",
        "displayTime": "3",
        "highlight": "",
        "sendall": true,
        "outputs": 1,
        "ok": "OK",
        "cancel": "Cancel",
        "raw": false,
        "topic": "",
        "name": "Alert",
        "x": 170,
        "y": 160,
        "wires": [
            [
                "818a6f8bfc732a59"
            ]
        ]
    },
    {
        "id": "35f154938724cff8",
        "type": "function",
        "z": "9a2012d7b4e48ade",
        "name": "",
        "func": "if (msg.payload === true){\n    txt = \"Caution!! Will reboot.\";\n    msg.payload =  txt ;\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 160,
        "y": 100,
        "wires": [
            [
                "bc997f0a3f2f5cdf"
            ]
        ]
    },
    {
        "id": "818a6f8bfc732a59",
        "type": "function",
        "z": "9a2012d7b4e48ade",
        "name": "",
        "func": "if (msg.payload === \"OK\"){\n    msg.payload = true;\n}\nelse{\n    msg.payload = null;\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 160,
        "y": 220,
        "wires": [
            [
                "56a42e6a89d16cd3"
            ]
        ]
    },
    {
        "id": "a26c296d8a3715e0",
        "type": "ui_button",
        "z": "9a2012d7b4e48ade",
        "name": "Reboot",
        "group": "2de74aabc7cdf0ad",
        "order": 2,
        "width": "3",
        "height": "1",
        "passthru": false,
        "label": "Reiniciar domo",
        "tooltip": "",
        "color": "white",
        "bgcolor": "#da3232",
        "icon": "autorenew",
        "payload": "true",
        "payloadType": "bool",
        "topic": "topic",
        "x": 160,
        "y": 40,
        "wires": [
            [
                "35f154938724cff8"
            ]
        ]
    },
    {
        "id": "2de74aabc7cdf0ad",
        "type": "ui_group",
        "name": "Configuración",
        "tab": "fcae68a61b2b76db",
        "order": 5,
        "disp": true,
        "width": "6",
        "collapse": true
    },
    {
        "id": "fcae68a61b2b76db",
        "type": "ui_tab",
        "z": "",
        "name": "DEMO",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

EDIT:
Nevermind. Returning the msg within the conditional check, fixed it.

if (msg.payload == "OK"){
    msg.payload = true;
    return msg;
}

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