([^<]+)<\\/div>\\s*
([^<]+)<\\/div>\\s*<\\/div>/g;\n\nconst rows = [];\nfor (const m of html.matchAll(re)) {\n const adresse = m[1].trim();\n const label = m[2].trim();\n const raw = m[3].trim();\n\n const { value, unit, currency } = parseNumUnit(raw);\n const key = slug(label);\n\n rows.push({\n Adresse: adresse,\n Bezeichnung: label,\n Wert: (value !== null ? value : raw), // Zahl bevorzugt, sonst Rohstring\n Einheit: unit || '',\n Waehrung: currency || '',\n Raw: raw,\n Key: key\n });\n}\n\n// 3) Als **einzelne Items** zurückgeben (ein Item pro Wert/Zeile)\nreturn rows.map(r => ({ json: r }));\n"
- },
- "type": "n8n-nodes-base.code",
- "typeVersion": 2,
- "position": [
- 224,
- 192
- ],
- "id": "8f08ee8b-d3eb-4d7e-baa7-6fad114e40b0",
- "name": "Code in JavaScript2"
- },
- {
- "parameters": {
- "jsCode": "// INPUT: 19 Items vom Parser (Adresse, Bezeichnung, Wert, Einheit, Waehrung, Key)\n// OUTPUT: 1 Item mit vielen Feldern: leistung, tageszaehlerstand, ...\n\nconst out = {};\nconst units = {}; // falls du Einheiten brauchst\n\nfor (const it of items) {\n const j = it.json;\n // Zahl bevorzugt, sonst Rohstring\n out[j.Key] = (j.Wert ?? j.Raw ?? null);\n if (j.Einheit) units[j.Key] = j.Einheit;\n if (j.Waehrung) units[j.Key] = (units[j.Key] ? units[j.Key] + ' ' : '') + j.Waehrung;\n}\n\n// Ein einziges Item zurückgeben\nreturn [{ json: { ...out, _units: units } }];\n"
- },
- "type": "n8n-nodes-base.code",
- "typeVersion": 2,
- "position": [
- 448,
- 192
- ],
- "id": "d1a4e45e-854b-4359-8da0-3e85f0c41dc4",
- "name": "Code in JavaScript3"
- },
- {
- "parameters": {
- "operation": "upsert",
- "table": {
- "__rl": true,
- "value": "Waermepumpe",
- "mode": "list",
- "cachedResultName": "Waermepumpe"
- },
- "dataMode": "defineBelow",
- "columnToMatchOn": "Datum",
- "valueToMatchOn": "={{ $now.toFormat('yyyy-MM-dd')}}",
- "valuesToSend": {
- "values": [
- {
- "column": "Tagesverbrauch",
- "value": "={{ $json.tageszahlerstand }}"
- }
- ]
- },
- "options": {}
- },
- "type": "n8n-nodes-base.mySql",
- "typeVersion": 2.5,
- "position": [
- 672,
- 0
- ],
- "id": "797700c3-040b-4a27-b621-68e806b65730",
- "name": "update Tagesverbrauch mysql",
- "credentials": {
- "mySql": {
- "id": "GvOnFzLTFlbKtgUM",
- "name": "MySQL account - homelab"
- }
- }
- },
- {
- "parameters": {
- "operation": "upsert",
- "table": {
- "__rl": true,
- "value": "Waermepumpe",
- "mode": "list",
- "cachedResultName": "Waermepumpe"
- },
- "dataMode": "defineBelow",
- "columnToMatchOn": "Datum",
- "valueToMatchOn": "={{ $now.toFormat('yyyy-MM-dd')}}",
- "valuesToSend": {
- "values": [
- {
- "column": "Anteil PV",
- "value": "={{ $json.tageszahlerstand }}"
- }
- ]
- },
- "options": {}
- },
- "type": "n8n-nodes-base.mySql",
- "typeVersion": 2.5,
- "position": [
- 672,
- 192
- ],
- "id": "7546d115-42c1-4cf9-ae9c-9030a86f9a7c",
- "name": "update Tagesverbrauch PV mysql",
- "credentials": {
- "mySql": {
- "id": "GvOnFzLTFlbKtgUM",
- "name": "MySQL account - homelab"
- }
- }
- },
- {
- "parameters": {
- "operation": "select",
- "table": {
- "__rl": true,
- "value": "Waermepumpe",
- "mode": "list",
- "cachedResultName": "Waermepumpe"
- },
- "where": {
- "values": [
- {
- "column": "Datum",
- "value": "={{ $now.toFormat('yyyy-MM-dd')}}"
- }
- ]
- },
- "options": {}
- },
- "type": "n8n-nodes-base.mySql",
- "typeVersion": 2.5,
- "position": [
- 1344,
- 96
- ],
- "id": "6c0fce95-29f5-4c9a-bd06-6ce474207b01",
- "name": "Select rows from a table",
- "credentials": {
- "mySql": {
- "id": "GvOnFzLTFlbKtgUM",
- "name": "MySQL account - homelab"
- }
- }
- },
- {
- "parameters": {
- "operation": "update",
- "table": {
- "__rl": true,
- "value": "Waermepumpe",
- "mode": "list",
- "cachedResultName": "Waermepumpe"
- },
- "dataMode": "defineBelow",
- "columnToMatchOn": "Datum",
- "valueToMatchOn": "={{ $now.toFormat('yyyy-MM-dd')}}",
- "valuesToSend": {
- "values": [
- {
- "column": "Anteil Netzbezug",
- "value": "={{ $json['Anteil Netzbezug'] }}"
- }
- ]
- },
- "options": {}
- },
- "type": "n8n-nodes-base.mySql",
- "typeVersion": 2.5,
- "position": [
- 1792,
- 96
- ],
- "id": "b0e2962f-490d-4f17-be1c-0f8bbe80d510",
- "name": "Update rows in a table",
- "credentials": {
- "mySql": {
- "id": "GvOnFzLTFlbKtgUM",
- "name": "MySQL account - homelab"
- }
- }
- },
- {
- "parameters": {
- "mode": "chooseBranch",
- "useDataOfInput": 2
- },
- "type": "n8n-nodes-base.merge",
- "typeVersion": 3.2,
- "position": [
- 1120,
- 96
- ],
- "id": "e3aedba7-b520-40c7-b0ac-80c231bafbd8",
- "name": "Merge"
- },
- {
- "parameters": {
- "jsCode": "// Verarbeite alle eingehenden Items\nreturn $input.all().map(item => {\n const tagesverbrauch = Number(item.json[\"Tagesverbrauch\"]) || 0;\n const anteilPV = Number(item.json[\"Anteil PV\"]) || 0;\n\n // Berechnung\n const anteilNetzbezug = tagesverbrauch - anteilPV;\n\n // Neues Feld hinzufügen\n item.json[\"Anteil Netzbezug\"] = anteilNetzbezug;\n\n return item;\n});\n"
- },
- "type": "n8n-nodes-base.code",
- "typeVersion": 2,
- "position": [
- 1568,
- 96
- ],
- "id": "b709fffd-4cf1-46ae-839e-fb72a4902b0b",
- "name": "calculate Netzbezug"
- },
- {
- "parameters": {
- "url": "http://192.168.2.68:8093/v1/state/0_userdata.0.haus.heizung.waermepumpe.heat_pump_daily_consumption_pv",
- "sendQuery": true,
- "queryParameters": {
- "parameters": [
- {
- "name": "value",
- "value": "={{ $('Code in JavaScript3').item.json.tageszahlerstand }}"
- }
- ]
- },
- "options": {}
- },
- "type": "n8n-nodes-base.httpRequest",
- "typeVersion": 4.2,
- "position": [
- 896,
- 192
- ],
- "id": "a0db8fee-4d48-49b0-a329-80c90783e530",
- "name": "update Tagesverbrauch PV"
- },
- {
- "parameters": {
- "url": "http://192.168.2.68:8093/v1/state/0_userdata.0.haus.heizung.waermepumpe.heat_pump_daily_consumption_power",
- "sendQuery": true,
- "queryParameters": {
- "parameters": [
- {
- "name": "value",
- "value": "={{ $('calculate Netzbezug').item.json['Anteil Netzbezug'] }}"
- }
- ]
- },
- "options": {}
- },
- "type": "n8n-nodes-base.httpRequest",
- "typeVersion": 4.2,
- "position": [
- 2016,
- 96
- ],
- "id": "6dcc484c-e75a-46b2-9049-87a4e48d2d1d",
- "name": "update Netzbezug"
- }
- ],
- "pinData": {},
- "connections": {
- "Code in JavaScript": {
- "main": [
- [
- {
- "node": "Code in JavaScript1",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Code in JavaScript1": {
- "main": [
- [
- {
- "node": "update Tagesverbrauch mysql",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Schedule Trigger": {
- "main": [
- [
- {
- "node": "get Tageszählerstand WP",
- "type": "main",
- "index": 0
- },
- {
- "node": "get Tageszählerstand PV WP",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "get Tageszählerstand WP": {
- "main": [
- [
- {
- "node": "Code in JavaScript",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "get Tageszählerstand PV WP": {
- "main": [
- [
- {
- "node": "Code in JavaScript2",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Code in JavaScript2": {
- "main": [
- [
- {
- "node": "Code in JavaScript3",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Code in JavaScript3": {
- "main": [
- [
- {
- "node": "update Tagesverbrauch PV mysql",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "update Tagesverbrauch mysql": {
- "main": [
- [
- {
- "node": "update Tageszählerstand iobroker",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Select rows from a table": {
- "main": [
- [
- {
- "node": "calculate Netzbezug",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Update rows in a table": {
- "main": [
- [
- {
- "node": "update Netzbezug",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "update Tageszählerstand iobroker": {
- "main": [
- [
- {
- "node": "Merge",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "update Tagesverbrauch PV mysql": {
- "main": [
- [
- {
- "node": "update Tagesverbrauch PV",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Merge": {
- "main": [
- [
- {
- "node": "Select rows from a table",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "calculate Netzbezug": {
- "main": [
- [
- {
- "node": "Update rows in a table",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "update Tagesverbrauch PV": {
- "main": [
- [
- {
- "node": "Merge",
- "type": "main",
- "index": 1
- }
- ]
- ]
- }
- },
- "active": true,
- "settings": {
- "executionOrder": "v1"
- },
- "versionId": "8b467f30-717c-41e3-9051-236e31116740",
- "meta": {
- "templateCredsSetupCompleted": true,
- "instanceId": "3cc6c4256e2bbdec1b3708c49dc3889c7266357f3e239651c157c2de760e6c65"
- },
- "id": "bKlJd68Ba0ZWBnNS",
- "tags": [
- {
- "updatedAt": "2025-12-20T20:03:34.739Z",
- "createdAt": "2025-12-20T20:03:34.739Z",
- "id": "i5rtQijMRj2sx5Zj",
- "name": "Heizung"
- },
- {
- "updatedAt": "2025-12-20T19:56:59.512Z",
- "createdAt": "2025-12-20T19:56:59.512Z",
- "id": "9G8OthZJpXo6BPbV",
- "name": "Smart Home"
- }
- ]
-}
\ No newline at end of file