Skip to content

Instantly share code, notes, and snippets.

@martinLim45
Last active October 13, 2022 09:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinLim45/f4043666579db6bfee8b235f3e9a8a16 to your computer and use it in GitHub Desktop.
Save martinLim45/f4043666579db6bfee8b235f3e9a8a16 to your computer and use it in GitHub Desktop.
IoT Smart Home Simulation

This is a IoT Smart Home Simulation in the specific scenario. When the application is first started, every virual devices operate according to the given situation and interact with connected nodes. Some specific devices send the status information to the administrator through the Telegram messenger.

[
{
"id": "af288459.9f9ef8",
"type": "homekit-service",
"z": "cd7ed0a1.05b36",
"accessory": "a64b6a15.279b38",
"name": "AirQualitySensor01",
"serviceName": "AirQualitySensor",
"x": 101,
"y": 396,
"wires": [
[
"6cf85556.b46dac",
"b8db3942.2d1ff8"
]
]
},
{
"id": "2dc32382.fc6aec",
"type": "homekit-service",
"z": "cd7ed0a1.05b36",
"accessory": "2de9cae1.031ae6",
"name": "Door02",
"serviceName": "Door",
"x": 1226,
"y": 689,
"wires": [
[]
]
},
{
"id": "fc92561.e6bc4a8",
"type": "homekit-service",
"z": "cd7ed0a1.05b36",
"accessory": "9815ec25.85046",
"name": "Doorbell03",
"serviceName": "Doorbell",
"x": 1030,
"y": 679,
"wires": [
[]
]
},
{
"id": "6afd0b06.5f1b84",
"type": "homekit-service",
"z": "cd7ed0a1.05b36",
"accessory": "8c2003c6.a0aa5",
"name": "HeaterCooler05",
"serviceName": "HeaterCooler",
"x": 722,
"y": 572,
"wires": [
[]
]
},
{
"id": "1da8997b.d71537",
"type": "homekit-service",
"z": "cd7ed0a1.05b36",
"accessory": "66e36b3b.86adb4",
"name": "Fan04",
"serviceName": "Fan",
"x": 585,
"y": 577,
"wires": [
[]
]
},
{
"id": "75171288.ca6fec",
"type": "homekit-service",
"z": "cd7ed0a1.05b36",
"accessory": "5aa0b702.9e9c48",
"name": "TemperaturSensor06",
"serviceName": "TemperatureSensor",
"x": 606,
"y": 387,
"wires": [
[
"3d8a9968.864406",
"7f45e192.512b2"
]
]
},
{
"id": "51bac031.255e7",
"type": "homekit-service",
"z": "cd7ed0a1.05b36",
"accessory": "cd03d7cf.fa48b8",
"name": "Lightbulb07",
"serviceName": "Lightbulb",
"x": 1011,
"y": 596,
"wires": [
[]
]
},
{
"id": "36826c52.14b094",
"type": "homekit-service",
"z": "cd7ed0a1.05b36",
"accessory": "5a0e39b1.7a7278",
"name": "MotionSensor08",
"serviceName": "MotionSensor",
"x": 1032,
"y": 387,
"wires": [
[
"53b61fe0.70231",
"e432d422.1140e8"
]
]
},
{
"id": "f2caa622.ffc5c8",
"type": "homekit-service",
"z": "cd7ed0a1.05b36",
"accessory": "fdd140d7.bd47b",
"name": "SecuritySystem09",
"serviceName": "SecuritySystem",
"x": 1204,
"y": 608,
"wires": [
[
"6ca9823c.3601fc"
]
]
},
{
"id": "19e0e893.3b7c47",
"type": "homekit-service",
"z": "cd7ed0a1.05b36",
"accessory": "9c856fe8.5025d",
"name": "SmokeSensor10",
"serviceName": "SmokeSensor",
"x": 338,
"y": 392,
"wires": [
[
"7f878f04.14954",
"5fb128b6.219508"
]
]
},
{
"id": "ae017503.7fbeb8",
"type": "homekit-service",
"z": "cd7ed0a1.05b36",
"accessory": "63d9d384.45953c",
"name": "Window11",
"serviceName": "Window",
"x": 84,
"y": 630,
"wires": [
[]
]
},
{
"id": "4aa71525.60d73c",
"type": "homekit-service",
"z": "cd7ed0a1.05b36",
"accessory": "63d9d384.45953c",
"name": "Window12",
"serviceName": "Window",
"x": 363,
"y": 611,
"wires": [
[]
]
},
{
"id": "6cf85556.b46dac",
"type": "function",
"z": "cd7ed0a1.05b36",
"name": "",
"func": "\nif (msg.payload.NitrogenDioxideDensity > 28) {\n msg1 = {payload : {On:true}}\n}else{\n msg1 = {payload : {On:false}} \n}\n\nreturn msg1;\n",
"outputs": "1",
"noerr": 0,
"x": 73,
"y": 461,
"wires": [
[
"5bf38e1a.86c76"
]
]
},
{
"id": "9d1f10cf.ace43",
"type": "function",
"z": "cd7ed0a1.05b36",
"name": "",
"func": "\nif (msg.payload.On === true) {\n msg1 = {payload : {On:true}}\n msg2 = {payload : {RotationSpeed:30}}\n flag = {payload : {state:true}}\n}else{\n msg1 = {payload : {On:false}}\n msg2 = {payload : {RotationSpeed:10}}\n flag = {payload : {state:false}}\n}\n\nreturn [msg1,msg2,flag];",
"outputs": "3",
"noerr": 0,
"x": 604,
"y": 494,
"wires": [
[
"1da8997b.d71537"
],
[
"6afd0b06.5f1b84"
],
[
"91b74852.17e2d8"
]
]
},
{
"id": "dccbaf26.c252e",
"type": "function",
"z": "cd7ed0a1.05b36",
"name": "",
"func": "\nif (msg.payload.On === true) {\n msg1 = {payload : {On:true}}\n msg2 = {payload : {SecuritySystemCurrentState:true}}\n msg3 = {payload : {Brightness:30}}\n msg4 = {payload : {TargetPosition:30}}\n flag = {payload : {state:true}}\n}else{\n msg1 = {payload : {On:false}}\n msg2 = {payload : {SecuritySystemCurrentState:false}}\n msg3 = {payload : {Brightness:10}}\n msg4 = {payload : {TargetPosition:10}}\n flag = {payload : {state:false}}\n}\n\nreturn [msg1,msg2,msg3,msg4,flag];",
"outputs": "5",
"noerr": 0,
"x": 1022,
"y": 504,
"wires": [
[
"51bac031.255e7"
],
[
"f2caa622.ffc5c8"
],
[
"fc92561.e6bc4a8"
],
[
"2dc32382.fc6aec"
],
[
"91b74852.17e2d8"
]
]
},
{
"id": "3f90ae0a.b26262",
"type": "function",
"z": "cd7ed0a1.05b36",
"name": "",
"func": "\nif (msg.payload.On === true) {\n msg = {payload : {TargetPosition:30}}\n flag = {payload : {state:true}}\n}else{\n msg = {payload : {TargetPosition:10}} \n flag = {payload : {state:false}}\n}\n\nreturn [msg,flag]",
"outputs": "2",
"noerr": 0,
"x": 338,
"y": 517,
"wires": [
[
"4aa71525.60d73c"
],
[
"91b74852.17e2d8"
]
]
},
{
"id": "5bf38e1a.86c76",
"type": "function",
"z": "cd7ed0a1.05b36",
"name": "",
"func": "if (msg.payload.On) {\n msg = {payload : {TargetPosition:30}}\n flag = {payload : {state:true}}\n}else{\n msg = {payload : {TargetPosition:10}} \n flag = {payload : {state:false}}\n}\n\nreturn [msg,flag]",
"outputs": "2",
"noerr": 0,
"x": 55,
"y": 524,
"wires": [
[
"ae017503.7fbeb8"
],
[
"91b74852.17e2d8"
]
]
},
{
"id": "12199df2.9d14a2",
"type": "homekit-service",
"z": "cd7ed0a1.05b36",
"accessory": "204ad8cd.7d0c88",
"name": "",
"serviceName": "Fan",
"x": 1078,
"y": 119,
"wires": [
[
"44fbf670.57e4b8"
]
]
},
{
"id": "deaa886.5686378",
"type": "function",
"z": "cd7ed0a1.05b36",
"name": "",
"func": "if(!msg.payload.Volume){\n msg = {payload : {\"On\":true, RotationSpeed:3}}\n msg2 = {payload : {TargetPosition:\"open\"}}\n return [msg2,msg];\n}\n\nif (msg.payload.Volume === \"On\") {\n msg = {payload : {\"On\":false, RotationSpeed:0}}\n msg2 = {payload : {TargetPosition:\"close\"}}\n return [msg2,msg];\n}\n\nif (msg.payload.Volume === \"Off\") {\n msg = {payload : {\"On\":true, RotationSpeed:3}}\n msg2 = {payload : {TargetPosition:\"open\"}}\n return [msg2,msg];\n} \n\n\n\n",
"outputs": "2",
"noerr": 0,
"x": 913,
"y": 89,
"wires": [
[
"297d7f33.28a7b"
],
[
"12199df2.9d14a2"
]
]
},
{
"id": "44fbf670.57e4b8",
"type": "function",
"z": "cd7ed0a1.05b36",
"name": "",
"func": "if (msg.payload.RotationSpeed === 3) {\n msg = {payload : {\"On\":true }}\n msg2 = {payload : {\"Volume\":\"On\" }}\n return [msg,msg2];\n}else{\n msg = {payload : {\"On\":false }}\n msg2 = {payload : {\"Volume\":\"Off\" }}\n return [msg,msg2];\n \n} \n\n",
"outputs": "2",
"noerr": 0,
"x": 929,
"y": 218,
"wires": [
[
"1815864e.79b86a"
],
[
"3d6e5223.4dae7e"
]
]
},
{
"id": "1815864e.79b86a",
"type": "homekit-service",
"z": "cd7ed0a1.05b36",
"accessory": "fa223280.c7ac1",
"name": "",
"serviceName": "Lightbulb",
"x": 1078,
"y": 207,
"wires": [
[]
]
},
{
"id": "297d7f33.28a7b",
"type": "homekit-service",
"z": "cd7ed0a1.05b36",
"accessory": "9678e26e.3c8c1",
"name": "Door",
"serviceName": "Door",
"x": 1075,
"y": 72,
"wires": [
[]
]
},
{
"id": "3d6e5223.4dae7e",
"type": "homekit-service",
"z": "cd7ed0a1.05b36",
"accessory": "c8e5f566.7a9f18",
"name": "",
"serviceName": "Speaker",
"x": 1082,
"y": 253,
"wires": [
[
"ad7bb0da.40614",
"f912599f.8fcb58"
]
]
},
{
"id": "ad7bb0da.40614",
"type": "delay",
"z": "cd7ed0a1.05b36",
"name": "",
"pauseType": "random",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "10",
"randomUnits": "seconds",
"drop": false,
"x": 706,
"y": 116,
"wires": [
[
"deaa886.5686378"
]
]
},
{
"id": "e5d554d1.8e97e8",
"type": "function",
"z": "cd7ed0a1.05b36",
"name": "",
"func": "if (msg.payload.state) {\nmsg1 = {payload : {NitrogenDioxideDensity:20}}\nmsg2 = {payload : {SmokeDetected:false}}\nmsg3 = {payload : {CurrentTemperature:20}}\nmsg4 = {payload : {MotionDetected:false}} \n}else{\nmsg1 = {payload : {NitrogenDioxideDensity:30}}\nmsg2 = {payload : {SmokeDetected:true}}\nmsg3 = {payload : {CurrentTemperature:30}}\nmsg4 = {payload : {MotionDetected:true}}\n}\n\nreturn [msg1,msg2,msg3,msg4];",
"outputs": "4",
"noerr": 0,
"x": 402,
"y": 220,
"wires": [
[
"af288459.9f9ef8"
],
[
"19e0e893.3b7c47"
],
[
"75171288.ca6fec"
],
[
"36826c52.14b094"
]
]
},
{
"id": "390cfbff.c11494",
"type": "function",
"z": "cd7ed0a1.05b36",
"name": "",
"func": "msg1 = {payload : {Start:true}}\nmsg2 = {payload : {Start:true}}\nreturn [msg1,msg2];\n",
"outputs": "2",
"noerr": 0,
"x": 511,
"y": 21,
"wires": [
[
"deaa886.5686378"
],
[
"e5d554d1.8e97e8"
]
]
},
{
"id": "93278886.493578",
"type": "inject",
"z": "cd7ed0a1.05b36",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": true,
"x": 333,
"y": 20,
"wires": [
[
"390cfbff.c11494"
]
]
},
{
"id": "91b74852.17e2d8",
"type": "delay",
"z": "cd7ed0a1.05b36",
"name": "",
"pauseType": "delay",
"timeout": "1",
"timeoutUnits": "minutes",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"x": 152,
"y": 228,
"wires": [
[
"e5d554d1.8e97e8"
]
]
},
{
"id": "7f878f04.14954",
"type": "function",
"z": "cd7ed0a1.05b36",
"name": "",
"func": "\nif (msg.payload.SmokeDetected === true) {\n msg2 = {payload : {On:true}}\n}else{\n msg2 = {payload : {On:false}}\n}\nreturn msg2;\n",
"outputs": "1",
"noerr": 0,
"x": 322,
"y": 455,
"wires": [
[
"3f90ae0a.b26262"
]
]
},
{
"id": "3d8a9968.864406",
"type": "function",
"z": "cd7ed0a1.05b36",
"name": "",
"func": "if (msg.payload.CurrentTemperature > 28) {\n msg3 = {payload : {On:true}}\n}else{\n msg3 = {payload : {On:false}} \n}\n\nreturn msg3;\n",
"outputs": "1",
"noerr": 0,
"x": 593,
"y": 438,
"wires": [
[
"9d1f10cf.ace43"
]
]
},
{
"id": "53b61fe0.70231",
"type": "function",
"z": "cd7ed0a1.05b36",
"name": "",
"func": "\nif (msg.payload.MotionDetected === true) {\nmsg4 = {payload : {On:true}}\n}else{\nmsg4 = {payload : {On:false}}\n}\n\nreturn msg4;\n",
"outputs": "1",
"noerr": 0,
"x": 1029,
"y": 436,
"wires": [
[
"dccbaf26.c252e"
]
]
},
{
"id": "e82308d5.ece868",
"type": "chatbot-telegram-send",
"z": "cd7ed0a1.05b36",
"bot": "43c2ee1d.27e32",
"track": false,
"outputs": 0,
"x": 788,
"y": 736,
"wires": []
},
{
"id": "6ca9823c.3601fc",
"type": "function",
"z": "cd7ed0a1.05b36",
"name": "",
"func": "msg.payload ={\nchatId: 64452046,\ntype: \"message\",\ncontent: \"Security System State changed!\"\n}\n\nreturn msg",
"outputs": 1,
"noerr": 0,
"x": 773,
"y": 670,
"wires": [
[
"e82308d5.ece868"
]
]
},
{
"id": "49016688.73e018",
"type": "chatbot-telegram-send",
"z": "cd7ed0a1.05b36",
"bot": "43c2ee1d.27e32",
"track": false,
"outputs": 0,
"x": 101,
"y": 810,
"wires": []
},
{
"id": "b8db3942.2d1ff8",
"type": "function",
"z": "cd7ed0a1.05b36",
"name": "",
"func": "msg.payload ={\nchatId: 64452046,\ntype: \"message\",\ncontent: \"NitrogenDioxideDensity Detect!\"\n}\n\nreturn msg",
"outputs": 1,
"noerr": 0,
"x": 86,
"y": 744,
"wires": [
[
"49016688.73e018"
]
]
},
{
"id": "39ce9888.5e61f8",
"type": "chatbot-telegram-send",
"z": "cd7ed0a1.05b36",
"bot": "43c2ee1d.27e32",
"track": false,
"outputs": 0,
"x": 370,
"y": 803,
"wires": []
},
{
"id": "5fb128b6.219508",
"type": "function",
"z": "cd7ed0a1.05b36",
"name": "",
"func": "msg.payload ={\nchatId: 64452046,\ntype: \"message\",\ncontent: \"SmokeDetected!\"\n}\n\nreturn msg",
"outputs": 1,
"noerr": 0,
"x": 355,
"y": 737,
"wires": [
[
"39ce9888.5e61f8"
]
]
},
{
"id": "95fac0a2.50089",
"type": "chatbot-telegram-send",
"z": "cd7ed0a1.05b36",
"bot": "43c2ee1d.27e32",
"track": false,
"outputs": 0,
"x": 615,
"y": 799,
"wires": []
},
{
"id": "7f45e192.512b2",
"type": "function",
"z": "cd7ed0a1.05b36",
"name": "",
"func": "msg.payload ={\nchatId: 64452046,\ntype: \"message\",\ncontent: \"CurrentTemperature changed!\"\n}\n\nreturn msg",
"outputs": 1,
"noerr": 0,
"x": 600,
"y": 733,
"wires": [
[
"95fac0a2.50089"
]
]
},
{
"id": "b605365e.633ae8",
"type": "chatbot-telegram-send",
"z": "cd7ed0a1.05b36",
"bot": "43c2ee1d.27e32",
"track": false,
"outputs": 0,
"x": 1321,
"y": 480,
"wires": []
},
{
"id": "e432d422.1140e8",
"type": "function",
"z": "cd7ed0a1.05b36",
"name": "",
"func": "msg.payload ={\nchatId: 64452046,\ntype: \"message\",\ncontent: \"Motion Detected!\"\n}\n\nreturn msg",
"outputs": 1,
"noerr": 0,
"x": 1306,
"y": 414,
"wires": [
[
"b605365e.633ae8"
]
]
},
{
"id": "8ee569af.2bce18",
"type": "chatbot-telegram-send",
"z": "cd7ed0a1.05b36",
"bot": "43c2ee1d.27e32",
"track": false,
"outputs": 0,
"x": 1352,
"y": 249,
"wires": []
},
{
"id": "f912599f.8fcb58",
"type": "function",
"z": "cd7ed0a1.05b36",
"name": "",
"func": "msg.payload ={\nchatId: 64452046,\ntype: \"message\",\ncontent: \"Speaker Detect!\"\n}\n\nreturn msg",
"outputs": 1,
"noerr": 0,
"x": 1337,
"y": 183,
"wires": [
[
"8ee569af.2bce18"
]
]
},
{
"id": "a64b6a15.279b38",
"type": "homekit-accessory",
"z": "",
"accessoryName": "AirQualitySensor01",
"pinCode": "111-11-111",
"port": "",
"manufacturer": "Default Manufacturer",
"model": "Default Model",
"serialNo": "Default Serial Number",
"accessoryType": "1"
},
{
"id": "2de9cae1.031ae6",
"type": "homekit-accessory",
"z": "",
"accessoryName": "Door02",
"pinCode": "111-11-112",
"port": "",
"manufacturer": "Default Manufacturer",
"model": "Default Model",
"serialNo": "Default Serial Number",
"accessoryType": "1"
},
{
"id": "9815ec25.85046",
"type": "homekit-accessory",
"z": "",
"accessoryName": "Doorbell03",
"pinCode": "111-11-113",
"port": "",
"manufacturer": "Default Manufacturer",
"model": "Default Model",
"serialNo": "Default Serial Number",
"accessoryType": "1"
},
{
"id": "8c2003c6.a0aa5",
"type": "homekit-accessory",
"z": "",
"accessoryName": "HeaterCooler05",
"pinCode": "111-11-115",
"port": "",
"manufacturer": "Default Manufacturer",
"model": "Default Model",
"serialNo": "Default Serial Number",
"accessoryType": "1"
},
{
"id": "66e36b3b.86adb4",
"type": "homekit-accessory",
"z": "",
"accessoryName": "Fan04",
"pinCode": "111-11-114",
"port": "",
"manufacturer": "Default Manufacturer",
"model": "Default Model",
"serialNo": "Default Serial Number",
"accessoryType": "1"
},
{
"id": "5aa0b702.9e9c48",
"type": "homekit-accessory",
"z": "",
"accessoryName": "TemperaturSensor06",
"pinCode": "111-11-116",
"port": "",
"manufacturer": "Default Manufacturer",
"model": "Default Model",
"serialNo": "Default Serial Number",
"accessoryType": "1"
},
{
"id": "cd03d7cf.fa48b8",
"type": "homekit-accessory",
"z": "",
"accessoryName": "Lightbulb07",
"pinCode": "111-11-117",
"port": "",
"manufacturer": "Default Manufacturer",
"model": "Default Model",
"serialNo": "Default Serial Number",
"accessoryType": "1"
},
{
"id": "5a0e39b1.7a7278",
"type": "homekit-accessory",
"z": "",
"accessoryName": "MotionSensor08",
"pinCode": "111-11-118",
"port": "",
"manufacturer": "Default Manufacturer",
"model": "Default Model",
"serialNo": "Default Serial Number",
"accessoryType": "1"
},
{
"id": "fdd140d7.bd47b",
"type": "homekit-accessory",
"z": "",
"accessoryName": "SecuritySystem09",
"pinCode": "111-11-119",
"port": "",
"manufacturer": "Default Manufacturer",
"model": "Default Model",
"serialNo": "Default Serial Number",
"accessoryType": "1"
},
{
"id": "9c856fe8.5025d",
"type": "homekit-accessory",
"z": "",
"accessoryName": "SmokeSensor10",
"pinCode": "111-11-110",
"port": "",
"manufacturer": "Default Manufacturer",
"model": "Default Model",
"serialNo": "Default Serial Number",
"accessoryType": "1"
},
{
"id": "63d9d384.45953c",
"type": "homekit-accessory",
"z": "",
"accessoryName": "Window12",
"pinCode": "111-11-122",
"port": "",
"manufacturer": "Default Manufacturer",
"model": "Default Model",
"serialNo": "Default Serial Number",
"accessoryType": "1"
},
{
"id": "204ad8cd.7d0c88",
"type": "homekit-accessory",
"z": "",
"accessoryName": "Fan",
"pinCode": "111-11-132",
"port": "",
"manufacturer": "Default Manufacturer",
"model": "Default Model",
"serialNo": "Default Serial Number",
"accessoryType": "3"
},
{
"id": "fa223280.c7ac1",
"type": "homekit-accessory",
"z": "",
"accessoryName": "Light",
"pinCode": "111-11-133",
"port": "",
"manufacturer": "Default Manufacturer",
"model": "Default Model",
"serialNo": "Default Serial Number",
"accessoryType": "5"
},
{
"id": "9678e26e.3c8c1",
"type": "homekit-accessory",
"z": "",
"accessoryName": "Door",
"pinCode": "111-11-131",
"port": "",
"manufacturer": "Default Manufacturer",
"model": "Default Model",
"serialNo": "Default Serial Number",
"accessoryType": "12"
},
{
"id": "c8e5f566.7a9f18",
"type": "homekit-accessory",
"z": "",
"accessoryName": "Speaker",
"pinCode": "111-11-134",
"port": "",
"manufacturer": "Default Manufacturer",
"model": "Default Model",
"serialNo": "Default Serial Number",
"accessoryType": "1"
},
{
"id": "43c2ee1d.27e32",
"type": "chatbot-telegram-node",
"z": "",
"botname": "telegrambot",
"usernames": "",
"polling": "1000",
"log": ""
}
]
@Giaitzoglou
Copy link

hi is this too heavy for a raspberry pi 3 ? should it only being deployed to a pc ? cause when i deployed it the nodered red froze after 15 minutes and the cpu was 1 core always 100%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment