[
    {
        "id": "c6a7e5f1a5b88279",
        "type": "tab",
        "label": "Práctica Día 3: Enlace Cloud",
        "disabled": false,
        "info": "Flujo de simulación y telemetría para enviar datos de temperatura en tiempo real desde Node-RED local a Google Firebase Realtime Database."
    },
    {
        "id": "e2c813a4bc4d9eb1",
        "type": "inject",
        "z": "c6a7e5f1a5b88279",
        "name": "Tick cada 5s",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "5",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 170,
        "y": 140,
        "wires": [
            [
                "61a298be69512fa3"
            ]
        ]
    },
    {
        "id": "61a298be69512fa3",
        "type": "function",
        "z": "c6a7e5f1a5b88279",
        "name": "Simulador Horno Industrial",
        "func": "// Simular temperatura de horno industrial\nlet tempBase = context.get('tempBase') || 115.0;\n\n// Generar variación aleatoria de temperatura (-2.5 a +2.5 °C)\nlet delta = (Math.random() - 0.5) * 5.0;\ntempBase += delta;\n\n// Acotar valores lógicos de operación\nif (tempBase < 80) tempBase = 90;\nif (tempBase > 200) tempBase = 180;\n\ncontext.set('tempBase', tempBase);\n\n// Determinar el estado operacional\nlet estado = \"NORMAL\";\nif (tempBase > 150) {\n    estado = \"OVERHEAT\";\n}\n\n// Construir objeto JSON de telemetría\nmsg.payload = {\n    timestamp: Date.now(),\n    temperatura: parseFloat(tempBase.toFixed(2)),\n    estado_horno: estado\n};\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 420,
        "y": 140,
        "wires": [
            [
                "e5b8801d02c7b5f2",
                "93e882bf477dfab0"
            ]
        ]
    },
    {
        "id": "e5b8801d02c7b5f2",
        "type": "debug",
        "z": "c6a7e5f1a5b88279",
        "name": "Debug Local",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 670,
        "y": 80,
        "wires": []
    },
    {
        "id": "93e882bf477dfab0",
        "type": "http request",
        "z": "c6a7e5f1a5b88279",
        "name": "Enviar a Firebase Cloud",
        "method": "POST",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "https://REEMPLAZAR-CON-SU-PROYECTO-rtdb.firebaseio.com/telemetria.json",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 690,
        "y": 200,
        "wires": [
            [
                "abcf82a884c781fe"
            ]
        ]
    },
    {
        "id": "abcf82a884c781fe",
        "type": "debug",
        "z": "c6a7e5f1a5b88279",
        "name": "Respuesta Firebase",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 930,
        "y": 200,
        "wires": []
    }
]
