8
n8n 中文网amn8n.com

通过Spook集成将E.ON W1000电能表数据导入Home Assistant

高级

这是一个自动化工作流,包含 46 个节点。主要使用 If, Set, Code, Gmail, Merge 等节点。 通过Spook集成将E.ON W1000电能表数据导入Home Assistant

前置要求
  • Google 账号和 Gmail API 凭证

分类

-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "4a5b18b7956bb13cea42c4f3d7e9bb71b32449d237a47746edc89eb39825abfa"
  },
  "nodes": [
    {
      "id": "631c332d-9840-419a-ae30-2717f7eee7a9",
      "name": "从文件提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -176,
        288
      ],
      "parameters": {
        "options": {},
        "operation": "xlsx",
        "binaryPropertyName": "attachment_0"
      },
      "typeVersion": 1
    },
    {
      "id": "84c8fd03-9fe3-4d7e-bd1d-db12fba92358",
      "name": "重命名\"*_1\"键以合并",
      "type": "n8n-nodes-base.renameKeys",
      "position": [
        336,
        192
      ],
      "parameters": {
        "keys": {
          "key": [
            {
              "newKey": "start",
              "currentKey": "Időbélyeg"
            },
            {
              "newKey": "AM",
              "currentKey": "Érték_1"
            }
          ]
        },
        "additionalOptions": {}
      },
      "typeVersion": 1
    },
    {
      "id": "8131bd99-2aae-47ee-8065-f376ecbb86eb",
      "name": "获取最后5条消息",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -1296,
        320
      ],
      "webhookId": "d48f4845-7cc0-49b4-8c53-56a838465f7e",
      "parameters": {
        "limit": 5,
        "filters": {
          "sender": "noreply@eon.com"
        },
        "operation": "getAll"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "ctBdwDxIkxFWYxhN",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1,
      "alwaysOutputData": true
    },
    {
      "id": "b939f7c5-3b21-4406-a9d3-f69125a96800",
      "name": "聚合ID",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        -848,
        336
      ],
      "parameters": {
        "options": {
          "mergeLists": false
        },
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "id"
            },
            {
              "fieldToAggregate": "internalDate"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ddfbda91-1b00-4ab4-998c-93db8acd6a95",
      "name": "获取消息[0]",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -624,
        336
      ],
      "webhookId": "2a28f6f9-b2d9-4d3b-a398-fc6a624fbea3",
      "parameters": {
        "simple": false,
        "options": {
          "downloadAttachments": true
        },
        "messageId": "={{ $json.id[0] }}",
        "operation": "get"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "ctBdwDxIkxFWYxhN",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "249022c5-fc9d-4030-82f6-4065fe1c9ad7",
      "name": "重命名\"*_1\"键以合并1",
      "type": "n8n-nodes-base.renameKeys",
      "position": [
        336,
        384
      ],
      "parameters": {
        "keys": {
          "key": [
            {
              "newKey": "start",
              "currentKey": "Időbélyeg"
            },
            {
              "newKey": "1_8_0",
              "currentKey": "Érték_2"
            }
          ]
        },
        "additionalOptions": {}
      },
      "typeVersion": 1
    },
    {
      "id": "42aac2f4-7b4b-4e48-91e2-ec9b4863443b",
      "name": "重命名\"*_1\"键以合并2",
      "type": "n8n-nodes-base.renameKeys",
      "position": [
        336,
        672
      ],
      "parameters": {
        "keys": {
          "key": [
            {
              "newKey": "start",
              "currentKey": "Időbélyeg"
            },
            {
              "newKey": "2_8_0",
              "currentKey": "Érték_3"
            }
          ]
        },
        "additionalOptions": {}
      },
      "typeVersion": 1
    },
    {
      "id": "889c7b85-64c8-4f19-bd99-c2a56d6228b6",
      "name": "从源数据提取默认数据(+A)",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        112,
        0
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "Időbélyeg,Érték"
      },
      "typeVersion": 1
    },
    {
      "id": "c04db25d-4461-4db8-a420-c6a9a2fec53a",
      "name": "从源数据提取'*_1'数据(-A)",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        112,
        192
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "Időbélyeg,Érték_1"
      },
      "typeVersion": 1
    },
    {
      "id": "091a5ad7-89b5-43f2-b59f-3abec3e13d7e",
      "name": "从源数据提取'*_2'数据(1_8_0)",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        112,
        384
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "Időbélyeg,Érték_2"
      },
      "typeVersion": 1
    },
    {
      "id": "2a12d83f-353d-41ba-bb9e-137d56718052",
      "name": "从源数据提取'*_3'数据(2_8_0)",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        112,
        672
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "Időbélyeg,Érték_3"
      },
      "typeVersion": 1
    },
    {
      "id": "cb8a13c8-e461-4ae0-80b6-b24d55b8197a",
      "name": "合并(+A; -A)",
      "type": "n8n-nodes-base.merge",
      "position": [
        560,
        96
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "joinMode": "keepEverything",
        "fieldsToMatchString": "['start']"
      },
      "typeVersion": 3.2
    },
    {
      "id": "6e606abd-8594-4715-8c94-edfc0362798a",
      "name": "重命名\"*_1\"键以合并3",
      "type": "n8n-nodes-base.renameKeys",
      "position": [
        336,
        0
      ],
      "parameters": {
        "keys": {
          "key": [
            {
              "newKey": "start",
              "currentKey": "Időbélyeg"
            },
            {
              "newKey": "AP",
              "currentKey": "Érték"
            }
          ]
        },
        "additionalOptions": {}
      },
      "typeVersion": 1
    },
    {
      "id": "8309f812-4ee1-4b71-ae15-019e0dc3cf87",
      "name": "合并(+A; -A)1",
      "type": "n8n-nodes-base.merge",
      "position": [
        560,
        480
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "joinMode": "keepEverything",
        "fieldsToMatchString": "['start']"
      },
      "typeVersion": 3.2
    },
    {
      "id": "a59136fd-54c4-4965-94e0-ce89ef68ef97",
      "name": "合并(+A; -A)2",
      "type": "n8n-nodes-base.merge",
      "position": [
        784,
        192
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "joinMode": "keepEverything",
        "fieldsToMatchString": "['start']"
      },
      "typeVersion": 3.2
    },
    {
      "id": "d3a58b39-51cd-41ff-b0a9-e8730119f92a",
      "name": "计算小时总和和",
      "type": "n8n-nodes-base.code",
      "position": [
        1600,
        192
      ],
      "parameters": {
        "jsCode": "// INPUT: items with { start, AP, AM, 1_8_0?, 2_8_0? }\n// OUTPUT: grouped hourly results with cumulative meters\n\nfunction toNum(x, def = 0) {\n  if (x === undefined || x === null || x === '') return def;\n  const n = Number(x);\n  return isNaN(n) ? def : n;\n}\n\n// --- group by hour ---\nconst grouped = {};\nfor (const item of items) {\n  const j = item.json;\n  const hour = j.start; // here already rounded to full hour\n  if (!grouped[hour]) {\n    grouped[hour] = { start: hour, AP: 0, AM: 0, m180: null, m280: null };\n  }\n  grouped[hour].AP += toNum(j.AP);\n  grouped[hour].AM += toNum(j.AM);\n  if (j['1_8_0'] !== undefined) grouped[hour].m180 = toNum(j['1_8_0']);\n  if (j['2_8_0'] !== undefined) grouped[hour].m280 = toNum(j['2_8_0']);\n}\n\n// --- sort by time ---\nconst hours = Object.values(grouped).sort((a, b) => new Date(a.start) - new Date(b.start));\n\n// --- build output ---\nlet last180 = null;\nlet last280 = null;\n\nconst out = [];\nfor (const h of hours) {\n  // if new meter values present -> reset base\n  if (h.m180 !== null) last180 = h.m180;\n  if (h.m280 !== null) last280 = h.m280;\n\n  // if no base yet (e.g. very first row), initialize with sums\n  if (last180 === null) last180 = 0;\n  if (last280 === null) last280 = 0;\n\n  const start180 = last180;\n  const start280 = last280;\n\n  const end180 = start180 + h.AP;\n  const end280 = start280 + h.AM;\n\n  // update for next iteration\n  last180 = end180;\n  last280 = end280;\n\n  out.push({\n    json: {\n      start: h.start,\n      AP: h.AP.toFixed(3),\n      AM: h.AM.toFixed(3),\n      '1_8_0': start180.toFixed(3),\n      '2_8_0': start280.toFixed(3),\n    }\n  });\n}\n\nreturn out;"
      },
      "typeVersion": 2
    },
    {
      "id": "8fb7b834-6899-4c70-916d-1386fc2063db",
      "name": "Spook: 更新+A历史数据1",
      "type": "n8n-nodes-base.homeAssistant",
      "position": [
        2416,
        96
      ],
      "parameters": {
        "domain": "recorder",
        "service": "import_statistics",
        "resource": "service",
        "operation": "call",
        "serviceAttributes": {
          "attributes": [
            {
              "name": "statistic_id",
              "value": "sensor.grid_energy_import"
            },
            {
              "name": "source",
              "value": "recorder"
            },
            {
              "name": "unit_of_measurement",
              "value": "kWh"
            },
            {
              "name": "has_mean",
              "value": "={{false}}"
            },
            {
              "name": "has_sum",
              "value": "={{ true }}"
            },
            {
              "name": "stats",
              "value": "={{ $json.data }}"
            }
          ]
        }
      },
      "credentials": {
        "homeAssistantApi": {
          "id": "5Q1lnmAQrn337KpP",
          "name": "Home Assistant account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "64031015-27d2-4ae5-9ccd-135ae36d7fcd",
      "name": "Spook: 更新-A历史数据1",
      "type": "n8n-nodes-base.homeAssistant",
      "position": [
        2416,
        288
      ],
      "parameters": {
        "domain": "recorder",
        "service": "import_statistics",
        "resource": "service",
        "operation": "call",
        "serviceAttributes": {
          "attributes": [
            {
              "name": "statistic_id",
              "value": "sensor.grid_energy_export"
            },
            {
              "name": "source",
              "value": "recorder"
            },
            {
              "name": "unit_of_measurement",
              "value": "kWh"
            },
            {
              "name": "has_mean",
              "value": "={{false}}"
            },
            {
              "name": "has_sum",
              "value": "={{ true }}"
            },
            {
              "name": "stats",
              "value": "={{ $json.data }}"
            }
          ]
        }
      },
      "credentials": {
        "homeAssistantApi": {
          "id": "5Q1lnmAQrn337KpP",
          "name": "Home Assistant account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "49db5891-53f2-45ad-882c-ca65dc6b02ec",
      "name": "为统计生成1_8_0列表",
      "type": "n8n-nodes-base.set",
      "position": [
        1968,
        96
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={\n  \"start\": {{new Date($json.start)}},\n  \"state\": {{ $json['1_8_0'] }},\n  \"sum\": {{ $json['1_8_0'] }}\n}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "4e496d23-514a-4a0e-9903-ef0ded711fc6",
      "name": "为统计生成2_8_0列表",
      "type": "n8n-nodes-base.set",
      "position": [
        1968,
        288
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={\n  \"start\": {{new Date($json.start)}},\n  \"state\": {{ $json['2_8_0'] }},\n  \"sum\": {{ $json['2_8_0'] }}\n}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "ac9ea82a-3d2c-49ef-8440-82ab0aa47713",
      "name": "生成1_8_0统计",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        2192,
        96
      ],
      "parameters": {
        "include": "specifiedFields",
        "options": {},
        "aggregate": "aggregateAllItemData",
        "fieldsToInclude": "start,state, sum"
      },
      "typeVersion": 1
    },
    {
      "id": "81712ea5-dfc9-4988-be79-238bb31f4a28",
      "name": "生成2_8_0统计",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        2192,
        288
      ],
      "parameters": {
        "include": "specifiedFields",
        "options": {},
        "aggregate": "aggregateAllItemData",
        "fieldsToInclude": "start,state, sum"
      },
      "typeVersion": 1
    },
    {
      "id": "c86a07b6-5ade-4ba0-a317-e75da9c7c091",
      "name": "更新input_number.exportt实体状态1",
      "type": "n8n-nodes-base.homeAssistant",
      "position": [
        2832,
        288
      ],
      "parameters": {
        "state": "={{ $('Generate 2_8_0 stats').item.json.data.at(-1).state }}",
        "entityId": "input_number.grid_export_meter",
        "resource": "state",
        "operation": "upsert"
      },
      "credentials": {
        "homeAssistantApi": {
          "id": "5Q1lnmAQrn337KpP",
          "name": "Home Assistant account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6a0092b7-172d-47a8-8fd2-1be198bf542e",
      "name": "更新input_number.import实体状态1",
      "type": "n8n-nodes-base.homeAssistant",
      "position": [
        2832,
        96
      ],
      "parameters": {
        "state": "={{ $('Generate 1_8_0 stats').item.json.data.at(-1).state }}",
        "entityId": "input_number.grid_import_meter",
        "resource": "state",
        "operation": "upsert"
      },
      "credentials": {
        "homeAssistantApi": {
          "id": "5Q1lnmAQrn337KpP",
          "name": "Home Assistant account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ae61e4e5-4441-49a0-88a3-a660483cd958",
      "name": "Gmail 触发器",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -1296,
        512
      ],
      "parameters": {
        "filters": {
          "sender": "noreply@eon.com",
          "labelIds": []
        },
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "ctBdwDxIkxFWYxhN",
          "name": "Gmail account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b16e04c4-e7cc-4ea1-9328-ef26e9741602",
      "name": "计划触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1520,
        320
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 14
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "96bed2da-2176-410f-9810-01a1607b07c7",
      "name": "如果attachment_0是xlsx",
      "type": "n8n-nodes-base.if",
      "position": [
        -400,
        336
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "3b78aa20-1a72-4d43-9428-d754e9a51c55",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.subject }}",
              "rightValue": "[EON-W1000]"
            },
            {
              "id": "a046b65a-72b7-4eff-b97a-ad09acc1e753",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{$binary.attachment_0 ? true : false}}",
              "rightValue": ""
            },
            {
              "id": "4cfbc149-f429-4a68-a908-95e7db6906c6",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ [\"xls\", \"xlsx\"].includes($binary.attachment_0.fileExtension.toLowerCase()) }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "7f5378b1-aa34-4ba1-9375-302c4f242e64",
      "name": "无操作,不执行任何操作1",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -176,
        512
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "48003569-a556-4107-a48b-a9a13862e7f2",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1616,
        -64
      ],
      "parameters": {
        "width": 1616,
        "height": 896,
        "content": "# 主题和附件检查"
      },
      "typeVersion": 1
    },
    {
      "id": "b4db1439-e373-411c-aacd-cf4757af58f6",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32,
        -336
      ],
      "parameters": {
        "width": 912,
        "height": 1168,
        "content": "# 列映射"
      },
      "typeVersion": 1
    },
    {
      "id": "2fc06f65-1720-414d-a945-3fd938f4e857",
      "name": "邮件触发器(IMAP)",
      "type": "n8n-nodes-base.emailReadImap",
      "position": [
        -624,
        672
      ],
      "parameters": {
        "options": {
          "customEmailConfig": "=[\"UNSEEN\",[\"OR\",[\"FROM\",\"noreply@eon.com\"],[\"SUBJECT\",\"[EON-W1000]\"]]]"
        },
        "downloadAttachments": true
      },
      "typeVersion": 2.1
    },
    {
      "id": "a4e84c72-f998-45f3-949b-f55f3da3730a",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1616,
        -848
      ],
      "parameters": {
        "color": 2,
        "width": 688,
        "height": 752,
        "content": "# E.ON W1000 → n8n → Home Assistant (Spook) — 概述"
      },
      "typeVersion": 1
    },
    {
      "id": "de554edc-2b14-4a22-b6e3-b890962e8142",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -288,
        -1184
      ],
      "parameters": {
        "color": 2,
        "width": 624,
        "height": 192,
        "content": "# 需要配置的凭据"
      },
      "typeVersion": 1
    },
    {
      "id": "6051e276-de9e-4629-8af3-3c278d301507",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1600,
        272
      ],
      "parameters": {
        "color": 5,
        "height": 208,
        "content": "## 计划触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "69312661-e8bb-45e4-ba65-056805504df5",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1376,
        464
      ],
      "parameters": {
        "color": 5,
        "height": 208,
        "content": "## Gmail触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "07ef2161-472f-4d58-a0e3-d7cf56e40b91",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -704,
        624
      ],
      "parameters": {
        "color": 5,
        "height": 208,
        "content": "## IMAP触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "41d12eca-181d-4ed3-b0df-663659815142",
      "name": "检查邮件主题",
      "type": "n8n-nodes-base.if",
      "position": [
        -1072,
        416
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "3b78aa20-1a72-4d43-9428-d754e9a51c55",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.Subject }}",
              "rightValue": "[EON-W1000]"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "882d8e14-710c-4869-83d1-0ac06cb9c9c6",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        944,
        -16
      ],
      "parameters": {
        "width": 448,
        "height": 368,
        "content": "# 时间转换"
      },
      "typeVersion": 1
    },
    {
      "id": "47b0ac45-6718-426c-8c5d-469d948daf94",
      "name": "转换日期时间为Spook格式",
      "type": "n8n-nodes-base.dateTime",
      "position": [
        1232,
        192
      ],
      "parameters": {
        "date": "={{ $json['start'] }}",
        "format": "custom",
        "options": {
          "includeInputFields": true
        },
        "operation": "formatDate",
        "customFormat": "yyyy-MM-dd HH:00:00ZZ",
        "outputFieldName": "start"
      },
      "typeVersion": 2
    },
    {
      "id": "b4f079d8-e58c-45d6-8a59-1954729d3c37",
      "name": "转换Excel时间",
      "type": "n8n-nodes-base.dateTime",
      "position": [
        1008,
        192
      ],
      "parameters": {
        "options": {
          "includeInputFields": true
        },
        "duration": "={{ $json['start'] + 0.00000001}}",
        "timeUnit": "=days",
        "magnitude": "1899-12-30",
        "operation": "addToDate",
        "outputFieldName": "start"
      },
      "typeVersion": 2
    },
    {
      "id": "99a605b5-0e6c-41ca-aea6-394ef8b0b028",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1408,
        -288
      ],
      "parameters": {
        "width": 448,
        "height": 640,
        "content": "# 小时分组逻辑(Code节点)"
      },
      "typeVersion": 1
    },
    {
      "id": "f93df5c7-2d9a-4a0b-aebe-ebc51d0bd488",
      "name": "便签9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1872,
        -144
      ],
      "parameters": {
        "width": 816,
        "height": 608,
        "content": "# recorder.import_statistics负载"
      },
      "typeVersion": 1
    },
    {
      "id": "0884b829-04ad-4643-a412-ef2a986d242a",
      "name": "便签 10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2704,
        -176
      ],
      "parameters": {
        "width": 448,
        "height": 640,
        "content": "# 更新的实体ID"
      },
      "typeVersion": 1
    },
    {
      "id": "d7742880-2443-45eb-8838-859c6f613643",
      "name": "便签11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -288,
        -768
      ],
      "parameters": {
        "color": 2,
        "width": 624,
        "height": 272,
        "content": "# 故障排除"
      },
      "typeVersion": 1
    },
    {
      "id": "4a0c69b2-8e61-434e-aa6b-54e6b31975f8",
      "name": "便签 12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -288,
        -976
      ],
      "parameters": {
        "color": 2,
        "width": 624,
        "height": 192,
        "content": "# 安全与隐私"
      },
      "typeVersion": 1
    },
    {
      "id": "7a95c640-56c2-4e8b-a1bd-923200046f94",
      "name": "便签 13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -912,
        -1184
      ],
      "parameters": {
        "color": 2,
        "width": 608,
        "height": 1088,
        "content": "# Home Assistant先决条件"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Aggregate_id": {
      "main": [
        [
          {
            "node": "Get a message[0]",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Check Email Subject",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge (+A; -A)": {
      "main": [
        [
          {
            "node": "Merge (+A; -A)2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge (+A; -A)1": {
      "main": [
        [
          {
            "node": "Merge (+A; -A)2",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge (+A; -A)2": {
      "main": [
        [
          {
            "node": "Convert Excel time",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get a message[0]": {
      "main": [
        [
          {
            "node": "If attachment_0 is xlsx",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get last 5 messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Extract default data from source (+A)",
            "type": "main",
            "index": 0
          },
          {
            "node": "Extract '*_1' data from source (-A)",
            "type": "main",
            "index": 0
          },
          {
            "node": "Extract '*_2' data from source (1_8_0)",
            "type": "main",
            "index": 0
          },
          {
            "node": "Extract '*_3' data from source (2_8_0)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert Excel time": {
      "main": [
        [
          {
            "node": "Convert datetime to Spook format",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Email Subject": {
      "main": [
        [
          {
            "node": "Aggregate_id",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get last 5 messages": {
      "main": [
        [
          {
            "node": "Check Email Subject",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Trigger (IMAP)": {
      "main": [
        [
          {
            "node": "If attachment_0 is xlsx",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate 1_8_0 stats": {
      "main": [
        [
          {
            "node": "Spook: update +A hitorical data1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate 2_8_0 stats": {
      "main": [
        [
          {
            "node": "Spook: update -A hitorical data1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If attachment_0 is xlsx": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate hourly sum and": {
      "main": [
        [
          {
            "node": "Generate 1_8_0 list for stats",
            "type": "main",
            "index": 0
          },
          {
            "node": "Generate 2_8_0 list for stats",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Rename \"*_1\" keys for merge": {
      "main": [
        [
          {
            "node": "Merge (+A; -A)",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Rename \"*_1\" keys for merge1": {
      "main": [
        [
          {
            "node": "Merge (+A; -A)1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Rename \"*_1\" keys for merge2": {
      "main": [
        [
          {
            "node": "Merge (+A; -A)1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Rename \"*_1\" keys for merge3": {
      "main": [
        [
          {
            "node": "Merge (+A; -A)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate 1_8_0 list for stats": {
      "main": [
        [
          {
            "node": "Generate 1_8_0 stats",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate 2_8_0 list for stats": {
      "main": [
        [
          {
            "node": "Generate 2_8_0 stats",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert datetime to Spook format": {
      "main": [
        [
          {
            "node": "Calculate hourly sum and",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Spook: update +A hitorical data1": {
      "main": [
        [
          {
            "node": "Update input_number.import entity state1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Spook: update -A hitorical data1": {
      "main": [
        [
          {
            "node": "Update input_number.exportt entity state1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract '*_1' data from source (-A)": {
      "main": [
        [
          {
            "node": "Rename \"*_1\" keys for merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract default data from source (+A)": {
      "main": [
        [
          {
            "node": "Rename \"*_1\" keys for merge3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract '*_2' data from source (1_8_0)": {
      "main": [
        [
          {
            "node": "Rename \"*_1\" keys for merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract '*_3' data from source (2_8_0)": {
      "main": [
        [
          {
            "node": "Rename \"*_1\" keys for merge2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量46
分类-
节点类型16
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

外部链接
在 n8n.io 查看

分享此工作流