[{ "id": "57138478.e2855c", "type": "tab", "label": "Azure: Combined module demo", "info": "Start with the numbered focused examples. This combined flow demonstrates module twin, input/output and an echo method. Requires Edge workload identity and the README output1/input1/output2 routes." }, { "id": "combined-intro", "type": "comment", "z": "57138478.e2855c", "name": "Start here: one Module Client, manual sends, echo only", "info": "Requires Node-RED running as an Edge module. Import one module example at a time, or reuse your existing SINGLE Module Client and remove the redundant imported config before deploying. Merge both README route snippets (output1 to hub, sensor to input1, output2 to hub), using real deployment module IDs. All Inject nodes are manual. Invoke module method echo with payload {\"value\":42} and response timeout >=30s; expect status 200 with {\"echo\":{\"value\":42}}. No device setting is changed. Preserve requestId. The input transformer annotates objects but preserves arrays/scalars, re-encoding strings for Module Output. Review Debug output before production use.", "x": 430, "y": 20, "wires": [] }, { "id": "44969a6.3050964", "type": "function", "z": "57138478.e2855c", "name": "output msg", "func": "msg.payload = {\n random: Math.random(),\n deviceId: \"device-01\",\n timestamp: msg.payload\n};\nreturn msg;", "outputs": 1, "noerr": 0, "x": 951, "y": 244, "wires": [["67164628.3b1398"]] }, { "id": "4c358445.b1b6bc", "type": "moduletwin", "z": "57138478.e2855c", "client": "99470517.72f7f8", "x": 508, "y": 118, "wires": [["14c1ef9a.69fde"]] }, { "id": "14c1ef9a.69fde", "type": "debug", "z": "57138478.e2855c", "name": "twin msg", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "x": 731, "y": 64, "wires": [] }, { "id": "e13ad5d3.fdc6c8", "type": "inject", "z": "57138478.e2855c", "name": "running", "topic": "", "payload": "running", "payloadType": "str", "repeat": "", "crontab": "", "once": false, "onceDelay": "0.1", "x": 147, "y": 82, "wires": [["3de42c9c.86ee94"]] }, { "id": "3de42c9c.86ee94", "type": "function", "z": "57138478.e2855c", "name": "reported msg", "func": "msg.payload = { moduleStatus: msg.payload };\nreturn msg;", "outputs": 1, "noerr": 0, "x": 307, "y": 162, "wires": [["4c358445.b1b6bc"]] }, { "id": "567d6311.1fea7c", "type": "inject", "z": "57138478.e2855c", "name": "stopped", "topic": "", "payload": "stopped", "payloadType": "str", "repeat": "", "crontab": "", "once": false, "onceDelay": "0.1", "x": 147, "y": 222, "wires": [["3de42c9c.86ee94"]] }, { "id": "67164628.3b1398", "type": "moduleoutput", "z": "57138478.e2855c", "client": "99470517.72f7f8", "output": "output1", "x": 1216, "y": 292, "wires": [] }, { "id": "24d99fed.7176e", "type": "inject", "z": "57138478.e2855c", "name": "", "topic": "", "payload": "", "payloadType": "date", "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "x": 751, "y": 304, "wires": [["44969a6.3050964"]] }, { "id": "f51e142b.0bec48", "type": "modulemethod", "z": "57138478.e2855c", "client": "99470517.72f7f8", "method": "echo", "x": 936, "y": 652, "wires": [["766d143b.b9826c", "8f6c02.a49314"]] }, { "id": "18db5e91.52bd21", "type": "moduleinput", "z": "57138478.e2855c", "client": "99470517.72f7f8", "input": "input1", "x": 204, "y": 533, "wires": [["7b2695b2.35c47c", "aae877c8.807d28"]] }, { "id": "7b2695b2.35c47c", "type": "debug", "z": "57138478.e2855c", "name": "input msg", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "x": 427, "y": 566, "wires": [] }, { "id": "766d143b.b9826c", "type": "debug", "z": "57138478.e2855c", "name": "method msg", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "x": 1196, "y": 632, "wires": [] }, { "id": "8f6c02.a49314", "type": "function", "z": "57138478.e2855c", "name": "response msg", "func": "msg.payload = { echo: msg.payload };\nmsg.status = 200;\nreturn msg;", "outputs": 1, "noerr": 0, "x": 926, "y": 772, "wires": [["f51e142b.0bec48"]] }, { "id": "7e4f9e1b.cd666", "type": "moduleoutput", "z": "57138478.e2855c", "client": "99470517.72f7f8", "output": "output2", "x": 691, "y": 492, "wires": [] }, { "id": "721b4238.86b15c", "type": "comment", "z": "57138478.e2855c", "name": "Example: Work with module twin", "info": "The Module Twin emits desired-property messages with topic: desired. Send an object or JSON text to report properties.", "x": 467, "y": 71, "wires": [] }, { "id": "27c3e76c.795cb8", "type": "comment", "z": "57138478.e2855c", "name": "Example: Simulate module output", "info": "The Module Output sends JSON to Edge Hub using the configured output route.", "x": 998, "y": 191, "wires": [] }, { "id": "f0f61271.7c3c3", "type": "comment", "z": "57138478.e2855c", "name": "Example: Process Direct Method", "info": "Invoke echo on the Edge device/module identity. This only echoes the request, not a real setting change. Preserve requestId and return the message with status and a native JSON payload within 25 seconds; caller timeout >=30 seconds.", "x": 948, "y": 595, "wires": [] }, { "id": "7ded1ccf.398f24", "type": "comment", "z": "57138478.e2855c", "name": "Example: Enable module input", "info": "The Module Input emits JSON payloads with topic: input and the configured input name.", "x": 197, "y": 474, "wires": [] }, { "id": "110a9903.29dcb7", "type": "comment", "z": "57138478.e2855c", "name": "Example: Process message and send to output", "info": "Object payloads gain forwardedAt. Arrays/scalars retain their JSON values; strings are re-encoded as JSON text for Module Output. The README routes send sensor output1 to input1 and forward output2 upstream.", "x": 675, "y": 410, "wires": [] }, { "id": "aae877c8.807d28", "type": "function", "z": "57138478.e2855c", "name": "Prepare output payload", "func": "const payload = msg.payload;\nif (payload !== null && typeof payload === 'object' && !Array.isArray(payload)) {\n msg.payload = { ...payload, forwardedAt: new Date().toISOString() };\n} else if (typeof payload === 'string') {\n // Module Output expects JSON text for strings, not raw text.\n msg.payload = JSON.stringify(payload);\n}\nreturn msg;", "outputs": 1, "noerr": 0, "x": 441, "y": 462, "wires": [["7e4f9e1b.cd666"]] }, { "id": "99470517.72f7f8", "type": "moduleclient", "z": "" }]