Klar, kein Problem ![]()
Im Endefekt mache ich es so, dass ich die Werte ĂĽber den inject alle paar Sekunden aus meinen globalen Variablen hole und dann in das Javascript object schreibe.
Ich hab das oben mal mit Vincent durchgekaspert, du kannst aber auch ĂĽberall das Object laden und deine Werte reinpacken und wieder speichern.
Ich fand es bei der vielahl von Werten so einfacher, und es birgt nicht die Gefahr, dass das Object an unterschiedlichen Punkten geöffnet und dann wieder gespeichert wird, das könnte dazu führen das eventuelle neue Werte überschrieben werden. Da müsste man penibel auf die Laufzeit achten, hierbei nicht. Dafür wird hier jedesmal “alles” geladen.
Naturlich nicht vergessen die Globalen Variablen auhc anzulegen, vermutlich hast du die Werte aber sowieso schon in solchen ![]()
Viel spaĂź
[
{
"id": "b6e238d154109197",
"type": "inject",
"z": "9626f9b7d1e2d1b4",
"g": "fe59a07826917a3c",
"name": "set configuration",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "5",
"crontab": "",
"once": true,
"onceDelay": "5",
"topic": "",
"payload": "",
"payloadType": "date",
"x": 1070,
"y": 560,
"wires": [
[
"6880477c74edfb35"
]
]
},
{
"id": "6880477c74edfb35",
"type": "function",
"z": "9626f9b7d1e2d1b4",
"g": "fe59a07826917a3c",
"name": "custom data",
"func": "/*******************************************************\n * Set up custom key:value data for the app\n * -----------------------------------------------------\n * This function defines small text or status fields you \n * want to show inside the app’s “Custom Info” popup.\n * \n * HOW IT WORKS:\n * - Set the flag `customDataForApp` to true → enables\n * this feature for the API.\n * - Build a plain JS object (`key_values`) that contains \n * your custom labels and their values.\n * - Save that object into the global variable \n * `customDataForApp_key_values` → the app will pick it up\n * automatically and display it if non-empty.\n *\n * Each key/value pair will appear as a line in the popup.\n * Values are converted to strings automatically in the app.\n *******************************************************/\n\n// Enable custom data mode\nglobal.set(\"customDataForApp\", true); // must be true for data to be sent\n\n// Define your custom key:value pairs\n\n/*\nlet key_values = {\n \n \"Power Total Watts\" : \"EcoFlowTotalWatts\",\n \"Power Total Volt\" : \"MainBattVolt\",\n \"Power Total Ampere\" : \"MainBattAmps\",\n \"Power Total SOC\" : \"MainBattSoc\",\n\n \"Batterie 1 Watts\" : \"EcoFlowBatt1Watts\",\n \"Batterie 1 Volt\" : \"EcoFlowBatt1\",\n \"Batterie 1 Ampere\" : \"EcoFlowBatt1Curr\",\n \"Batterie 1 Soc\" : \"EcoFlowBatt1Soc\",\n \"Batterie 1 Temp\" : \"EcoFlowBatt1Temp\",\n\n \"Batterie 2 Watts\" : \"EcoFlowBatt2Watts\",\n \"Batterie 2 Volt\" : \"EcoFlowBatt2\",\n \"Batterie 2 Ampere\" : \"EcoFlowBatt2Curr\",\n \"Batterie 2 Soc\" : \"EcoFlowBatt2Soc\",\n \"Batterie 2 Temp\" : \"EcoFlowBatt2Temp\",\n\n \"Batterie 3 Watts\" : \"EcoFlowBatt3Watts\",\n \"Batterie 3 Volt\" : \"EcoFlowBatt3\",\n \"Batterie 3 Ampere\" : \"EcoFlowBatt3Curr\",\n \"Batterie 3 Soc\" : \"EcoFlowBatt3Soc\",\n \"Batterie 3 Temp\" : \"EcoFlowBatt3Temp\",\n\n \"Alternator In Watts\" : \"EcoFlowAltWatts\",\n \"Alternator In Volt\": \"EcoFlowAltVol\",\n \"Alternator In Ampere\" : \"EcoFlowAltCurr\",\n\n \"PV Total Watts\" : \"mppt_pv_watts\",\n\n \"PV 1 Watts\" : \"EcoFlowPv1InWatt\",\n \"PV 1 Volt\" : \"EcoFlowPv1InVol\",\n \"PV 1 Ampere\" : \"EcoFlowPv1InCurr\",\n\n \"PV 2 Watts\" : \"EcoFlowPv2InWatt\",\n \"PV 2 Volt\" : \"EcoFlowPv2InVol\",\n \"PV 2 Ampere\" : \"EcoFlowPv2InCurr\",\n\n \"AC In Watts\" : \"EcoFlowAcInWatt\",\n \"AC In Volt\" : \"EcoFlowAcInVol\",\n \"AC In Ampere\" : \"EcoFlowAcInCurr\",\n\n \"AC Out Watts\" : \"EcoFlowAcOutWatt\",\n \"DC Out Watts\" : \"EcoFlowDcOutWatt\",\n \"DC 48 V Out Watts\" : \"EcoFlow48Watts\"\n};\n\n\n*/\n\n\nlet key_values = {\n \n \"Power Total In Watts\" : global.get(\"EcoFlowTotalInWatts\"),\n \"Power Total Out Watts\" : global.get(\"EcoFlowTotalOutWatts\"),\n \"Power Total Volt\" : global.get(\"MainBattVolt\"),\n \"Power Total Ampere (Calculated)\" : global.get(\"MainBattAmps\"),\n \"Power Total SOC\" : global.get(\"MainBattSoc\"),\n \"Power Total FromBatt (Calculated)\" : global.get(\"EcoFlowWattsCalcFromBattery\"),\n\n \"Batterie 1 Watts\" : global.get(\"EcoFlowBatt1Watt\"),\n \"Batterie 1 Volt\" : global.get(\"EcoFlowBatt1\"),\n \"Batterie 1 Ampere\" : global.get(\"EcoFlowBatt1Curr\"),\n \"Batterie 1 Soc\" : global.get(\"EcoFlowBatt1Soc\"),\n \"Batterie 1 Temp\" : \"(fehlt noch)\",\n //global.get(\"EcoFlowBatt1Temp\"),\n\n \"Batterie 2 Watts\" : global.get(\"EcoFlowBatt2Watt\"),\n \"Batterie 2 Volt\" : global.get(\"EcoFlowBatt2\"),\n \"Batterie 2 Ampere\" : global.get(\"EcoFlowBatt2Curr\"),\n \"Batterie 2 Soc\" : global.get(\"EcoFlowBatt2Soc\"),\n \"Batterie 2 Temp\" : \"(fehlt noch)\",\n //global.get(\"EcoFlowBatt2Temp\"),\n\n \"Batterie 3 Watts\" : global.get(\"EcoFlowBatt3Watt\"),\n \"Batterie 3 Volt\" : global.get(\"EcoFlowBatt3\"),\n \"Batterie 3 Ampere\" : global.get(\"EcoFlowBatt3Curr\"),\n \"Batterie 3 Soc\" : global.get(\"EcoFlowBatt3Soc\"),\n \"Batterie 3 Temp\" : \"(fehlt noch)\",\n // global.get(\"EcoFlowBatt3Temp\"),\n\n \"Alternator In Watts\" : global.get(\"EcoFlowAltWatts\"),\n \"Alternator In Volt\": global.get(\"EcoFlowAltVol\"),\n \"Alternator In Ampere\" : global.get(\"EcoFlowAltCurr\"),\n\n \"PV Total Watts\" : global.get(\"mppt_pv_watts\"),\n\n \"PV 1 Watts\" : global.get(\"EcoFlowPv1InWatt\"),\n \"PV 1 Volt\" : global.get(\"EcoFlowPv1InVol\"),\n \"PV 1 Ampere\" : global.get(\"EcoFlowPv1InCurr\"),\n\n \"PV 2 Watts\" : global.get(\"EcoFlowPv2InWatt\"),\n \"PV 2 Volt\" : global.get(\"EcoFlowPv2InVol\"),\n \"PV 2 Ampere\" : global.get(\"EcoFlowPv2InCurr\"),\n\n\n \"AC In Volt\" : global.get(\"EcoFlowAcInVolt\"),\n \"AC In Ampere\" : global.get(\"EcoFlowAcInCurr\"),\n \"AC In Watts\": global.get(\"EcoFlowAcInWatt\"),\n \"AC Out Watts\" : global.get(\"EcoFlowAcOutWatt\"),\n \"DC Out Watts\" : global.get(\"EcoFlowDcOutWatt\"),\n \"DC 48 V Out Watts\" : global.get(\"EcoFlow48Watts\"),\n\n\n};\n\n// Save the object globally so the API can include it\nglobal.set(\"customDataForApp_key_values\", key_values);\n\n/*******************************************************\n * NOTES:\n * - Keys should be unique; duplicates will overwrite.\n * - Values can be strings, numbers, or anything that \n * makes sense - the app will treat them as text.\n * - To disable sending custom data, just run:\n * global.set(\"customDataForApp\", false);\n * global.set(\"customDataForApp_key_values\", {});\n *******************************************************/\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1290,
"y": 560,
"wires": [
[]
]
},
{
"id": "a9e528f9db78921e",
"type": "function",
"z": "9626f9b7d1e2d1b4",
"g": "fe59a07826917a3c",
"name": "custom relays",
"func": "/*******************************************************\n * Set up custom relays for the app\n * -----------------------------------------------------\n * This node writes two global variables used by the \n * main relay builder function:\n * \n * 1. global.customDataForApp\n * → enables custom data injection (must be TRUE)\n * \n * 2. global.customDataForApp_relays\n * → holds your custom relay definitions\n *\n * Each entry inside the object represents one relay.\n * The key (e.g. \"testrelay1\") is just a label and \n * doesn’t affect numbering — the main relay function\n * will append them automatically as Relay17, Relay18…\n *\n * Expected fields per relay:\n * - state → true/false\n * - name → the display name in the app\n * - autooff → optional, numeric (default 0)\n * - offtime → optional, numeric (time in seconds)\n *******************************************************/\n\n// enable custom data block\nglobal.set(\"customDataForApp\", true);\n\n// define your custom relays\nlet relayObject = {\n \n\n \"AC\": {\n state:false,\n name: \"AC\"\n },\n \"DC\": {\n state: false,\n name: \"DC\"\n },\n \"Lichtmaschine (fehlt noch)\": {\n state: true,\n name: \"Lichtmaschine\"\n },\n \"PV1 (fehlt noch)\": {\n state: true,\n name: \"PV1\"\n },\n \"PV2 (fehlt noch)\": {\n state: true,\n name: \"PV2\"\n },\n \"AC Laden (fehlt noch)\": {\n state: true,\n name: \"AC Laden\"\n },\n};\n\n// store them globally so the relay builder can append them\nglobal.set(\"customDataForApp_relays\", relayObject);\n\n// You can verify it worked in the Node-RED debug tab:\n//node.warn(global.get(\"customDataForApp_relays\"));",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1300,
"y": 600,
"wires": [
[]
]
},
{
"id": "a33bacd791f1eb9f",
"type": "inject",
"z": "9626f9b7d1e2d1b4",
"g": "fe59a07826917a3c",
"name": "set configuration",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": "3",
"topic": "",
"payload": "",
"payloadType": "date",
"x": 1070,
"y": 600,
"wires": [
[
"a9e528f9db78921e"
]
]
}
]
>