[
    {
        "id": "2b5690933ff0c424",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "ab0bdb5e08386da4",
        "type": "group",
        "z": "2b5690933ff0c424",
        "name": "ESP32_1 (10.10.10.31)",
        "style": {
            "stroke": "#000000",
            "fill": "#ffefbf",
            "label": true,
            "color": "#000000"
        },
        "nodes": [
            "a128947fa24e5fce",
            "fa3d5ebf04fadc4a",
            "4cf73103a0afadfc",
            "ded1de09bf5525b1",
            "39157279a73000ec",
            "61ecec0bf33805ee",
            "eb85c0378000df4c",
            "888301a16acd3260",
            "f3424f3eb93698de",
            "fc3536baec60b434",
            "37972ddb741ee36f",
            "05733c15e7b65ca7",
            "bc45047f19964872",
            "2c0f5d615f6b2855",
            "75186b41ae947c44",
            "2ff3402c59e816f5",
            "ca44d7f9ad3eb289",
            "5c9ba8478f1104fc",
            "40427a6e6f69fba3",
            "7499322fba292ac4",
            "68b009b627f7b7d2",
            "4523ca1ae477c914",
            "d0f57c61dd603d33",
            "4f8e265e52d937de",
            "18e1d3aa8e66d904",
            "25f0c9f540b555af",
            "56f5a2700cc50276",
            "f49d104f13b262be"
        ],
        "x": 34,
        "y": 119,
        "w": 1292,
        "h": 642
    },
    {
        "id": "f49d104f13b262be",
        "type": "junction",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "x": 540,
        "y": 680,
        "wires": [
            [
                "75186b41ae947c44",
                "4f8e265e52d937de"
            ]
        ]
    },
    {
        "id": "a128947fa24e5fce",
        "type": "http in",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "",
        "url": "/esp32plc14_31/update",
        "method": "get",
        "upload": false,
        "swaggerDoc": "",
        "x": 180,
        "y": 160,
        "wires": [
            [
                "4cf73103a0afadfc",
                "68b009b627f7b7d2",
                "5c9ba8478f1104fc",
                "d0f57c61dd603d33"
            ]
        ]
    },
    {
        "id": "fa3d5ebf04fadc4a",
        "type": "http response",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "",
        "statusCode": "200",
        "headers": {},
        "x": 600,
        "y": 240,
        "wires": []
    },
    {
        "id": "4cf73103a0afadfc",
        "type": "debug",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "debug 46",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 420,
        "y": 160,
        "wires": []
    },
    {
        "id": "ded1de09bf5525b1",
        "type": "debug",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "debug 47",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 600,
        "y": 220,
        "wires": []
    },
    {
        "id": "39157279a73000ec",
        "type": "http in",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "",
        "url": "/esp32plc14_31/status",
        "method": "post",
        "upload": false,
        "swaggerDoc": "",
        "x": 180,
        "y": 560,
        "wires": [
            [
                "eb85c0378000df4c",
                "61ecec0bf33805ee",
                "888301a16acd3260"
            ]
        ]
    },
    {
        "id": "61ecec0bf33805ee",
        "type": "http response",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "",
        "statusCode": "200",
        "headers": {},
        "x": 420,
        "y": 560,
        "wires": []
    },
    {
        "id": "eb85c0378000df4c",
        "type": "debug",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "debug 48",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 420,
        "y": 520,
        "wires": []
    },
    {
        "id": "888301a16acd3260",
        "type": "switch",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "",
        "property": "payload.status",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "0",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "1",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "2",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "3",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "4",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 5,
        "x": 410,
        "y": 620,
        "wires": [
            [
                "f3424f3eb93698de"
            ],
            [
                "fc3536baec60b434"
            ],
            [
                "37972ddb741ee36f"
            ],
            [
                "f49d104f13b262be"
            ],
            [
                "56f5a2700cc50276"
            ]
        ]
    },
    {
        "id": "f3424f3eb93698de",
        "type": "debug",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "NO UPDATE",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 610,
        "y": 560,
        "wires": []
    },
    {
        "id": "fc3536baec60b434",
        "type": "debug",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "UPDATE",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 600,
        "y": 600,
        "wires": []
    },
    {
        "id": "37972ddb741ee36f",
        "type": "debug",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "ERROR UPDATE",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 630,
        "y": 640,
        "wires": []
    },
    {
        "id": "05733c15e7b65ca7",
        "type": "http in",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "",
        "url": "/esp32plc14_31/firmware",
        "method": "get",
        "upload": false,
        "swaggerDoc": "",
        "x": 180,
        "y": 460,
        "wires": [
            [
                "2c0f5d615f6b2855",
                "ca44d7f9ad3eb289"
            ]
        ]
    },
    {
        "id": "bc45047f19964872",
        "type": "http response",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "",
        "statusCode": "200",
        "headers": {},
        "x": 880,
        "y": 460,
        "wires": []
    },
    {
        "id": "2c0f5d615f6b2855",
        "type": "file in",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "",
        "filename": "/home/pc039/firmware/OTA_ESP32_ETHERNET_31.ino.bin",
        "filenameType": "str",
        "format": "",
        "chunk": false,
        "sendError": false,
        "encoding": "none",
        "allProps": false,
        "x": 580,
        "y": 460,
        "wires": [
            [
                "bc45047f19964872"
            ]
        ]
    },
    {
        "id": "75186b41ae947c44",
        "type": "debug",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "UPDATE SUCCES",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 650,
        "y": 680,
        "wires": []
    },
    {
        "id": "2ff3402c59e816f5",
        "type": "comment",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "posar a false el true de update la versio",
        "info": "",
        "x": 1150,
        "y": 680,
        "wires": []
    },
    {
        "id": "ca44d7f9ad3eb289",
        "type": "debug",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "debug 59",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 420,
        "y": 420,
        "wires": []
    },
    {
        "id": "5c9ba8478f1104fc",
        "type": "trigger",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "",
        "op1": "true",
        "op2": "false",
        "op1type": "bool",
        "op2type": "bool",
        "duration": "30",
        "extend": true,
        "overrideDelay": false,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 430,
        "y": 280,
        "wires": [
            [
                "7499322fba292ac4"
            ]
        ]
    },
    {
        "id": "40427a6e6f69fba3",
        "type": "inject",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "false",
        "payloadType": "bool",
        "x": 250,
        "y": 320,
        "wires": [
            [
                "5c9ba8478f1104fc"
            ]
        ]
    },
    {
        "id": "7499322fba292ac4",
        "type": "debug",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "debug 67",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 600,
        "y": 280,
        "wires": []
    },
    {
        "id": "68b009b627f7b7d2",
        "type": "exec",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "command": "date",
        "addpay": "",
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "winHide": false,
        "oldrc": false,
        "name": "",
        "x": 410,
        "y": 200,
        "wires": [
            [],
            [],
            []
        ]
    },
    {
        "id": "4523ca1ae477c914",
        "type": "inject",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "x": 250,
        "y": 260,
        "wires": [
            [
                "d0f57c61dd603d33"
            ]
        ]
    },
    {
        "id": "d0f57c61dd603d33",
        "type": "function",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "UpdateFirmware",
        "func": "// Inicializamos el estado guardado en el contexto del nodo\n// Si es la primera vez que se ejecuta, por defecto será false\nlet currentState = context.get('updateState') ?? false;\nconst currentVersion = \"0.0.3\";\n\n// Comprobamos si el mensaje entrante es para cambiar la configuración\nif (msg.payload === true || msg.payload === false) {\n    // Actualizamos el estado en el contexto\n    context.set('updateState', msg.payload);\n    \n    // Actualizamos el estado visual del nodo\n    node.status({ \n        fill: msg.payload ? \"green\" : \"red\", \n        shape: \"dot\", \n        text: \"Update: \" + msg.payload \n    });\n    \n    // No enviamos nada (según tu requerimiento)\n    return null;\n}\n\n// Para cualquier otro mensaje, respondemos con el objeto JSON\nmsg.payload = {\n    \"update\": currentState,\n    \"version\": currentVersion\n};\n\n// Actualizamos el status por si acaso es el primer mensaje tras un reinicio\nnode.status({ \n    fill: currentState ? \"green\" : \"red\", \n    shape: \"dot\", \n    text: \"Update: \" + currentState \n});\n\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 440,
        "y": 240,
        "wires": [
            [
                "ded1de09bf5525b1",
                "fa3d5ebf04fadc4a"
            ]
        ]
    },
    {
        "id": "4f8e265e52d937de",
        "type": "change",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 860,
        "y": 680,
        "wires": [
            [
                "18e1d3aa8e66d904"
            ]
        ]
    },
    {
        "id": "18e1d3aa8e66d904",
        "type": "link out",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "link out 4",
        "mode": "link",
        "links": [
            "25f0c9f540b555af"
        ],
        "x": 975,
        "y": 680,
        "wires": []
    },
    {
        "id": "25f0c9f540b555af",
        "type": "link in",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "link in 4",
        "links": [
            "18e1d3aa8e66d904"
        ],
        "x": 285,
        "y": 240,
        "wires": [
            [
                "d0f57c61dd603d33"
            ]
        ]
    },
    {
        "id": "56f5a2700cc50276",
        "type": "debug",
        "z": "2b5690933ff0c424",
        "g": "ab0bdb5e08386da4",
        "name": "MODBUS RTU",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 620,
        "y": 720,
        "wires": []
    }
]