Nothing Special   »   [go: up one dir, main page]

Flows V1

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 52

[

{
"id": "4112c200fc8c7519",
"type": "tab",
"label": "Main",
"disabled": false,
"info": "",
"env": []
},
{
"id": "d7653bde71c42b94",
"type": "tab",
"label": "Módulo email",
"disabled": true,
"info": "",
"env": []
},
{
"id": "61c9b80ab7459c84",
"type": "tab",
"label": "Folder management",
"disabled": true,
"info": "",
"env": []
},
{
"id": "1819625cc50921ea",
"type": "tab",
"label": "COSAS PARA HACER",
"disabled": true,
"info": "",
"env": []
},
{
"id": "ed53b3331ecaacca",
"type": "sqlitedb",
"db": "Documents\\servidor_raspberry\\db_web.db",
"mode": "RWC"
},
{
"id": "e732f9804aee6074",
"type": "ui_group",
"name": "EMAIL",
"tab": "c841644d902a5ca1",
"order": 2,
"disp": false,
"width": 6,
"collapse": false,
"className": ""
},
{
"id": "c7e0a341ce74d5b8",
"type": "ui_tab",
"name": "Servidor KrownPi",
"icon": "fa-industry",
"order": 1,
"disabled": false,
"hidden": false
},
{
"id": "6c6c5547339844cc",
"type": "ui_base",
"theme": {
"name": "theme-dark",
"lightTheme": {
"default": "#0094CE",
"baseColor": "#0094CE",
"baseFont": "-apple-system,BlinkMacSystemFont,Segoe
UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif",
"edited": true,
"reset": false
},
"darkTheme": {
"default": "#097479",
"baseColor": "#0f43bd",
"baseFont": "Lucida Sans Typewriter,Lucida
Console,Monaco,monospace",
"edited": true,
"reset": false
},
"customTheme": {
"name": "Untitled Theme 1",
"default": "#4B7930",
"baseColor": "#4B7930",
"baseFont": "-apple-system,BlinkMacSystemFont,Segoe
UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"
},
"themeState": {
"base-color": {
"default": "#097479",
"value": "#0f43bd",
"edited": true
},
"page-titlebar-backgroundColor": {
"value": "#0f43bd",
"edited": false
},
"page-backgroundColor": {
"value": "#111111",
"edited": false
},
"page-sidebar-backgroundColor": {
"value": "#333333",
"edited": false
},
"group-textColor": {
"value": "#2a65ee",
"edited": false
},
"group-borderColor": {
"value": "#555555",
"edited": false
},
"group-backgroundColor": {
"value": "#333333",
"edited": false
},
"widget-textColor": {
"value": "#eeeeee",
"edited": false
},
"widget-backgroundColor": {
"value": "#0f43bd",
"edited": false
},
"widget-borderColor": {
"value": "#333333",
"edited": false
},
"base-font": {
"value": "Lucida Sans Typewriter,Lucida
Console,Monaco,monospace"
}
},
"angularTheme": {
"primary": "indigo",
"accents": "blue",
"warn": "red",
"background": "grey",
"palette": "light"
}
},
"site": {
"name": "Node-RED Dashboard",
"hideToolbar": "false",
"allowSwipe": "false",
"lockMenu": "false",
"allowTempTheme": "true",
"dateFormat": "DD/MM/YYYY",
"sizes": {
"sx": 100,
"sy": 48,
"gx": 0,
"gy": 10,
"cx": 10,
"cy": 10,
"px": 0,
"py": 0
}
}
},
{
"id": "c841644d902a5ca1",
"type": "ui_tab",
"name": "DataBase maintenance",
"icon": "fa-wrench",
"order": 2,
"disabled": false,
"hidden": false
},
{
"id": "168eb2751b9f84b4",
"type": "ui_group",
"name": "Borrar DB",
"tab": "c7e0a341ce74d5b8",
"order": 4,
"disp": false,
"width": "2",
"collapse": false,
"className": ""
},
{
"id": "c754fc29ad9ccd9a",
"type": "ui_group",
"name": "Generacion CSV",
"tab": "c841644d902a5ca1",
"order": 1,
"disp": false,
"width": "6",
"collapse": false,
"className": ""
},
{
"id": "6410d05b70e5ba8a",
"type": "ui_group",
"name": "Lectura de datos",
"tab": "c7e0a341ce74d5b8",
"order": 2,
"disp": true,
"width": "7",
"collapse": false,
"className": ""
},
{
"id": "40d8b907.a41218",
"type": "ui_tab",
"name": "Home",
"icon": "dashboard",
"order": 4,
"disabled": false,
"hidden": false
},
{
"id": "c1f8c5797eabe8f9",
"type": "ui_group",
"name": "Fecha",
"tab": "c7e0a341ce74d5b8",
"order": 1,
"disp": false,
"width": 6,
"collapse": false,
"className": ""
},
{
"id": "3547e9f6ea3e65fc",
"type": "ui_group",
"name": "Visor de errores",
"tab": "c841644d902a5ca1",
"order": 4,
"disp": false,
"width": "6",
"collapse": false,
"className": ""
},
{
"id": "160e81fb.f1c86e",
"type": "ui_group",
"name": "File Browser",
"tab": "b63d1f91.68095",
"order": 1,
"disp": true,
"width": 18,
"collapse": false
},
{
"id": "b63d1f91.68095",
"type": "ui_tab",
"name": "Files",
"icon": "folder",
"order": 3,
"disabled": false,
"hidden": false
},
{
"id": "c9fd8de789c50f0a",
"type": "ui_spacer",
"z": "61c9b80ab7459c84",
"name": "spacer",
"group": "160e81fb.f1c86e",
"order": 3,
"width": 14,
"height": 1
},
{
"id": "006aa3a01a28c78d",
"type": "ui_spacer",
"z": "61c9b80ab7459c84",
"name": "spacer",
"group": "160e81fb.f1c86e",
"order": 6,
"width": 1,
"height": 1
},
{
"id": "d314a6298dd14179",
"type": "ui_spacer",
"z": "61c9b80ab7459c84",
"name": "spacer",
"group": "160e81fb.f1c86e",
"order": 8,
"width": 5,
"height": 1
},
{
"id": "babc9472555071bb",
"type": "s7 endpoint",
"transport": "iso-on-tcp",
"address": "192.168.0.2",
"port": "102",
"rack": "0",
"slot": "1",
"localtsaphi": "01",
"localtsaplo": "00",
"remotetsaphi": "01",
"remotetsaplo": "00",
"connmode": "rack-slot",
"adapter": "",
"busaddr": "2",
"cycletime": "30000",
"timeout": "2000",
"name": "Lectura alarmas",
"vartable": [
{
"addr": "M100.0",
"name": "Inyectora en emergencia"
},
{
"addr": "M100.1",
"name": "Puerta abierta"
},
{
"addr": "M100.2",
"name": "Piston atrás"
},
{
"addr": "M100.3",
"name": "Emergencia horno"
},
{
"addr": "M100.4",
"name": "Nivel bajo"
},
{
"addr": "M100.5",
"name": "Maximo tiempo con tubo lleno"
},
{
"addr": "M100.6",
"name": "Vigilancia up manual"
},
{
"addr": "M100.7",
"name": "Electrodo sucio"
},
{
"addr": "M101.0",
"name": "Temperatura máxima dosis"
},
{
"addr": "M101.1",
"name": "Alarma Temperatura"
},
{
"addr": "M101.2",
"name": "Termopar caldo roto"
},
{
"addr": "M101.3",
"name": "Termopar boveda roto"
},
{
"addr": "M101.4",
"name": "Molde no cerrado"
},
{
"addr": "M101.5",
"name": "Sin nitrógeno"
},
{
"addr": "M101.6",
"name": "Fallo predosis"
},
{
"addr": "M101.7",
"name": "Electrodo roto"
},
{
"addr": "M102.0",
"name": "Sin presion acometida de aire"
},
{
"addr": "M102.1",
"name": "Toque fuera de rango"
},
{
"addr": "M102.2",
"name": "Up and down no abajo"
},
{
"addr": "M102.3",
"name": "Up and down no arriba"
},
{
"addr": "M102.5",
"name": "Auto/manual no seleccionado"
},
{
"addr": "M102.6",
"name": "Calentamiento desconectado"
},
{
"addr": "M102.7",
"name": "Permiso de movimiento activo"
},
{
"addr": "M103.0",
"name": "Alarma interface"
},
{
"addr": "M103.1",
"name": "Alarma interface 2"
},
{
"addr": "M103.4",
"name": "Tolva no abierta"
},
{
"addr": "M103.5",
"name": "Tolva no cerrada"
},
{
"addr": "M103.6",
"name": "Fallo fuente de alimentacion"
},
{
"addr": "M103.7",
"name": "Consumo excesivo fase R"
},
{
"addr": "M104.0",
"name": "Consumo excesivo fase S"
},
{
"addr": "M104.1",
"name": "Consumo excesivo fase T"
},
{
"addr": "M104.2",
"name": "Potencia aparente baja"
},
{
"addr": "M104.3",
"name": "Rotura resistencia fase R"
},
{
"addr": "M104.4",
"name": "Rotura resistencia fase S"
},
{
"addr": "M104.5",
"name": "Rotura resistencia fase T"
},
{
"addr": "M104.6",
"name": "Consumo bajo fase R"
},
{
"addr": "M104.7",
"name": "Consumo bajo fase S"
},
{
"addr": "M105.0",
"name": "Consumo bajo fase T"
}
]
},
{
"id": "b3fc33a7555f259f",
"type": "s7 endpoint",
"transport": "iso-on-tcp",
"address": "192.168.0.2",
"port": "102",
"rack": "0",
"slot": "1",
"localtsaphi": "01",
"localtsaplo": "00",
"remotetsaphi": "01",
"remotetsaplo": "00",
"connmode": "rack-slot",
"adapter": "",
"busaddr": "2",
"cycletime": "60000",
"timeout": "3000",
"name": "Lectura valores",
"vartable": [
{
"addr": "MW502",
"name": "SP Boveda"
},
{
"addr": "MW124",
"name": "PV Boveda"
},
{
"addr": "MW500",
"name": "SP Caldo"
},
{
"addr": "MW228",
"name": "PV Caldo"
},
{
"addr": "DB70,R54",
"name": "Nivel"
}
]
},
{
"id": "388aea321477692e",
"type": "ui_group",
"name": "Lectura alarmas",
"tab": "c7e0a341ce74d5b8",
"order": 3,
"disp": true,
"width": "7",
"collapse": false,
"className": ""
},
{
"id": "092f3a0ac6c4207c",
"type": "sqlite",
"z": "4112c200fc8c7519",
"mydb": "ed53b3331ecaacca",
"sqlquery": "msg.topic",
"sql": "SELECT Nivel FROM datos_nivel\nORDER BY Nivel DESC",
"name": "DB DB_WEB",
"x": 810,
"y": 160,
"wires": [
[
"c4e900ea5c54054a"
]
]
},
{
"id": "c4e900ea5c54054a",
"type": "ui_table",
"z": "4112c200fc8c7519",
"group": "6410d05b70e5ba8a",
"name": "Tabla Datos",
"order": 1,
"width": 7,
"height": 7,
"columns": [
{
"field": "Fecha",
"title": "Fecha",
"width": "",
"align": "center",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "Hora",
"title": "Hora",
"width": "",
"align": "center",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "Nivel",
"title": "Nivel",
"width": "",
"align": "center",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "SP Boveda",
"title": "SP Boveda",
"width": "",
"align": "center",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "PV Boveda",
"title": "PV Boveda",
"width": "",
"align": "center",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "SP Caldo",
"title": "SP Caldo",
"width": "",
"align": "center",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "PV Caldo",
"title": "PV Caldo",
"width": "",
"align": "center",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
}
],
"outputs": 0,
"cts": false,
"x": 970,
"y": 160,
"wires": []
},
{
"id": "3b66f20c532f7e58",
"type": "ui_button",
"z": "4112c200fc8c7519",
"name": "",
"group": "168eb2751b9f84b4",
"order": 1,
"width": 2,
"height": 1,
"passthru": false,
"label": "Vaciar base de datos",
"tooltip": "Esto podría dificultar la lectura de los próximos datos. Haced
esto solo si estás seguro",
"color": "black",
"bgcolor": "orange",
"className": "",
"icon": "fa-warning",
"payload": "Introduce el nombre de usuario",
"payloadType": "str",
"topic": "topic",
"topicType": "msg",
"x": 100,
"y": 420,
"wires": [
[
"236111b83f9f8c69"
]
]
},
{
"id": "c50019fa737ec6b5",
"type": "function",
"z": "4112c200fc8c7519",
"name": "VACIAR BASE DE DATOS",
"func": "if (msg.payload == \"Si\"){\n msg.topic = \" DELETE FROM
Alarmas;\";\n msg.payload = \"\"\n} //DELETE FROM datos_PLC;\n \n return
msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 880,
"y": 360,
"wires": [
[
"060eb8c5bb3175a8",
"e007a35601b8b188"
]
]
},
{
"id": "373b2a301757bd81",
"type": "ui_date_picker",
"z": "4112c200fc8c7519",
"name": "",
"label": "Seleccionar fecha",
"group": "c1f8c5797eabe8f9",
"order": 1,
"width": 5,
"height": 1,
"passthru": false,
"topic": "date.format(\"DD/MM/YYYY\")",
"topicType": "str",
"className": "",
"x": 330,
"y": 60,
"wires": [
[
"56142c112f5420ac"
]
]
},
{
"id": "56142c112f5420ac",
"type": "function",
"z": "4112c200fc8c7519",
"name": "Da datos según fecha",
"func": "// Verifica si msg.payload es un número\nif (typeof msg.payload
=== 'number') {\n \n // Convierte el número a un objeto Date\n var
fechaObj = new Date(msg.payload);\n\n // Obtiene los componentes de la fecha\n
var dia = fechaObj.getDate().toString().padStart(2, '0');\n var mes =
(fechaObj.getMonth() + 1).toString().padStart(2, '0');\n var año =
fechaObj.getFullYear();\n\n // Formatea la fecha en el formato DD-MM-YYYY\n
var fechaFormateada = dia + '/' + mes + '/' + año;\n\n // Construye la
instrucción SQL\n msg.topic = \"SELECT * FROM datos_PLC WHERE Fecha = '\" +
fechaFormateada + \"' ORDER BY Fecha DESC, Hora DESC; SELECT * FROM Alarmas WHERE
Fecha = '\" + fechaFormateada + \"' ORDER BY Fecha DESC, Hora DESC\";\n\n //
Asigna la fecha formateada a msg.payload (opcional)\n //msg.payload =
fechaFormateada;\n} else {\n // Si msg.payload no es un número, puedes manejarlo
según tus necesidades\n // Aquí se asume que msg.payload ya está en el formato
deseado\n msg.topic = \"SELECT * FROM datos_PLC WHERE Fecha = '\" +
fechaFormateada + \"' ORDER BY Fecha DESC, Hora DESC; SELECT * FROM Alarmas WHERE
Fecha = '\" + fechaFormateada + \"' ORDER BY Fecha DESC, Hora DESC\";\n}\n\nreturn
msg;\n\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 500,
"y": 120,
"wires": [
[
"092f3a0ac6c4207c"
]
]
},
{
"id": "17f65b33c4daaf8c",
"type": "ui_toast",
"z": "4112c200fc8c7519",
"position": "top right",
"displayTime": "3",
"highlight": "#3FADB5",
"sendall": false,
"outputs": 0,
"ok": "OK",
"cancel": "",
"raw": false,
"className": "",
"topic": "La base de datos se ha vaciado",
"name": "DB VACIO",
"x": 1130,
"y": 420,
"wires": []
},
{
"id": "f4fdf56cd1dc223a",
"type": "ui_button",
"z": "4112c200fc8c7519",
"name": "actualizar a fecha de hoy",
"group": "c1f8c5797eabe8f9",
"order": 2,
"width": 1,
"height": 1,
"passthru": false,
"label": "",
"tooltip": "Introduce la fecha de hoy",
"color": "black",
"bgcolor": "#C0DEED",
"className": "",
"icon": "fa-refresh",
"payload": "",
"payloadType": "date",
"topic": "topic",
"topicType": "str",
"x": 150,
"y": 120,
"wires": [
[
"373b2a301757bd81",
"56142c112f5420ac"
]
]
},
{
"id": "46e4388d128f69c5",
"type": "ui_toast",
"z": "4112c200fc8c7519",
"position": "dialog",
"displayTime": "3",
"highlight": "",
"sendall": false,
"outputs": 1,
"ok": "Si",
"cancel": "No",
"raw": false,
"className": "",
"topic": "",
"name": "Confirmation",
"x": 830,
"y": 480,
"wires": [
[
"8b58acbd4209be04"
]
]
},
{
"id": "3184877974a74f39",
"type": "change",
"z": "4112c200fc8c7519",
"name": "Set message",
"rules": [
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "Confirmación",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "¿Seguro que quieres vaciar la base de datos? Se borrarán
todos los datos registrados. Esto solo se recomienda cada varios años.",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 730,
"y": 420,
"wires": [
[
"46e4388d128f69c5"
]
]
},
{
"id": "8b58acbd4209be04",
"type": "switch",
"z": "4112c200fc8c7519",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "Si",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 930,
"y": 420,
"wires": [
[
"c50019fa737ec6b5"
]
]
},
{
"id": "060eb8c5bb3175a8",
"type": "change",
"z": "4112c200fc8c7519",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "La base está libre de registros",
"tot": "str"
},
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "Se ha vaciado la base de datos",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1120,
"y": 380,
"wires": [
[
"17f65b33c4daaf8c"
]
]
},
{
"id": "46dc741337c28ecb",
"type": "function",
"z": "4112c200fc8c7519",
"name": "Escribir datos en DB",
"func": "var fecha = new Date(); // Puedes reemplazar esto con tu objeto de
fecha existente\n\nvar dia = fecha.getDate();\nvar mes = fecha.getMonth() + 1; //
Meses son indexados desde 0, por lo que se suma 1\nvar año = fecha.getFullYear();\
n// Format day and month to have two digits\ndia = (dia < 10) ? '0' + dia : dia;\
nmes = (mes < 10) ? '0' + mes : mes;\n\nvar formatoDeseado = dia + '/' + mes + '/'
+ año;\n\nvar hora = fecha.getHours();\nvar minuto = fecha.getMinutes();\nvar
segundo = fecha.getSeconds();\n\n// Format hour, minute, and second to have two
digits\nhora = (hora < 10) ? '0' + hora : hora;\nminuto = (minuto < 10) ? '0' +
minuto : minuto;\n\n//CREAMOS LAS VARIABLES CON EL MSG.PAYLOAD RECIBIDO DE LA
LECTURA\nvar hour = hora + ':' + minuto;\n\nvar NIVEL = msg.payload[\"Nivel\"];\
nvar SPBOVEDA = msg.payload[\"SP Boveda\"];\nvar PVBOVEDA = msg.payload[\"PV
Boveda\"];\nvar SPCALDO = msg.payload[\"SP Caldo\"];\nvar PVCALDO =
msg.payload[\"PV Caldo\"];\n\n//CREAMOS AHORA UNA VARIABLE CON EL DATO REFINADO, EL
NIVEL CON MENOS DECIMALES Y LOS DATOS ENTRE 10\nvar NIVEL_REDUCIDO =
parseFloat(NIVEL).toFixed(2).toString();\n// Nuevas variables para SPBOVEDA,
PVBOVEDA, SPCALDO y PVCALDO divididas por 10\nvar SPBOVEDA_DIVIDIDO =
(parseFloat(SPBOVEDA) / 10).toFixed(1);\nvar PVBOVEDA_DIVIDIDO =
(parseFloat(PVBOVEDA) / 10).toFixed(1);\nvar SPCALDO_DIVIDIDO =
(parseFloat(SPCALDO) / 10).toFixed(1);\nvar PVCALDO_DIVIDIDO = (parseFloat(PVCALDO)
/ 10).toFixed(1);\nvar queryInsert = \"INSERT INTO datos_PLC (Fecha, Hora, Nivel,
`SP Boveda`, `PV Boveda`, `SP Caldo`, `PV Caldo`) VALUES ('\" + formatoDeseado
+ \"','\" + hour + \"','\" + NIVEL_REDUCIDO + \"','\" + SPBOVEDA_DIVIDIDO + \"','\"
+ PVBOVEDA_DIVIDIDO + \"','\" + SPCALDO_DIVIDIDO + \"','\" + PVCALDO_DIVIDIDO
+ \"'); SELECT * FROM datos_PLC WHERE Fecha = '\" + formatoDeseado + \"' ORDER BY
Fecha DESC, Hora DESC\";\n\nmsg.topic = queryInsert\n\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 440,
"y": 200,
"wires": [
[
"092f3a0ac6c4207c"
]
]
},
{
"id": "93cc34fdb1ef3cdb",
"type": "s7 in",
"z": "4112c200fc8c7519",
"endpoint": "babc9472555071bb",
"mode": "all",
"variable": "",
"diff": false,
"name": "",
"x": 120,
"y": 300,
"wires": [
[
"c47568ed99c41cbe",
"bdead44e3175b79d"
]
]
},
{
"id": "236111b83f9f8c69",
"type": "ui_toast",
"z": "4112c200fc8c7519",
"position": "prompt",
"displayTime": "3",
"highlight": "",
"sendall": false,
"outputs": 1,
"ok": "Continuar",
"cancel": "Cancelar",
"raw": false,
"className": "",
"topic": "",
"name": "User",
"x": 290,
"y": 420,
"wires": [
[
"5a013d56374a796e"
]
]
},
{
"id": "f814038b6e033b7a",
"type": "s7 in",
"z": "4112c200fc8c7519",
"endpoint": "b3fc33a7555f259f",
"mode": "all",
"variable": "",
"diff": false,
"name": "",
"x": 120,
"y": 200,
"wires": [
[
"46dc741337c28ecb",
"46fb307eecd4d3dc"
]
]
},
{
"id": "c47568ed99c41cbe",
"type": "function",
"z": "4112c200fc8c7519",
"name": "Escribir alarmas en DB",
"func": "var fecha = new Date(); // Puedes reemplazar esto con tu objeto de
fecha existente\n\nvar dia = fecha.getDate();\nvar mes = fecha.getMonth() + 1; //
Meses son indexados desde 0, por lo que se suma 1\nvar año = fecha.getFullYear();\
n// Format day and month to have two digits\ndia = (dia < 10) ? '0' + dia : dia;\
nmes = (mes < 10) ? '0' + mes : mes;\n\nvar formatoDeseado = dia + '/' + mes + '/'
+ año;\n\nvar hora = fecha.getHours();\nvar minuto = fecha.getMinutes();\nvar
segundo = fecha.getSeconds();\n\n// Format hour, minute, and second to have two
digits\nhora = (hora < 10) ? '0' + hora : hora;\nminuto = (minuto < 10) ? '0' +
minuto : minuto;\nvar hour = hora + ':' + minuto;\nvar previousAlarmState =
flow.get(\"previousAlarmState\") || {};\n\n// Filter out the boolean values that
are true and construct SQL queries\nfor (var Alarm in msg.payload) {\n if
(msg.payload.hasOwnProperty(Alarm) && msg.payload[Alarm] === true) {\n var
sqlQuery = \"INSERT OR IGNORE INTO Alarmas (Fecha, Hora, Alarma) VALUES ('\" +
formatoDeseado + \"','\" + hour + \"','\"+Alarm+\"'); SELECT * FROM Alarmas ORDER
BY Fecha DESC, Hora DESC; SELECT * FROM datos_PLC ORDER BY Fecha DESC, Hora
DESC;\";\n }\n if (!previousAlarmState.hasOwnProperty(Alarm) ||
previousAlarmState[Alarm] !== true) {\n // Construct INSERT query for each
true value\n var sqlQuery = \"INSERT OR IGNORE INTO Alarmas (Fecha, Hora,
Alarma) VALUES ('\" + formatoDeseado + \"','\" + hour + \"','\"+Alarm+\"'); SELECT
* FROM Alarmas ORDER BY Fecha DESC, Hora DESC; SELECT * FROM datos_PLC ORDER BY
Fecha DESC, Hora DESC;\";\n }\n if (msg.payload.hasOwnProperty(Alarm) &&
msg.payload[Alarm] === false) {\n var sqlQuery = \"SELECT * FROM Alarmas
ORDER BY Fecha DESC, Hora DESC;\";\n }\n}\n\n// Set the array of SQL queries as
the message payload\nmsg.topic = sqlQuery;\n\nreturn msg;\n\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 480,
"y": 300,
"wires": [
[
"e007a35601b8b188"
]
]
},
{
"id": "1689b386e12269cb",
"type": "ui_table",
"z": "4112c200fc8c7519",
"group": "388aea321477692e",
"name": "Tabla Alarmas",
"order": 1,
"width": 7,
"height": 6,
"columns": [
{
"field": "Fecha",
"title": "Fecha",
"width": "150",
"align": "center",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "Hora",
"title": "Hora",
"width": "100",
"align": "center",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "Alarma",
"title": "Alarma",
"width": "",
"align": "center",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
}
],
"outputs": 0,
"cts": false,
"x": 980,
"y": 300,
"wires": []
},
{
"id": "e007a35601b8b188",
"type": "sqlite",
"z": "4112c200fc8c7519",
"mydb": "ed53b3331ecaacca",
"sqlquery": "msg.topic",
"sql": "SELECT Nivel FROM datos_nivel\nORDER BY Nivel DESC",
"name": "DB DB_WEB",
"x": 810,
"y": 300,
"wires": [
[
"1689b386e12269cb"
]
]
},
{
"id": "46fb307eecd4d3dc",
"type": "delay",
"z": "4112c200fc8c7519",
"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": 290,
"y": 240,
"wires": [
[
"886b47b6746bd6e3"
]
]
},
{
"id": "886b47b6746bd6e3",
"type": "function",
"z": "4112c200fc8c7519",
"name": "Mostrar tabla datos",
"func": "var fecha = new Date(); // Puedes reemplazar esto con tu objeto de
fecha existente\n\nvar dia = fecha.getDate();\nvar mes = fecha.getMonth() + 1; //
Meses son indexados desde 0, por lo que se suma 1\nvar año = fecha.getFullYear();\
n// Format day and month to have two digits\ndia = (dia < 10) ? '0' + dia : dia;\
nmes = (mes < 10) ? '0' + mes : mes;\n\nvar formatoDeseado = dia + '/' + mes + '/'
+ año;\n\nvar hora = fecha.getHours();\nvar minuto = fecha.getMinutes();\nvar
segundo = fecha.getSeconds();\n\n// Format hour, minute, and second to have two
digits\nhora = (hora < 10) ? '0' + hora : hora;\nminuto = (minuto < 10) ? '0' +
minuto : minuto;\n\nvar queryInsert = \"SELECT * FROM datos_PLC WHERE Fecha = '\" +
formatoDeseado + \"' ORDER BY Fecha DESC, Hora DESC\";\n\nmsg.topic = queryInsert\
n\nreturn msg;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 490,
"y": 240,
"wires": [
[
"092f3a0ac6c4207c"
]
]
},
{
"id": "bdead44e3175b79d",
"type": "delay",
"z": "4112c200fc8c7519",
"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": 290,
"y": 340,
"wires": [
[
"bc49effc5f50f979"
]
]
},
{
"id": "bc49effc5f50f979",
"type": "function",
"z": "4112c200fc8c7519",
"name": "Mostrar tabla alarmas",
"func": "var fecha = new Date(); // Puedes reemplazar esto con tu objeto de
fecha existente\n\nvar dia = fecha.getDate();\nvar mes = fecha.getMonth() + 1; //
Meses son indexados desde 0, por lo que se suma 1\nvar año = fecha.getFullYear();\
n// Format day and month to have two digits\ndia = (dia < 10) ? '0' + dia : dia;\
nmes = (mes < 10) ? '0' + mes : mes;\n\nvar formatoDeseado = dia + '/' + mes + '/'
+ año;\n\nvar hora = fecha.getHours();\nvar minuto = fecha.getMinutes();\nvar
segundo = fecha.getSeconds();\n\n// Format hour, minute, and second to have two
digits\nhora = (hora < 10) ? '0' + hora : hora;\nminuto = (minuto < 10) ? '0' +
minuto : minuto;\n\nvar queryInsert = \"SELECT * FROM Alarmas WHERE Fecha = '\" +
formatoDeseado + \"' ORDER BY Fecha DESC, Hora DESC\";\n\nmsg.topic = queryInsert\
n\nreturn msg;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 480,
"y": 340,
"wires": [
[
"e007a35601b8b188"
]
]
},
{
"id": "1912fef60aeb6a11",
"type": "ui_toast",
"z": "4112c200fc8c7519",
"position": "prompt",
"displayTime": "3",
"highlight": "",
"sendall": false,
"outputs": 1,
"ok": "Continuar",
"cancel": "Cancelar",
"raw": false,
"className": "",
"topic": "Introduce la contraseña",
"name": "Password",
"x": 460,
"y": 420,
"wires": [
[
"49aaa8a6b2cd2803"
]
]
},
{
"id": "5a013d56374a796e",
"type": "switch",
"z": "4112c200fc8c7519",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "Cancelar",
"vt": "str"
},
{
"t": "eq",
"v": "admin",
"vt": "str"
},
{
"t": "neq",
"v": "admin",
"vt": "str"
}
],
"checkall": "false",
"repair": false,
"outputs": 3,
"x": 370,
"y": 480,
"wires": [
[],
[
"1912fef60aeb6a11"
],
[
"63499e9ee3f778b7"
]
]
},
{
"id": "54e32d2475d73b56",
"type": "ui_toast",
"z": "4112c200fc8c7519",
"position": "top right",
"displayTime": "3",
"highlight": "#3FADB5",
"sendall": false,
"outputs": 0,
"ok": "OK",
"cancel": "",
"raw": false,
"className": "",
"topic": "",
"name": "insert user",
"x": 170,
"y": 600,
"wires": []
},
{
"id": "63499e9ee3f778b7",
"type": "change",
"z": "4112c200fc8c7519",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Usuario no encontrado",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 160,
"y": 560,
"wires": [
[
"54e32d2475d73b56",
"bdcffe50cb0d9983"
]
]
},
{
"id": "bdcffe50cb0d9983",
"type": "change",
"z": "4112c200fc8c7519",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Introduce el nombre de usuario",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 140,
"y": 480,
"wires": [
[
"236111b83f9f8c69"
]
]
},
{
"id": "49aaa8a6b2cd2803",
"type": "switch",
"z": "4112c200fc8c7519",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "Cancelar",
"vt": "str"
},
{
"t": "eq",
"v": "admin",
"vt": "str"
},
{
"t": "neq",
"v": "admin",
"vt": "str"
}
],
"checkall": "false",
"repair": false,
"outputs": 3,
"x": 590,
"y": 420,
"wires": [
[],
[
"3184877974a74f39"
],
[
"01b46535d9cd9d02"
]
]
},
{
"id": "01b46535d9cd9d02",
"type": "change",
"z": "4112c200fc8c7519",
"name": "",
"rules": [
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "Contraseña incorrecta",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 580,
"y": 480,
"wires": [
[
"ded628015b03c64d"
]
]
},
{
"id": "ded628015b03c64d",
"type": "ui_toast",
"z": "4112c200fc8c7519",
"position": "top right",
"displayTime": "3",
"highlight": "#3FADB5",
"sendall": false,
"outputs": 0,
"ok": "OK",
"cancel": "",
"raw": false,
"className": "",
"topic": "",
"name": "in password",
"x": 590,
"y": 520,
"wires": []
},
{
"id": "1f8a869ea717520c",
"type": "csv",
"z": "d7653bde71c42b94",
"name": "datos_raspberrypi",
"sep": "|",
"hdrin": true,
"hdrout": "all",
"multi": "one",
"ret": "\\r\\n",
"temp": "Fecha,Hora,Nivel,Temperatura",
"skip": "2",
"strings": true,
"include_empty_strings": true,
"include_null_values": false,
"x": 670,
"y": 120,
"wires": [
[
"b5cdbbe7a09b781a"
]
]
},
{
"id": "d7b3793db866cfd2",
"type": "ui_button",
"z": "d7653bde71c42b94",
"name": "",
"group": "c754fc29ad9ccd9a",
"order": 1,
"width": 0,
"height": 0,
"passthru": true,
"label": "Generar CSV",
"tooltip": "Crea archivo excell con los datos de la tabla y los guarda en
una carpeta predeterminada",
"color": "Black",
"bgcolor": "#6FC276",
"className": "",
"icon": "fa-download",
"payload": "true",
"payloadType": "bool",
"topic": "topic",
"topicType": "msg",
"x": 100,
"y": 120,
"wires": [
[
"8285823642500e8a"
]
]
},
{
"id": "8285823642500e8a",
"type": "function",
"z": "d7653bde71c42b94",
"name": "ACTUALIZAR DATOS",
"func": "msg.topic = \"SELECT * FROM datos_PLC ORDER BY Fecha DESC,Hora
DESC\"\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 300,
"y": 120,
"wires": [
[
"aa695d26ee231f02"
]
]
},
{
"id": "aa695d26ee231f02",
"type": "sqlite",
"z": "d7653bde71c42b94",
"mydb": "ed53b3331ecaacca",
"sqlquery": "msg.topic",
"sql": "SELECT Nivel FROM datos_nivel\nORDER BY Nivel DESC",
"name": "DB DB_WEB",
"x": 490,
"y": 120,
"wires": [
[
"1f8a869ea717520c"
]
]
},
{
"id": "c98229e822124a29",
"type": "file",
"z": "d7653bde71c42b94",
"name": "",
"filename": "path",
"filenameType": "msg",
"appendNewline": true,
"createDir": true,
"overwriteFile": "true",
"encoding": "utf8",
"x": 1040,
"y": 120,
"wires": [
[
"64132a102bde9d61"
]
]
},
{
"id": "cd30d23964a4203d",
"type": "ui_toast",
"z": "d7653bde71c42b94",
"position": "top right",
"displayTime": "3",
"highlight": "#3FADB5",
"sendall": false,
"outputs": 0,
"ok": "OK",
"cancel": "",
"raw": false,
"className": "",
"topic": "",
"name": "",
"x": 1390,
"y": 120,
"wires": []
},
{
"id": "7db9f5508844a1fa",
"type": "e-mail",
"z": "d7653bde71c42b94",
"server": "smtp.gmail.com",
"port": "465",
"authtype": "BASIC",
"saslformat": true,
"token": "oauth2Response.access_token",
"secure": true,
"tls": false,
"name": "felipesobrino@krownsa.com",
"dname": "",
"x": 1240,
"y": 260,
"wires": []
},
{
"id": "69b6afd4b1623b8d",
"type": "ui_toast",
"z": "d7653bde71c42b94",
"position": "bottom right",
"displayTime": "4",
"highlight": "#FFCC66",
"sendall": false,
"outputs": 0,
"ok": "OK",
"cancel": "",
"raw": false,
"className": "",
"topic": "",
"name": "",
"x": 530,
"y": 360,
"wires": []
},
{
"id": "b5cdbbe7a09b781a",
"type": "function",
"z": "d7653bde71c42b94",
"name": "FilePath",
"func": "var fecha = new Date();\nvar dia = fecha.getDate();\nvar mes =
fecha.getMonth() + 1; // Months are zero-based, so add 1\nvar año =
fecha.getFullYear();\n\n// Format day and month to have two digits\ndia = (dia <
10) ? '0' + dia : dia;\nmes = (mes < 10) ? '0' + mes : mes;\n\nvar formatoDeseado =
dia + '-' + mes + '-' + año;\nmsg.topic = \"Excell registro datos de horno \"+
formatoDeseado;\nmsg.path =
\"Documents/servidor_raspberry/Archivos_registro/registro_datos \" + formatoDeseado
+ \".csv\";\nreturn msg;\n\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 880,
"y": 120,
"wires": [
[
"c98229e822124a29"
]
]
},
{
"id": "64132a102bde9d61",
"type": "function",
"z": "d7653bde71c42b94",
"name": "function 1",
"func": "// Check if there is an error in the current message\nif
(msg.hasOwnProperty(\"error\")) {\n node.error(\"Error al generar archivo\",
msg);\n} else {\n msg.payload = \"Archivo generado correctamente\";\n}\n\nreturn
msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1200,
"y": 120,
"wires": [
[
"cd30d23964a4203d"
]
]
},
{
"id": "153a15ea8a627d59",
"type": "ui_button",
"z": "d7653bde71c42b94",
"name": "",
"group": "e732f9804aee6074",
"order": 1,
"width": 0,
"height": 0,
"passthru": true,
"label": "Enviar correo",
"tooltip": "Envia un correo a la dirección acordada con Krown",
"color": "Black",
"bgcolor": "#FF0000",
"className": "",
"icon": "mail",
"payload": "true",
"payloadType": "bool",
"topic": "topic",
"topicType": "msg",
"x": 90,
"y": 260,
"wires": [
[
"d771c316520c7b7c"
]
]
},
{
"id": "44a5f9cc679c283d",
"type": "csv",
"z": "d7653bde71c42b94",
"name": "datos_raspberrypi",
"sep": "|",
"hdrin": true,
"hdrout": "all",
"multi": "one",
"ret": "\\r\\n",
"temp": "Fecha,Hora,Nivel,Temperatura",
"skip": "2",
"strings": true,
"include_empty_strings": true,
"include_null_values": false,
"x": 730,
"y": 260,
"wires": [
[
"b6ed3afa765cdbf3"
]
]
},
{
"id": "d771c316520c7b7c",
"type": "function",
"z": "d7653bde71c42b94",
"name": "ACTUALIZAR DATOS",
"func": "msg.topic = \"SELECT * FROM datos_PLC ORDER BY Fecha DESC,Hora
DESC\"\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 300,
"y": 260,
"wires": [
[
"6ae571713bc439a6"
]
]
},
{
"id": "6ae571713bc439a6",
"type": "sqlite",
"z": "d7653bde71c42b94",
"mydb": "ed53b3331ecaacca",
"sqlquery": "msg.topic",
"sql": "SELECT Nivel FROM datos_nivel\nORDER BY Nivel DESC",
"name": "DB DB_WEB",
"x": 510,
"y": 260,
"wires": [
[
"44a5f9cc679c283d"
]
]
},
{
"id": "b6ed3afa765cdbf3",
"type": "function",
"z": "d7653bde71c42b94",
"name": "función nombre correo",
"func": "try {\n // Tu lógica principal aquí\n // Si la lógica
principal tiene éxito\n var fecha = new Date();\n var dia = fecha.getDate();\
n var mes = fecha.getMonth() + 1; // Months are zero-based, so add 1\n var
año = fecha.getFullYear();\n\n // Format day and month to have two digits\n
dia = (dia < 10) ? '0' + dia : dia;\n mes = (mes < 10) ? '0' + mes : mes;\n\n
var formatoDeseado = dia + '-' + mes + '-' + año;\n msg.topic = \"Excell
registro datos de horno \" + formatoDeseado;\n // Envía el mensaje modificado\n
return msg; \n} \ncatch (error) {\n // Si hay un error\n msg.topic = \"Error
al enviar email\";\n msg.payload = \"Compruebe la conexión a Internet\";\n \n
// Puedes imprimir el error en la consola para obtener más detalles\n
console.error(error);\n}\n\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 960,
"y": 260,
"wires": [
[
"7db9f5508844a1fa",
"be0188e01f84a2d3"
]
]
},
{
"id": "adf64715991b2057",
"type": "ui_toast",
"z": "d7653bde71c42b94",
"position": "top right",
"displayTime": "3",
"highlight": "#3FADB5",
"sendall": false,
"outputs": 0,
"ok": "OK",
"cancel": "",
"raw": false,
"className": "",
"topic": "",
"name": "",
"x": 1250,
"y": 340,
"wires": []
},
{
"id": "202424fe4c1fad72",
"type": "change",
"z": "d7653bde71c42b94",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Comprueba conexion a internet",
"tot": "str"
},
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "Error al enviar Email",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 300,
"y": 360,
"wires": [
[
"69b6afd4b1623b8d"
]
]
},
{
"id": "be0188e01f84a2d3",
"type": "change",
"z": "d7653bde71c42b94",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Correo enviado satisfactoriamente",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1040,
"y": 340,
"wires": [
[
"adf64715991b2057"
]
]
},
{
"id": "4ae70fccaf123877",
"type": "catch",
"z": "d7653bde71c42b94",
"name": "",
"scope": [
"7db9f5508844a1fa"
],
"uncaught": false,
"x": 70,
"y": 360,
"wires": [
[
"202424fe4c1fad72",
"254393c294f0f500"
]
]
},
{
"id": "254393c294f0f500",
"type": "debug",
"z": "d7653bde71c42b94",
"name": "debug 4",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 300,
"y": 440,
"wires": []
},
{
"id": "4fa73dd9.83cca4",
"type": "comment",
"z": "61c9b80ab7459c84",
"name": "File Browser",
"info": "1) Update the default folder in the Init node\n2) Update the
default folder in the Reset node as well\n3) You can duplicate the Reset nodes and
use them as saved shortcuts\n4) Check the Convert Timestamps function node if you
want to see your dates in a different format. I just used the Javascript
toISOString format.\n5) The Graph button can read any CSV file which have any
number of values, but the first column always contains a timestamp column with
javascript timestamp of the data point.",
"x": 150,
"y": 40,
"wires": []
},
{
"id": "d185a45.2327a58",
"type": "inject",
"z": "61c9b80ab7459c84",
"name": "Init",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "change",
"payload": "Documents/servidor_raspberry/Archivos_registro",
"payloadType": "str",
"x": 150,
"y": 160,
"wires": [
[
"3d4e5e51.bdf952"
]
]
},
{
"id": "a715f7a4.a398a8",
"type": "ui_button",
"z": "61c9b80ab7459c84",
"name": "",
"group": "160e81fb.f1c86e",
"order": 1,
"width": 2,
"height": 1,
"passthru": false,
"label": "Refresh",
"tooltip": "",
"color": "",
"bgcolor": "",
"className": "",
"icon": "refresh",
"payload": "",
"payloadType": "str",
"topic": "refresh",
"topicType": "str",
"x": 140,
"y": 200,
"wires": [
[
"3d4e5e51.bdf952"
]
]
},
{
"id": "eb17c7ee.e61988",
"type": "ui_dropdown",
"z": "61c9b80ab7459c84",
"name": "File Selector",
"label": "",
"tooltip": "",
"place": "Select a file",
"group": "160e81fb.f1c86e",
"order": 5,
"width": 5,
"height": 1,
"passthru": false,
"multiple": false,
"options": [
{
"label": "",
"value": "",
"type": "str"
}
],
"payload": "",
"topic": "",
"topicType": "str",
"className": "",
"x": 1350,
"y": 140,
"wires": [
[
"be4830df.5775d"
]
]
},
{
"id": "dd88bd23.37cde",
"type": "function",
"z": "61c9b80ab7459c84",
"name": "Format data",
"func": "// format the data for the dropdown\nmsg.options = [];\nfor (var
i=0; i<msg.payload.length; i++) {\n // This is a file\n var file = {};\n
file [msg.payload[i].name.replace(/^.*(\\\\|\\/|\\:)/, '')]=msg.payload[i].name;\n
msg.options.push(file);\n}\nmsg.payload={};\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1150,
"y": 140,
"wires": [
[
"eb17c7ee.e61988"
]
]
},
{
"id": "638728aa.cd0b08",
"type": "ui_template",
"z": "61c9b80ab7459c84",
"group": "160e81fb.f1c86e",
"name": "",
"order": 4,
"width": 18,
"height": 4,
"format": "<div ng-bind-html=\"msg.payload\" height=\"400\" style=\"height:
400px;\"><br/>\n</div>\n\n",
"storeOutMessages": true,
"fwdInMessages": true,
"templateScope": "local",
"x": 1540,
"y": 200,
"wires": [
[]
]
},
{
"id": "9d27e846.b31db8",
"type": "template",
"z": "61c9b80ab7459c84",
"name": "",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "<table width=\"100%\">\n <tr><th>File
Name</th><th>Size</th><th>Created</th><th>Changed</th></tr>\n {{#payload}}\n
<tr>\n <td><a href=\"/download?filename={{name}}\"
target=\"blank\">{{fname}}</a></td>\n <td>{{stat.size}}</td>\n
<td>{{stat.created}}</td>\n <td>{{stat.changed}}</td>\n </tr>\n
{{/payload}}\n</table>\n",
"output": "str",
"x": 1380,
"y": 200,
"wires": [
[
"638728aa.cd0b08"
]
]
},
{
"id": "3e094f82.15d6e",
"type": "function",
"z": "61c9b80ab7459c84",
"name": "Convert timestamps",
"func": "for (var i=0; i<msg.payload.length; i++) {\n
msg.payload[i].stat.created = msg.payload[i].stat.created.toISOString().slice(0,
19).replace('T', ' ');\n msg.payload[i].stat.changed =
msg.payload[i].stat.changed.toISOString().slice(0, 19).replace('T', ' ');\n
msg.payload[i].stat.accessed = msg.payload[i].stat.accessed.toISOString().slice(0,
19).replace('T', ' ');\n msg.payload[i].stat.statusChanged =
msg.payload[i].stat.statusChanged.toISOString().slice(0, 19).replace('T', ' ');\n
msg.payload[i].fname = msg.payload[i].name.replace(/^.*(\\\\|\\/|\\:)/, '');\n}\
nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1180,
"y": 200,
"wires": [
[
"9d27e846.b31db8"
]
]
},
{
"id": "7b7e0d58.05e244",
"type": "ui_button",
"z": "61c9b80ab7459c84",
"name": "",
"group": "160e81fb.f1c86e",
"order": 10,
"width": 18,
"height": 1,
"passthru": false,
"label": "ELIMINAR",
"tooltip": "Elimina el archivo seleccionado",
"color": "black",
"bgcolor": "red",
"className": "",
"icon": "delete",
"payload": "",
"payloadType": "str",
"topic": "",
"topicType": "str",
"x": 150,
"y": 320,
"wires": [
[
"8da8147a.999af8"
]
]
},
{
"id": "7d490dd1.8458b4",
"type": "function",
"z": "61c9b80ab7459c84",
"name": "Get filename",
"func": "// Get the filename from the flow context\nlet filename =
flow.get(\"fileselected\");\n\n// check, if the filename is undefined that means it
does not exist yet, nothing is selected yet\n// return: do not output anything\nif
(filename===undefined) {\n return;\n}\n\n// return the filename to the file-in
node to delete\nmsg.filename = filename;\n\nif
(msg.filename.replace(/^.*(\\\\|\\/|\\:)/, '')[0]!==\".\") {\n // Only do this
if this is a file, we don't delete folders\n // and delete the context/selection
as we are deleting the file as well\n flow.set(\"fileselected\");\n return
msg;\n}",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 550,
"y": 380,
"wires": [
[
"372ee262.fc94de"
]
]
},
{
"id": "372ee262.fc94de",
"type": "file",
"z": "61c9b80ab7459c84",
"name": "Delete file",
"filename": "filename",
"filenameType": "msg",
"appendNewline": true,
"createDir": false,
"overwriteFile": "delete",
"encoding": "none",
"x": 740,
"y": 380,
"wires": [
[
"993d7272.843ae",
"5219875b.c070d8"
]
]
},
{
"id": "aa8c482.93734b8",
"type": "http in",
"z": "61c9b80ab7459c84",
"name": "",
"url": "/download",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 140,
"y": 500,
"wires": [
[
"d969ba04.e24028"
]
]
},
{
"id": "d19cc7d8.646328",
"type": "http response",
"z": "61c9b80ab7459c84",
"name": "",
"statusCode": "",
"headers": {},
"x": 930,
"y": 500,
"wires": []
},
{
"id": "d969ba04.e24028",
"type": "function",
"z": "61c9b80ab7459c84",
"name": "Get the file name",
"func": "msg.filename = msg.req.query.filename;\nmsg.contentdisposition
= \"attachment; filename=\\\"\" +
msg.req.query.filename.replace(/^.*(\\\\|\\/|\\:)/, '') + \"\\\"\";\nreturn msg;\
n",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 390,
"y": 500,
"wires": [
[
"e92381c3.c4cd2"
]
],
"outputLabels": [
"Folder selected"
]
},
{
"id": "e92381c3.c4cd2",
"type": "file in",
"z": "61c9b80ab7459c84",
"name": "",
"filename": "filename",
"filenameType": "msg",
"format": "",
"chunk": false,
"sendError": false,
"encoding": "none",
"allProps": false,
"x": 580,
"y": 500,
"wires": [
[
"99ff4953.d0d5c8"
]
]
},
{
"id": "99ff4953.d0d5c8",
"type": "change",
"z": "61c9b80ab7459c84",
"name": "Set Headers",
"rules": [
{
"t": "set",
"p": "headers",
"pt": "msg",
"to": "{}",
"tot": "json"
},
{
"t": "set",
"p": "headers.content-type",
"pt": "msg",
"to": "text/csv",
"tot": "str"
},
{
"t": "set",
"p": "headers.Content-Disposition",
"pt": "msg",
"to": "contentdisposition",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 750,
"y": 500,
"wires": [
[
"d19cc7d8.646328"
]
]
},
{
"id": "554f0095.ac1b2",
"type": "ui_toast",
"z": "61c9b80ab7459c84",
"position": "dialog",
"displayTime": "3",
"highlight": "",
"sendall": false,
"outputs": 1,
"ok": "Yes",
"cancel": "No",
"raw": false,
"className": "",
"topic": "",
"name": "Confirmation",
"x": 690,
"y": 300,
"wires": [
[
"24df84fe.ebf45c"
]
]
},
{
"id": "8da8147a.999af8",
"type": "change",
"z": "61c9b80ab7459c84",
"name": "Set message",
"rules": [
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "Delete confirmation",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Are you sure you want to delete this file?",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 490,
"y": 300,
"wires": [
[
"554f0095.ac1b2"
]
]
},
{
"id": "24df84fe.ebf45c",
"type": "switch",
"z": "61c9b80ab7459c84",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "Yes",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 930,
"y": 300,
"wires": [
[
"7d490dd1.8458b4"
]
]
},
{
"id": "3d4e5e51.bdf952",
"type": "function",
"z": "61c9b80ab7459c84",
"name": "Folder handling",
"func": "let folder = context.get(\"folder\");\nif (folder===undefined) {\n
folder=\"/\";\n context.set(\"folder\", folder);\n}\n\nlet hidden =
context.get(\"hidden\");\nif (hidden===undefined) {\n hidden=false;\n
context.set(\"hidden\", hidden);\n}\n\nif (msg.topic===\"up\") {\n var the_arr =
folder.split('/');\n the_arr.pop();\n folder=the_arr.join('/'); \n
context.set(\"folder\", folder);\n}\nif (msg.topic===\"change\") {\n
folder=msg.payload; \n context.set(\"folder\", folder);\n}\nif
(msg.topic===\"hidden\") {\n hidden=msg.payload; \n
context.set(\"hidden\", hidden);\n}\n\nmsg.payload = {\"start\":folder, \"hidden\":
hidden};\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 480,
"y": 200,
"wires": [
[
"993d7272.843ae",
"5219875b.c070d8"
]
]
},
{
"id": "80940e39.5035b",
"type": "ui_button",
"z": "61c9b80ab7459c84",
"d": true,
"name": "",
"group": "160e81fb.f1c86e",
"order": 7,
"width": 2,
"height": 1,
"passthru": false,
"label": "Open",
"tooltip": "",
"color": "",
"bgcolor": "",
"className": "",
"icon": "folder_open",
"payload": "",
"payloadType": "str",
"topic": "",
"topicType": "str",
"x": 110,
"y": 380,
"wires": [
[
"8c1dfaac.979588"
]
]
},
{
"id": "8c1dfaac.979588",
"type": "function",
"z": "61c9b80ab7459c84",
"name": "Change folder",
"func": "// Get the filename from the flow context\nlet folderselected =
flow.get(\"folderselected\");\n\n// check, if the filename is undefined that means
it does not exist yet, nothing is selected yet\n// return: do not output anything\
nif (folderselected===undefined) {\n return;\n}\n\nmsg.topic = \"change\";\
nmsg.payload = folderselected;\n\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 280,
"y": 380,
"wires": [
[
"3d4e5e51.bdf952"
]
]
},
{
"id": "37485c24.212054",
"type": "ui_dropdown",
"z": "61c9b80ab7459c84",
"d": true,
"name": "Folder Selector",
"label": "",
"tooltip": "",
"place": "Select a folder",
"group": "160e81fb.f1c86e",
"order": 9,
"width": 5,
"height": 1,
"passthru": false,
"multiple": false,
"options": [
{
"label": "",
"value": "",
"type": "str"
}
],
"payload": "",
"topic": "",
"topicType": "str",
"className": "",
"x": 1360,
"y": 240,
"wires": [
[
"2875c79f.531558"
]
]
},
{
"id": "ebc234be.d53fe8",
"type": "function",
"z": "61c9b80ab7459c84",
"d": true,
"name": "Format data",
"func": "// format the data for the dropdown\nmsg.options = [];\nfor (var
i=0; i<msg.payload.length; i++) {\n // This is a foler\n var obj = {};\n
obj [\"[\"+msg.payload[i].name.replace(/^.*(\\\\|\\/|\\:)/, '')
+\"]\"]=msg.payload[i].name;\n msg.options.push(obj);\n}\nmsg.payload={};\
nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1150,
"y": 240,
"wires": [
[
"37485c24.212054"
]
]
},
{
"id": "be4830df.5775d",
"type": "change",
"z": "61c9b80ab7459c84",
"name": "Save selection",
"rules": [
{
"t": "set",
"p": "fileselected",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1560,
"y": 140,
"wires": [
[]
]
},
{
"id": "2875c79f.531558",
"type": "change",
"z": "61c9b80ab7459c84",
"name": "Save selection",
"rules": [
{
"t": "set",
"p": "folderselected",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1560,
"y": 240,
"wires": [
[]
]
},
{
"id": "928e60a7.994be",
"type": "ui_switch",
"z": "61c9b80ab7459c84",
"name": "",
"label": "Hidden",
"tooltip": "Show hidden files or not",
"group": "160e81fb.f1c86e",
"order": 2,
"width": 2,
"height": 1,
"passthru": false,
"decouple": "false",
"topic": "hidden",
"topicType": "str",
"style": "",
"onvalue": "true",
"onvalueType": "bool",
"onicon": "check_box",
"oncolor": "#FFFFFF",
"offvalue": "false",
"offvalueType": "bool",
"officon": "check_box_outline_blank",
"offcolor": "#FFFFFF",
"animate": true,
"className": "",
"x": 140,
"y": 260,
"wires": [
[
"3d4e5e51.bdf952"
]
]
},
{
"id": "993d7272.843ae",
"type": "fs-file-lister",
"z": "61c9b80ab7459c84",
"name": "Files",
"start": "Documents/servidor_raspberry/Archivos_registro",
"pattern": "*.*",
"folders": "*",
"hidden": false,
"lstype": "files",
"path": true,
"single": true,
"depth": 0,
"stat": true,
"showWarnings": false,
"x": 950,
"y": 140,
"wires": [
[
"dd88bd23.37cde",
"3e094f82.15d6e"
]
]
},
{
"id": "5219875b.c070d8",
"type": "fs-file-lister",
"z": "61c9b80ab7459c84",
"name": "Folders",
"start": "Documents/servidor_raspberry/Archivos_registro",
"pattern": "*.*",
"folders": "*",
"hidden": false,
"lstype": "directories",
"path": true,
"single": true,
"depth": 0,
"stat": true,
"showWarnings": false,
"x": 960,
"y": 240,
"wires": [
[
"ebc234be.d53fe8"
]
]
},
{
"id": "7fa33f28061a62c6",
"type": "ui_text_input",
"z": "1819625cc50921ea",
"name": "",
"label": "Introduce tu correo",
"tooltip": "",
"group": "e732f9804aee6074",
"order": 4,
"width": 0,
"height": 0,
"passthru": false,
"mode": "text",
"delay": "0",
"topic": "topic",
"sendOnBlur": true,
"className": "",
"topicType": "msg",
"x": 250,
"y": 100,
"wires": [
[]
]
},
{
"id": "d074282197a60a8c",
"type": "function",
"z": "1819625cc50921ea",
"name": "File email recipient",
"func": "\n//var fecha = new Date();\n//var dia = fecha.getDate();\n//var
mes = fecha.getMonth() + 1; // Months are zero-based, so add 1\n//var año =
fecha.getFullYear();\n\n// Format day and month to have two digits\n//dia = (dia <
10) ? '0' + dia : dia;\n//mes = (mes < 10) ? '0' + mes : mes;\n\n//var
formatoDeseado = dia + '-' + mes + '-' + año;\n//msg.topic = \"Excell registro
datos de horno \"+ formatoDeseado;\n//msg.path =
\"Documents/servidor_raspberry/Archivos_registro/registro_datos \" + formatoDeseado
+ \".csv\";\n//return msg;\n\n// Assuming msg.payload contains the email address\
nvar emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\nif
(emailRegex.test(msg.payload)) {\n var fecha = new Date();\n var dia =
fecha.getDate();\n var mes = fecha.getMonth() + 1; // Months are zero-based, so
add 1\n var año = fecha.getFullYear();\n\n // Format day and month to have
two digits\n dia = (dia < 10) ? '0' + dia : dia;\n mes = (mes < 10) ? '0' +
mes : mes;\n\n var formatoDeseado = dia + '-' + mes + '-' + año;\n \n
msg.topic = \"Excell registro datos de horno \" + formatoDeseado;\n \n \
n // Add your email sending logic here\n // For example, if you're using the
Email node in Node-RED:\n //msg.payload = \"Email body content\"; // Set the
email body\n msg.to = msg.payload; // Set the recipient email address\n \n
//msg.subject = \"Email Subject\"; // Set the email subject\n\n // Return the
modified message for further processing in the flow\n return msg;\n} else {\n
node.warn(\"Invalid email address entered\");\n return null; // or any other
appropriate action\n}\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 450,
"y": 100,
"wires": [
[]
]
},
{
"id": "9d11295232f99926",
"type": "ui_toast",
"z": "1819625cc50921ea",
"position": "bottom right",
"displayTime": "4",
"highlight": "#FFCC66",
"sendall": false,
"outputs": 0,
"ok": "OK",
"cancel": "",
"raw": false,
"className": "",
"topic": "",
"name": "",
"x": 590,
"y": 280,
"wires": []
},
{
"id": "c25b4be8208c9d60",
"type": "ui_toast",
"z": "1819625cc50921ea",
"position": "top right",
"displayTime": "3",
"highlight": "#3FADB5",
"sendall": false,
"outputs": 0,
"ok": "OK",
"cancel": "",
"raw": false,
"className": "",
"topic": "",
"name": "",
"x": 630,
"y": 220,
"wires": []
},
{
"id": "0ad3745041cb357d",
"type": "change",
"z": "1819625cc50921ea",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Comprueba conexion a internet",
"tot": "str"
},
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "Error al enviar Email",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 400,
"y": 280,
"wires": [
[
"9d11295232f99926"
]
]
},
{
"id": "c513937e2623b216",
"type": "change",
"z": "1819625cc50921ea",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Correo enviado satisfactoriamente",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 420,
"y": 220,
"wires": [
[
"c25b4be8208c9d60"
]
]
},
{
"id": "2e54b123c74ace4b",
"type": "switch",
"z": "1819625cc50921ea",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "Mensaje enviado",
"vt": "str"
},
{
"t": "eq",
"v": "Compruebe la conexión a Internet",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 150,
"y": 240,
"wires": [
[
"c513937e2623b216"
],
[
"0ad3745041cb357d"
]
]
},
{
"id": "89e45fa63748e28a",
"type": "ui_button",
"z": "1819625cc50921ea",
"d": true,
"name": "",
"group": "6410d05b70e5ba8a",
"order": 2,
"width": 0,
"height": 0,
"passthru": false,
"label": "Actualizar datos",
"tooltip": "Lee base de datos",
"color": "Black",
"bgcolor": "#6FC276",
"className": "",
"icon": "fa-refresh",
"payload": "",
"payloadType": "str",
"topic": "topic",
"topicType": "msg",
"x": 180,
"y": 480,
"wires": [
[
"3dc585c72401c416"
]
]
},
{
"id": "042a7e834f35bb45",
"type": "function",
"z": "1819625cc50921ea",
"name": "ACTUALIZAR DATOS",
"func": "msg.topic = \"SELECT * FROM datos_PLC ORDER BY Fecha DESC, Hora
DESC\"\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 580,
"y": 480,
"wires": [
[]
]
},
{
"id": "3dc585c72401c416",
"type": "delay",
"z": "1819625cc50921ea",
"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": 360,
"y": 480,
"wires": [
[
"042a7e834f35bb45"
]
]
},
{
"id": "094851de45212f5e",
"type": "s7 in",
"z": "1819625cc50921ea",
"endpoint": "babc9472555071bb",
"mode": "all",
"variable": "I0",
"diff": false,
"name": "Lectura temp y nivel",
"x": 1010,
"y": 360,
"wires": [
[]
]
},
{
"id": "fdd733c58709dc59",
"type": "function",
"z": "1819625cc50921ea",
"name": "LEER PLC",
"func": "var fecha = new Date(); // Puedes reemplazar esto con tu objeto de
fecha existente\n\nvar dia = fecha.getDate();\nvar mes = fecha.getMonth() + 1; //
Meses son indexados desde 0, por lo que se suma 1\nvar año = fecha.getFullYear();\
n// Format day and month to have two digits\ndia = (dia < 10) ? '0' + dia : dia;\
nmes = (mes < 10) ? '0' + mes : mes;\n\nvar formatoDeseado = dia + '/' + mes + '/'
+ año;\n\nvar hora = fecha.getHours();\nvar minuto = fecha.getMinutes();\nvar
segundo = fecha.getSeconds();\n\n// Format hour, minute, and second to have two
digits\nhora = (hora < 10) ? '0' + hora : hora;\nminuto = (minuto < 10) ? '0' +
minuto : minuto;\n\nvar hour = hora + ':' + minuto;\n\n\nmsg.topic = \"INSERT OR
IGNORE INTO datos_PLC (Fecha,Hora,Nivel,Temperatura) VALUES ('\" + formatoDeseado +
\"','\" + hour + \"','500','500'); SELECT * FROM datos_PLC ORDER BY Fecha DESC,
Hora DESC\";\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1010,
"y": 400,
"wires": [
[]
]
},
{
"id": "cdcb6d91283cf632",
"type": "delay",
"z": "1819625cc50921ea",
"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": 960,
"y": 460,
"wires": [
[
"4ba813b0490b6de0"
]
]
},
{
"id": "4ba813b0490b6de0",
"type": "function",
"z": "1819625cc50921ea",
"d": true,
"name": "MOSTRAR DATOS",
"func": "var fecha = new Date(); // Puedes reemplazar esto con tu objeto de
fecha existente\n\nvar dia = fecha.getDate();\nvar mes = fecha.getMonth() + 1; //
Meses son indexados desde 0, por lo que se suma 1\nvar año = fecha.getFullYear();\
n// Format day and month to have two digits\ndia = (dia < 10) ? '0' + dia : dia;\
nmes = (mes < 10) ? '0' + mes : mes;\n\nvar formatoDeseado = dia + '/' + mes + '/'
+ año;\n\nvar hora = fecha.getHours();\nvar minuto = fecha.getMinutes();\nvar
segundo = fecha.getSeconds();\n\n// Format hour, minute, and second to have two
digits\nhora = (hora < 10) ? '0' + hora : hora;\nminuto = (minuto < 10) ? '0' +
minuto : minuto;\n\nvar hour = hora + ':' + minuto;\n\nmsg.topic = \"SELECT * FROM
datos_PLC WHERE Fecha = '\" +formatoDeseado+ \"' ORDER BY Fecha DESC, Hora DESC\"\
nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1150,
"y": 460,
"wires": [
[]
]
},
{
"id": "a5716f05eac9b1b8",
"type": "function",
"z": "1819625cc50921ea",
"name": "Muestra datos de hoy",
"func": "var fecha = new Date(); // Puedes reemplazar esto con tu objeto de
fecha existente\n\nvar dia = fecha.getDate();\nvar mes = fecha.getMonth() + 1; //
Meses son indexados desde 0, por lo que se suma 1\nvar año = fecha.getFullYear();\
n// Format day and month to have two digits\ndia = (dia < 10) ? '0' + dia : dia;\
nmes = (mes < 10) ? '0' + mes : mes;\n\nvar formatoDeseado = dia + '/' + mes + '/'
+ año;\n\nvar hora = fecha.getHours();\nvar minuto = fecha.getMinutes();\nvar
segundo = fecha.getSeconds();\n\n// Format hour, minute, and second to have two
digits\nhora = (hora < 10) ? '0' + hora : hora;\nminuto = (minuto < 10) ? '0' +
minuto : minuto;\n\nvar hour = hora + ':' + minuto;\n\nmsg.topic = \"SELECT * FROM
datos_PLC WHERE Fecha = '\" +formatoDeseado+ \"' ORDER BY Fecha DESC, Hora DESC\"\
nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1020,
"y": 520,
"wires": [
[]
]
},
{
"id": "dd1ca16a7a792d45",
"type": "function",
"z": "1819625cc50921ea",
"name": "verificar user y password",
"func": "var inicio = false;\n\n\n//while (inicio === false){\n //if
(msg.in_username === msg.username){\n // if (msg.in_password ===
msg.password){\n // msg.payload = \"OK\"\n // inicio = true;\
n // }\n //}\n //else{\n //msg.payload = \"Usuario o contraseña
incorrectas\"\n //}\n//}\n//return msg;\n\n// Verificar si se ha proporcionado
un nombre de usuario y una contraseña\nif (msg.in_username !== undefined &&
msg.in_password !== undefined) {\n // Verificar si el nombre de usuario y la
contraseña coinciden\n if (msg.in_username === msg.username && msg.in_password
=== msg.password) {\n // Credenciales correctas\n msg.payload
= \"OK\";\n } else {\n // Nombre de usuario o contraseña incorrectos\n
msg.payload = \"Usuario o contraseña incorrectos\";\n }\n} \nelse {\n //
Nombre de usuario o contraseña no proporcionados\n //msg.payload = \"Por favor,
proporcione tanto el nombre de usuario como la contraseña\";\n}\n\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 950,
"y": 660,
"wires": [
[]
]
}
]

You might also like