JSON-Payload mit Node-Red

Hab´s hin bekommen, falls es jemanden interessiert…

[
    {
        "id": "caad49ce5c607c2d",
        "type": "tab",
        "label": "3D-MES",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "7673221db4b8ee65",
        "type": "inject",
        "z": "caad49ce5c607c2d",
        "name": "Sende Werte",
        "props": [],
        "repeat": "10",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "x": 120,
        "y": 40,
        "wires": [
            [
                "045c055301561e39",
                "e8ee5ecd08e127e6",
                "6de841a47e8d350e",
                "5319fce987bbcd90",
                "dba613fe0f6c9993",
                "46061c23d2d737d1",
                "45c15626b647372a",
                "f29d0ae75620f52c",
                "75d10cd38071898c"
            ]
        ]
    },
    {
        "id": "045c055301561e39",
        "type": "api-current-state",
        "z": "caad49ce5c607c2d",
        "name": "Hole Temperatur",
        "server": "25bb7b972abf0ad5",
        "version": 3,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "sensor.box1_temperature",
        "state_type": "num",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            }
        ],
        "for": 0,
        "forType": "num",
        "forUnits": "minutes",
        "x": 340,
        "y": 40,
        "wires": [
            [
                "4183f8e8ea8a11cb"
            ]
        ]
    },
    {
        "id": "e8ee5ecd08e127e6",
        "type": "api-current-state",
        "z": "caad49ce5c607c2d",
        "name": "Hole Luftfeuchtigkeit",
        "server": "25bb7b972abf0ad5",
        "version": 3,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "sensor.box1_humidity",
        "state_type": "num",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            }
        ],
        "for": 0,
        "forType": "num",
        "forUnits": "minutes",
        "x": 360,
        "y": 100,
        "wires": [
            [
                "8cf122fa5d7aa047"
            ]
        ]
    },
    {
        "id": "6de841a47e8d350e",
        "type": "api-current-state",
        "z": "caad49ce5c607c2d",
        "name": "Hole Identifier",
        "server": "25bb7b972abf0ad5",
        "version": 3,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "input_number.identifier_box1",
        "state_type": "num",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            }
        ],
        "for": 0,
        "forType": "num",
        "forUnits": "minutes",
        "x": 340,
        "y": 160,
        "wires": [
            [
                "850b69c63096d418"
            ]
        ]
    },
    {
        "id": "4183f8e8ea8a11cb",
        "type": "function",
        "z": "caad49ce5c607c2d",
        "name": "Setze Topic für Temperatur",
        "func": "msg.payload = {\n    temperature: parseFloat(msg.payload) // Beispielwert für Temperatur\n};\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 620,
        "y": 40,
        "wires": [
            [
                "00b60d3874b23706"
            ]
        ]
    },
    {
        "id": "8cf122fa5d7aa047",
        "type": "function",
        "z": "caad49ce5c607c2d",
        "name": "Setze Topic für Luftfeuchtigkeit",
        "func": "msg.payload = {\n    humidity: parseFloat(msg.payload) // Beispielwert für Luftfeuchtigkeit\n};\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 630,
        "y": 100,
        "wires": [
            [
                "00b60d3874b23706"
            ]
        ]
    },
    {
        "id": "850b69c63096d418",
        "type": "function",
        "z": "caad49ce5c607c2d",
        "name": "Setze Topic für Identifier",
        "func": "msg.payload = {\n    identifier: parseInt(msg.payload, 10) // Beispielwert für Identifier\n};\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 610,
        "y": 160,
        "wires": [
            [
                "00b60d3874b23706"
            ]
        ]
    },
    {
        "id": "00b60d3874b23706",
        "type": "join",
        "z": "caad49ce5c607c2d",
        "name": "Zusammenführen",
        "mode": "custom",
        "build": "merged",
        "property": "payload",
        "propertyType": "msg",
        "key": "topic",
        "joiner": "\\n",
        "joinerType": "str",
        "useparts": true,
        "accumulate": false,
        "timeout": "",
        "count": 3,
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "",
        "reduceFixup": "",
        "x": 930,
        "y": 40,
        "wires": [
            [
                "2dcea1ea4c4d0a42"
            ]
        ]
    },
    {
        "id": "2dcea1ea4c4d0a42",
        "type": "function",
        "z": "caad49ce5c607c2d",
        "name": "JSON erstellen",
        "func": "// Überprüfen, ob msg.payload ein Objekt ist\nif (typeof msg.payload === \"object\") {\n    // Werte aus msg.payload extrahieren und runden\n    let temperature = Math.round(parseFloat(msg.payload.temperature)); // Temperatur runden\n    let humidity = Math.round(parseFloat(msg.payload.humidity));       // Luftfeuchtigkeit runden\n    let identifier = parseInt(msg.payload.identifier, 10);             // Identifier in eine Ganzzahl umwandeln\n\n    // Prüfe, ob die Konvertierungen erfolgreich waren\n    if (isNaN(temperature) || isNaN(humidity) || isNaN(identifier)) {\n        node.error(\"Ein oder mehrere Werte konnten nicht konvertiert werden.\");\n        return null; // Keine Weiterleitung, wenn Fehler auftritt\n    }\n\n    // JSON-Payload erstellen\n    msg.payload = {\n        temperature: temperature,\n        humidity: humidity,\n        Identifier: identifier\n    };\n\n    return msg;\n} else {\n    // Fehler, wenn msg.payload kein Objekt ist\n    node.error(\"msg.payload ist kein Objekt!\");\n    return null; // Keine Weiterleitung, wenn Fehler auftritt\n}\n",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1140,
        "y": 40,
        "wires": [
            [
                "f41400871c9e3da4"
            ]
        ]
    },
    {
        "id": "f41400871c9e3da4",
        "type": "http request",
        "z": "caad49ce5c607c2d",
        "name": "Sende POST",
        "method": "POST",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "http://192.168.10.208:81/api/humidity",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 1330,
        "y": 40,
        "wires": [
            [
                "c823c95dd4c05a50"
            ]
        ]
    },
    {
        "id": "c823c95dd4c05a50",
        "type": "debug",
        "z": "caad49ce5c607c2d",
        "name": "Antwort anzeigen",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1530,
        "y": 40,
        "wires": []
    },
    {
        "id": "5319fce987bbcd90",
        "type": "api-current-state",
        "z": "caad49ce5c607c2d",
        "name": "Hole Temperatur",
        "server": "25bb7b972abf0ad5",
        "version": 3,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "sensor.box2_temperature",
        "state_type": "num",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            }
        ],
        "for": 0,
        "forType": "num",
        "forUnits": "minutes",
        "x": 340,
        "y": 260,
        "wires": [
            [
                "1d3a53c1b5330534"
            ]
        ]
    },
    {
        "id": "dba613fe0f6c9993",
        "type": "api-current-state",
        "z": "caad49ce5c607c2d",
        "name": "Hole Luftfeuchtigkeit",
        "server": "25bb7b972abf0ad5",
        "version": 3,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "sensor.box2_humidity",
        "state_type": "num",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            }
        ],
        "for": 0,
        "forType": "num",
        "forUnits": "minutes",
        "x": 360,
        "y": 320,
        "wires": [
            [
                "4ceed5bd016f482a"
            ]
        ]
    },
    {
        "id": "46061c23d2d737d1",
        "type": "api-current-state",
        "z": "caad49ce5c607c2d",
        "name": "Hole Identifier",
        "server": "25bb7b972abf0ad5",
        "version": 3,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "input_number.identifier_box2",
        "state_type": "num",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            }
        ],
        "for": 0,
        "forType": "num",
        "forUnits": "minutes",
        "x": 340,
        "y": 380,
        "wires": [
            [
                "360573784e6ade47"
            ]
        ]
    },
    {
        "id": "1d3a53c1b5330534",
        "type": "function",
        "z": "caad49ce5c607c2d",
        "name": "Setze Topic für Temperatur",
        "func": "msg.payload = {\n    temperature: parseFloat(msg.payload) // Beispielwert für Temperatur\n};\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 620,
        "y": 260,
        "wires": [
            [
                "7244fb3cd7e95dc5"
            ]
        ]
    },
    {
        "id": "4ceed5bd016f482a",
        "type": "function",
        "z": "caad49ce5c607c2d",
        "name": "Setze Topic für Luftfeuchtigkeit",
        "func": "msg.payload = {\n    humidity: parseFloat(msg.payload) // Beispielwert für Luftfeuchtigkeit\n};\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 630,
        "y": 320,
        "wires": [
            [
                "7244fb3cd7e95dc5"
            ]
        ]
    },
    {
        "id": "360573784e6ade47",
        "type": "function",
        "z": "caad49ce5c607c2d",
        "name": "Setze Topic für Identifier",
        "func": "msg.payload = {\n    identifier: parseInt(msg.payload, 10) // Beispielwert für Identifier\n};\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 610,
        "y": 380,
        "wires": [
            [
                "7244fb3cd7e95dc5"
            ]
        ]
    },
    {
        "id": "7244fb3cd7e95dc5",
        "type": "join",
        "z": "caad49ce5c607c2d",
        "name": "Zusammenführen",
        "mode": "custom",
        "build": "merged",
        "property": "payload",
        "propertyType": "msg",
        "key": "topic",
        "joiner": "\\n",
        "joinerType": "str",
        "useparts": true,
        "accumulate": false,
        "timeout": "",
        "count": 3,
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "",
        "reduceFixup": "",
        "x": 930,
        "y": 260,
        "wires": [
            [
                "aadced59d69dbd95"
            ]
        ]
    },
    {
        "id": "aadced59d69dbd95",
        "type": "function",
        "z": "caad49ce5c607c2d",
        "name": "JSON erstellen",
        "func": "// Überprüfen, ob msg.payload ein Objekt ist\nif (typeof msg.payload === \"object\") {\n    // Werte aus msg.payload extrahieren und runden\n    let temperature = Math.round(parseFloat(msg.payload.temperature)); // Temperatur runden\n    let humidity = Math.round(parseFloat(msg.payload.humidity));       // Luftfeuchtigkeit runden\n    let identifier = parseInt(msg.payload.identifier, 10);             // Identifier in eine Ganzzahl umwandeln\n\n    // Prüfe, ob die Konvertierungen erfolgreich waren\n    if (isNaN(temperature) || isNaN(humidity) || isNaN(identifier)) {\n        node.error(\"Ein oder mehrere Werte konnten nicht konvertiert werden.\");\n        return null; // Keine Weiterleitung, wenn Fehler auftritt\n    }\n\n    // JSON-Payload erstellen\n    msg.payload = {\n        temperature: temperature,\n        humidity: humidity,\n        Identifier: identifier\n    };\n\n    return msg;\n} else {\n    // Fehler, wenn msg.payload kein Objekt ist\n    node.error(\"msg.payload ist kein Objekt!\");\n    return null; // Keine Weiterleitung, wenn Fehler auftritt\n}\n",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1140,
        "y": 260,
        "wires": [
            [
                "6ac630738b77155f"
            ]
        ]
    },
    {
        "id": "6ac630738b77155f",
        "type": "http request",
        "z": "caad49ce5c607c2d",
        "name": "Sende POST",
        "method": "POST",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "http://192.168.10.208:81/api/humidity",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 1330,
        "y": 260,
        "wires": [
            [
                "d2dc32c82162ef39"
            ]
        ]
    },
    {
        "id": "d2dc32c82162ef39",
        "type": "debug",
        "z": "caad49ce5c607c2d",
        "name": "Antwort anzeigen",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1530,
        "y": 260,
        "wires": []
    },
    {
        "id": "45c15626b647372a",
        "type": "api-current-state",
        "z": "caad49ce5c607c2d",
        "name": "Hole Temperatur",
        "server": "25bb7b972abf0ad5",
        "version": 3,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "sensor.box3_temperature",
        "state_type": "num",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            }
        ],
        "for": 0,
        "forType": "num",
        "forUnits": "minutes",
        "x": 340,
        "y": 480,
        "wires": [
            [
                "50c9cb009bff0608"
            ]
        ]
    },
    {
        "id": "f29d0ae75620f52c",
        "type": "api-current-state",
        "z": "caad49ce5c607c2d",
        "name": "Hole Luftfeuchtigkeit",
        "server": "25bb7b972abf0ad5",
        "version": 3,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "sensor.box3_humidity",
        "state_type": "num",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            }
        ],
        "for": 0,
        "forType": "num",
        "forUnits": "minutes",
        "x": 360,
        "y": 540,
        "wires": [
            [
                "d78b71bdc26cd27c"
            ]
        ]
    },
    {
        "id": "75d10cd38071898c",
        "type": "api-current-state",
        "z": "caad49ce5c607c2d",
        "name": "Hole Identifier",
        "server": "25bb7b972abf0ad5",
        "version": 3,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "input_number.identifier_box3",
        "state_type": "num",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            }
        ],
        "for": 0,
        "forType": "num",
        "forUnits": "minutes",
        "x": 340,
        "y": 600,
        "wires": [
            [
                "f756c61aadfe31b6"
            ]
        ]
    },
    {
        "id": "50c9cb009bff0608",
        "type": "function",
        "z": "caad49ce5c607c2d",
        "name": "Setze Topic für Temperatur",
        "func": "msg.payload = {\n    temperature: parseFloat(msg.payload) // Beispielwert für Temperatur\n};\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 620,
        "y": 480,
        "wires": [
            [
                "4064c76a7b846760"
            ]
        ]
    },
    {
        "id": "d78b71bdc26cd27c",
        "type": "function",
        "z": "caad49ce5c607c2d",
        "name": "Setze Topic für Luftfeuchtigkeit",
        "func": "msg.payload = {\n    humidity: parseFloat(msg.payload) // Beispielwert für Luftfeuchtigkeit\n};\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 630,
        "y": 540,
        "wires": [
            [
                "4064c76a7b846760"
            ]
        ]
    },
    {
        "id": "f756c61aadfe31b6",
        "type": "function",
        "z": "caad49ce5c607c2d",
        "name": "Setze Topic für Identifier",
        "func": "msg.payload = {\n    identifier: parseInt(msg.payload, 10) // Beispielwert für Identifier\n};\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 610,
        "y": 600,
        "wires": [
            [
                "4064c76a7b846760"
            ]
        ]
    },
    {
        "id": "4064c76a7b846760",
        "type": "join",
        "z": "caad49ce5c607c2d",
        "name": "Zusammenführen",
        "mode": "custom",
        "build": "merged",
        "property": "payload",
        "propertyType": "msg",
        "key": "topic",
        "joiner": "\\n",
        "joinerType": "str",
        "useparts": true,
        "accumulate": false,
        "timeout": "",
        "count": 3,
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "",
        "reduceFixup": "",
        "x": 930,
        "y": 480,
        "wires": [
            [
                "af78db0f5ba07375"
            ]
        ]
    },
    {
        "id": "af78db0f5ba07375",
        "type": "function",
        "z": "caad49ce5c607c2d",
        "name": "JSON erstellen",
        "func": "// Überprüfen, ob msg.payload ein Objekt ist\nif (typeof msg.payload === \"object\") {\n    // Werte aus msg.payload extrahieren und runden\n    let temperature = Math.round(parseFloat(msg.payload.temperature)); // Temperatur runden\n    let humidity = Math.round(parseFloat(msg.payload.humidity));       // Luftfeuchtigkeit runden\n    let identifier = parseInt(msg.payload.identifier, 10);             // Identifier in eine Ganzzahl umwandeln\n\n    // Prüfe, ob die Konvertierungen erfolgreich waren\n    if (isNaN(temperature) || isNaN(humidity) || isNaN(identifier)) {\n        node.error(\"Ein oder mehrere Werte konnten nicht konvertiert werden.\");\n        return null; // Keine Weiterleitung, wenn Fehler auftritt\n    }\n\n    // JSON-Payload erstellen\n    msg.payload = {\n        temperature: temperature,\n        humidity: humidity,\n        Identifier: identifier\n    };\n\n    return msg;\n} else {\n    // Fehler, wenn msg.payload kein Objekt ist\n    node.error(\"msg.payload ist kein Objekt!\");\n    return null; // Keine Weiterleitung, wenn Fehler auftritt\n}\n",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1140,
        "y": 480,
        "wires": [
            [
                "49daa8acb3ba3100"
            ]
        ]
    },
    {
        "id": "49daa8acb3ba3100",
        "type": "http request",
        "z": "caad49ce5c607c2d",
        "name": "Sende POST",
        "method": "POST",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "http://xxx.xxx.xxx.xxx:xx/api/humidity",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 1330,
        "y": 480,
        "wires": [
            [
                "3aa07c0db0e21137"
            ]
        ]
    },
    {
        "id": "3aa07c0db0e21137",
        "type": "debug",
        "z": "caad49ce5c607c2d",
        "name": "Antwort anzeigen",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1530,
        "y": 480,
        "wires": []
    },
    {
        "id": "25bb7b972abf0ad5",
        "type": "server",
        "name": "Home Assistant",
        "version": 5,
        "addon": true,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true,
        "heartbeat": false,
        "heartbeatInterval": "30",
        "areaSelector": "friendlyName",
        "deviceSelector": "friendlyName",
        "entitySelector": "friendlyName",
        "statusSeparator": ": ",
        "statusYear": "hidden",
        "statusMonth": "short",
        "statusDay": "numeric",
        "statusHourCycle": "default",
        "statusTimeFormat": "h:m",
        "enableGlobalContextStore": false
    }
]