Smart Home Monitoring System (Simulated Sensors)
This flow simulates temperature sensors in two rooms. It uses Inject nodes to generate data, Function nodes to format the messages, and Debug nodes to show the output. This is part of a smart home monitoring system prototype using Node-RED.
[{"id":"c1a4f1b3d86a4e3b","type":"tab","label":"Smart Home Monitoring","disabled":false,"info":""},{"id":"c3a0a9e62438dbb1","type":"inject","z":"c1a4f1b3d86a4e3b","name":"Room 1 Temp","props":[{"p":"payload"}],"repeat":"5","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":100,"wires":[["d5c3fd8b88eb1a07"]]},{"id":"d5c3fd8b88eb1a07","type":"function","z":"c1a4f1b3d86a4e3b","name":"Simulate Room 1","func":"msg.payload = {\n room: \"Room 1\",\n temperature: (20 + Math.random() * 5).toFixed(2),\n timestamp: new Date().toISOString()\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":100,"wires":[["f401a0e6e6a0c5cd"]]},{"id":"f401a0e6e6a0c5cd","type":"debug","z":"c1a4f1b3d86a4e3b","name":"Room 1 Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":560,"y":100,"wires":[]},{"id":"23a6930a2e409149","type":"inject","z":"c1a4f1b3d86a4e3b","name":"Room 2 Temp","props":[{"p":"payload"}],"repeat":"5","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":160,"wires":[["73050543a0fdb9d1"]]},{"id":"73050543a0fdb9d1","type":"function","z":"c1a4f1b3d86a4e3b","name":"Simulate Room 2","func":"msg.payload = {\n room: \"Room 2\",\n temperature: (21 + Math.random() * 4).toFixed(2),\n timestamp: new Date().toISOString()\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":160,"wires":[["f3a02f28e29d4f49"]]},{"id":"f3a02f28e29d4f49","type":"debug","z":"c1a4f1b3d86a4e3b","name":"Room 2 Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":560,"y":160,"wires":[]}]