From c28f3ca0751c21b3b02863a2d08633cb4a65b3cf Mon Sep 17 00:00:00 2001 From: Rik Veenboer Date: Sun, 12 Oct 2025 16:50:34 +0200 Subject: [PATCH] mqtt splitter flow --- nodered/.config.nodes.json | 26 ++++++++++++++--- nodered/.config.users.json | 3 +- nodered/.gitignore | 1 + nodered/flows.json | 59 +++++++++++++++++++++++++++++++------- 4 files changed, 74 insertions(+), 15 deletions(-) diff --git a/nodered/.config.nodes.json b/nodered/.config.nodes.json index 23e370d..c77a56a 100644 --- a/nodered/.config.nodes.json +++ b/nodered/.config.nodes.json @@ -467,7 +467,7 @@ }, "node-red-contrib-telegrambot": { "name": "node-red-contrib-telegrambot", - "version": "16.3.2", + "version": "15.1.11", "local": true, "user": true, "nodes": { @@ -731,7 +731,7 @@ }, "node-red-node-email": { "name": "node-red-node-email", - "version": "3.0.3", + "version": "0.1.29", "local": true, "user": true, "nodes": { @@ -739,8 +739,7 @@ "name": "email", "types": [ "e-mail", - "e-mail in", - "e-mail mta" + "e-mail in" ], "enabled": true, "local": true, @@ -768,5 +767,24 @@ "file": "/data/node_modules/node-red-node-ui-table/node.js" } } + }, + "node-red-contrib-inspector": { + "name": "node-red-contrib-inspector", + "version": "1.0.1", + "local": true, + "user": true, + "nodes": { + "node-inspector": { + "name": "node-inspector", + "types": [ + "node-inspector" + ], + "enabled": true, + "local": true, + "user": false, + "module": "node-red-contrib-inspector", + "file": "/data/node_modules/node-red-contrib-inspector/node_inspector.js" + } + } } } \ No newline at end of file diff --git a/nodered/.config.users.json b/nodered/.config.users.json index da04b55..a381b60 100644 --- a/nodered/.config.users.json +++ b/nodered/.config.users.json @@ -19,7 +19,8 @@ }, "menu-menu-item-palette": true, "debug": { - "filter": "filterCurrent" + "filter": "filterCurrent", + "clearType": "all" }, "menu-deploymenu-item-node": true, "menu-deploymenu-item-full": false, diff --git a/nodered/.gitignore b/nodered/.gitignore index d4b6f0a..61ebc57 100644 --- a/nodered/.gitignore +++ b/nodered/.gitignore @@ -1,3 +1,4 @@ +.npm node_modules *.backup package.json diff --git a/nodered/flows.json b/nodered/flows.json index 6c987b2..6fbe93a 100644 --- a/nodered/flows.json +++ b/nodered/flows.json @@ -75,7 +75,6 @@ "sockspassword": "", "bothost": "", "botpath": "", - "localbothost": "", "localbotport": "8443", "publicbotport": "8443", "privatekey": "", @@ -876,11 +875,7 @@ "z": "88633c3e.1b273", "server": "email-smtp.eu-west-1.amazonaws.com", "port": "587", - "authtype": "BASIC", - "saslformat": false, - "token": "oauth2Response.access_token", "secure": false, - "tls": true, "name": "rik.veenboer@gmail.com", "dname": "Email", "x": 710, @@ -1102,7 +1097,7 @@ "type": "function", "z": "828acdf03ca58b4b", "name": "function 1", - "func": "// for (const [key, value] of Object.entries(msg.payload)) {\n// node.send({\n// topic: \"borgmatic/split/\" + key,\n// payload: value\n// });\n// }\nfunction flatten(obj, prefix, baseTopic, result) {\n for (const [key, value] of Object.entries(obj)) {\n const newPrefix = prefix ? prefix + \"/\" + key : key;\n if (value !== null && typeof value === \"object\" && !Array.isArray(value)) {\n flatten(value, newPrefix, baseTopic, result);\n } else {\n result.push({\n topic: baseTopic + \"/\" + newPrefix,\n payload: value\n });\n }\n }\n}\n\nlet result = [];\n\nflatten(msg.payload, \"\", msg.topic || \"borgmatic/split\", result);\n\n// return multiple messages\nreturn result;\n\n// return null; // because we already emitted messages", + "func": "const selections = [\n // [\"name\", \"name\"],\n [\"start\", \"start\"],\n [\"end\", \"end\"],\n [\"duration\", \"duration\"],\n [\"compressed_size\", \"stats.compressed_size\"],\n [\"deduplicated_size\", \"stats.deduplicated_size\"],\n [\"nfiles\", \"stats.nfiles\"],\n [\"original_size\", \"stats.original_size\"],\n];\n\nconst getPath = (obj, path) =>\n path.split('.').reduce((o, k) => (o?.[k] !== undefined ? o[k] : undefined), obj);\n\nconst namespace = msg.topic.split('/').pop()\n\nconst messages = selections.flatMap(([name, path]) => {\n const val = getPath(msg.payload, path);\n return val === undefined\n ? []\n : [{ topic: `borgmatic/split/${namespace}/${name}`, payload: val }];\n});\n\nreturn [messages];", "outputs": 1, "timeout": 0, "noerr": 0, @@ -1113,7 +1108,8 @@ "y": 240, "wires": [ [ - "50a0bb8c03545b5c" + "50a0bb8c03545b5c", + "13e002897ab3b6ab" ] ] }, @@ -1124,12 +1120,13 @@ "name": "debug 1", "active": true, "tosidebar": true, - "console": false, + "console": true, "tostatus": false, - "complete": "false", + "complete": "payload", + "targetType": "msg", "statusVal": "", "statusType": "auto", - "x": 360, + "x": 650, "y": 120, "wires": [] }, @@ -1150,5 +1147,47 @@ "x": 650, "y": 240, "wires": [] + }, + { + "id": "0a5f517589902b57", + "type": "node-inspector", + "z": "828acdf03ca58b4b", + "inputField": "payload", + "host": "0.0.0.0", + "portNumber": 9229, + "autoStart": true, + "name": "", + "x": 580, + "y": 340, + "wires": [] + }, + { + "id": "f297a215e3db36f2", + "type": "inject", + "z": "828acdf03ca58b4b", + "name": "", + "props": [ + { + "p": "topic", + "vt": "str" + }, + { + "p": "payload" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "borgmatic/stats/xyz", + "payload": "{\"command_line\":[\"/opt/homebrew/bin/borg\",\"create\",\"--patterns-from\",\"/var/folders/qh/8vg7yzzx6gj8y6tw327zbt380000gn/T/borgmatic-fbvbjxj_/borgmatic/tmpusnc8t0m\",\"--compression\",\"lz4\",\"--umask\",\"22\",\"--log-json\",\"--json\",\"/Users/rik/Downloads/repo::{now:%Y-%m-%d_%H%M%S}\"],\"duration\":0.003158,\"end\":\"2025-09-30T19:45:56.000000\",\"id\":\"467e209e97503853132b3e11ec1c8e3a21e00dd8224fa1e22d541c6d1670c094\",\"limits\":{\"max_archive_size\":0.000031518997777886815},\"name\":\"2025-09-30_194556\",\"start\":\"2025-09-30T19:45:56.000000\",\"stats\":{\"compressed_size\":1170,\"deduplicated_size\":661,\"nfiles\":2,\"original_size\":1286}}", + "payloadType": "json", + "x": 190, + "y": 420, + "wires": [ + [ + "2cc041d2f5a4a7ee" + ] + ] } ] \ No newline at end of file