AutomationFlowsData & Sheets › Sistema Monitoreo Fatiga Operadores

Sistema Monitoreo Fatiga Operadores

Sistema Monitoreo Fatiga Operadores. Uses httpRequest, supabase. Scheduled trigger; 9 nodes.

Cron / scheduled trigger★★★★☆ complexity9 nodesHTTP RequestSupabase
Data & Sheets Trigger: Cron / scheduled Nodes: 9 Complexity: ★★★★☆ Added:

This workflow follows the HTTP Request → Supabase recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "Sistema Monitoreo Fatiga Operadores",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 3
            }
          ]
        }
      },
      "id": "cron-trigger",
      "name": "Programador Ejecuci\u00f3n",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "url": "={{ $vars.API_DISPOSITIVOS_URL }}",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $vars.API_DISPOSITIVOS_TOKEN }}"
            }
          ]
        },
        "options": {
          "timeout": 30000
        }
      },
      "id": "ingesta-datos",
      "name": "Ingesta Datos Dispositivos",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const datos = $input.all();\nconst datosLimpios = [];\n\nfor (const item of datos) {\n  const datosRaw = item.json;\n  \n  let datosNormalizados = {};\n  \n  if (datosRaw.device_type === 'smartwatch') {\n    datosNormalizados = {\n      dispositivo_id: datosRaw.device_id,\n      timestamp: new Date(datosRaw.timestamp),\n      hrv: datosRaw.hrv || null,\n      spo2: datosRaw.blood_oxygen || datosRaw.spo2 || null,\n      frecuencia_cardiaca: datosRaw.heart_rate || null,\n      temperatura_piel: datosRaw.skin_temperature || null,\n      sueno_duracion: datosRaw.sleep_duration || null,\n      sueno_profundo: datosRaw.deep_sleep || null,\n      pasos: datosRaw.steps || null,\n      calorias: datosRaw.calories || null\n    };\n  } else if (datosRaw.device_type === 'banda_antifatiga') {\n    datosNormalizados = {\n      dispositivo_id: datosRaw.device_id,\n      timestamp: new Date(datosRaw.timestamp),\n      postura_angulo: datosRaw.posture_angle || null,\n      actividad_muscular: datosRaw.muscle_activity || null,\n      movimientos_anomalos: datosRaw.abnormal_movements || 0,\n      micro_suenos: datosRaw.micro_sleeps || 0\n    };\n  }\n  \n  Object.keys(datosNormalizados).forEach(key => {\n    if (typeof datosNormalizados[key] === 'number') {\n      if (key === 'hrv' && (datosNormalizados[key] < 0 || datosNormalizados[key] > 200)) {\n        datosNormalizados[key] = null;\n      }\n      if (key === 'spo2' && (datosNormalizados[key] < 70 || datosNormalizados[key] > 100)) {\n        datosNormalizados[key] = null;\n      }\n      if (key === 'frecuencia_cardiaca' && (datosNormalizados[key] < 40 || datosNormalizados[key] > 200)) {\n        datosNormalizados[key] = null;\n      }\n    }\n  });\n  \n  datosLimpios.push(datosNormalizados);\n}\n\nreturn datosLimpios;"
      },
      "id": "limpieza-datos",
      "name": "Limpieza y Estandarizaci\u00f3n",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        680,
        300
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const cleanedData = $input.all();\nconst enrichedData = [];\n\nconst deviceOperatorMap = {\n  'sw_001': { id: 1, nombre: 'Juan', turno: 'dia', maquina: 'excavadora' },\n  'sw_002': { id: 2, nombre: 'Mar\u00eda', turno: 'noche', maquina: 'gr\u00faa' },\n  'bf_001': { id: 1, nombre: 'Juan', turno: 'dia', maquina: 'excavadora' },\n  'bf_002': { id: 2, nombre: 'Mar\u00eda', turno: 'noche', maquina: 'gr\u00faa' }\n};\n\nfor (const item of cleanedData) {\n  const operatorInfo = deviceOperatorMap[item.json.dispositivo_id];\n  \n  if (operatorInfo) {\n    const now = new Date();\n    const hour = now.getHours();\n    let horasTurno = 0;\n    \n    if (operatorInfo.turno === 'dia') {\n      horasTurno = hour >= 6 && hour < 18 ? hour - 6 : 0;\n    } else if (operatorInfo.turno === 'noche') {\n      horasTurno = hour >= 18 || hour < 6 ? (hour >= 18 ? hour - 18 : hour + 6) : 0;\n    }\n    \n    enrichedData.push({\n      ...item.json,\n      id_operador: operatorInfo.id,\n      nombre_operador: operatorInfo.nombre,\n      tipo_maquina: operatorInfo.maquina,\n      turno_trabajo: operatorInfo.turno,\n      horas_turno: horasTurno,\n      condiciones_climaticas: {\n        temperatura: 22.5,\n        humedad: 65,\n        condiciones: 'parcialmente_nublado'\n      },\n      timestamp_contexto: new Date()\n    });\n  }\n}\n\nreturn enrichedData;"
      },
      "id": "contexto-operativo",
      "name": "Agregar Contexto Operativo",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        900,
        300
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const datosCompletos = $input.all();\nconst predicciones = [];\n\nfunction calcularIndiceFatiga(datos) {\n  let indice = 50;\n  \n  if (datos.hrv) {\n    const factorHRV = Math.max(0, (60 - datos.hrv) / 60 * 40);\n    indice += factorHRV;\n  }\n  \n  if (datos.spo2 && datos.spo2 < 95) {\n    indice += (95 - datos.spo2) * 2;\n  }\n  \n  if (datos.postura_angulo && Math.abs(datos.postura_angulo) > 30) {\n    indice += 20;\n  }\n  \n  if (datos.micro_suenos) {\n    indice += datos.micro_suenos * 10;\n  }\n  \n  if (datos.movimientos_anomalos) {\n    indice += datos.movimientos_anomalos * 5;\n  }\n  \n  if (datos.turno_trabajo === 'noche') {\n    indice += 15;\n  }\n  \n  if (datos.horas_turno > 8) {\n    indice += (datos.horas_turno - 8) * 2;\n  }\n  \n  return Math.max(0, Math.min(100, Math.round(indice * 100) / 100));\n}\n\nfunction clasificarRiesgo(indice) {\n  if (indice < 30) return 'bajo';\n  if (indice < 60) return 'medio';\n  if (indice < 80) return 'alto';\n  return 'critico';\n}\n\nfor (const item of datosCompletos) {\n  const indiceFatiga = calcularIndiceFatiga(item.json);\n  const clasificacion = clasificarRiesgo(indiceFatiga);\n  \n  predicciones.push({\n    ...item.json,\n    indice_fatiga: indiceFatiga,\n    clasificacion_riesgo: clasificacion,\n    timestamp_prediccion: new Date()\n  });\n}\n\nreturn predicciones;"
      },
      "id": "modelo-ml",
      "name": "Modelo ML - Predicci\u00f3n Fatiga",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1120,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "indice-fatiga-alto",
              "leftValue": "={{ $json.indice_fatiga }}",
              "rightValue": "60",
              "operator": {
                "type": "number",
                "operation": "largerEqual"
              }
            }
          ],
          "combinator": "or"
        }
      },
      "id": "logica-alertas",
      "name": "L\u00f3gica de Alertas",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        1340,
        240
      ]
    },
    {
      "parameters": {
        "operation": "insert",
        "tableId": "alertas",
        "options": {
          "returning": "representation"
        }
      },
      "id": "crear-alerta",
      "name": "Crear Alerta en BD",
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        1560,
        180
      ],
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "url": "={{ $vars.STREAMLIT_WEBHOOK_URL }}/api/alertas",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $vars.STREAMLIT_WEBHOOK_TOKEN }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "operador_id",
              "value": "={{ $json.id_operador }}"
            },
            {
              "name": "indice_fatiga",
              "value": "={{ $json.indice_fatiga }}"
            },
            {
              "name": "nivel_alerta",
              "value": "={{ $json.clasificacion_riesgo }}"
            },
            {
              "name": "timestamp",
              "value": "={{ $json.timestamp }}"
            }
          ]
        },
        "options": {
          "timeout": 5000
        }
      },
      "id": "notificar-frontend",
      "name": "Notificar Frontend Streamlit",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        1560,
        300
      ]
    },
    {
      "parameters": {
        "operation": "insert",
        "tableId": "metricas_procesadas",
        "options": {
          "returning": "representation"
        }
      },
      "id": "guardar-metricas",
      "name": "Guardar M\u00e9tricas Procesadas",
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        1340,
        420
      ],
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Programador Ejecuci\u00f3n": {
      "main": [
        [
          {
            "node": "Ingesta Datos Dispositivos",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ingesta Datos Dispositivos": {
      "main": [
        [
          {
            "node": "Limpieza y Estandarizaci\u00f3n",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limpieza y Estandarizaci\u00f3n": {
      "main": [
        [
          {
            "node": "Agregar Contexto Operativo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Agregar Contexto Operativo": {
      "main": [
        [
          {
            "node": "Modelo ML - Predicci\u00f3n Fatiga",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Modelo ML - Predicci\u00f3n Fatiga": {
      "main": [
        [
          {
            "node": "L\u00f3gica de Alertas",
            "type": "main",
            "index": 0
          },
          {
            "node": "Guardar M\u00e9tricas Procesadas",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "L\u00f3gica de Alertas": {
      "main": [
        [
          {
            "node": "Crear Alerta en BD",
            "type": "main",
            "index": 0
          },
          {
            "node": "Notificar Frontend Streamlit",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [],
  "triggerCount": 1,
  "updatedAt": "2025-11-11T00:00:00.000Z",
  "versionId": "1"
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Sistema Monitoreo Fatiga Operadores. Uses httpRequest, supabase. Scheduled trigger; 9 nodes.

Source: https://github.com/Alexxxxpur/Sistemas-de-Gestion-de-Fatiga--Claude-ZAI-DeepSeek--Lab12/blob/e730f8e59060658404b9c477625a377f6983c83c/deepseek/n8n/workflow.json — original creator credit. Request a take-down →

More Data & Sheets workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Data & Sheets

This workflow solves a common problem with RSS feeds: they often only provide a short summary or snippet of the full article. This template automatically monitors a list of your favorite blog RSS feed

HTTP Request, RSS Feed Read, Supabase
Data & Sheets

This workflow is a multi-system document synchronization pipeline built in n8n, designed to automatically sync and back up files between Microsoft SharePoint, Supabase/Postgres, and Google Drive.

HTTP Request, Supabase, Postgres +1
Data & Sheets

03 - Recordatorio 4h (CON VERIFICACIÓN) ✅. Uses supabase, httpRequest, twilio. Scheduled trigger; 17 nodes.

Supabase, HTTP Request, Twilio
Data & Sheets

02 - Recordatorio 24h antes (CON VERIFICACIÓN) ✅. Uses supabase, httpRequest, twilio. Scheduled trigger; 17 nodes.

Supabase, HTTP Request, Twilio
Data & Sheets

• Fetches IT-related tenders from the French BOAMP API (filter: informatique) • Scores each tender with OpenAI (pertinence, budget, stack, GO/NO-GO) • Routes to Supabase as hot (≥75) or archived • Run

HTTP Request, Supabase