Skip to content

Instantly share code, notes, and snippets.

@spl23

spl23/README.md Secret

Created March 24, 2017 04:35
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 spl23/e71d5246a2e80954b267b3079e1e9764 to your computer and use it in GitHub Desktop.
Save spl23/e71d5246a2e80954b267b3079e1e9764 to your computer and use it in GitHub Desktop.
elevator

IBM recipe for simulated elevators

[{"id":"df321cd2.aae86","type":"stop virtual device","z":"4cb9f36b.f002ac","name":"Stop Elevator","deviceId":"","schema":"b6e56c3f.e8dd1","x":797.6190910339355,"y":1840.0001602172852,"wires":[[]]},{"id":"39f0f922.022e86","type":"start virtual device","z":"4cb9f36b.f002ac","name":"Start Elevator","deviceId":"","schema":"b6e56c3f.e8dd1","outputs":1,"x":379.8571472167969,"y":426,"wires":[["746fb53b.07fecc"]]},{"id":"31430fac.a31fd","type":"ibmiot in","z":"4cb9f36b.f002ac","authentication":"apiKey","apiKey":"35fcbc9f.e98294","inputType":"cmd","deviceId":"Elevator1","applicationId":"","deviceType":"Elevator","eventType":"+","commandType":"maintenance_command","format":"json","name":"On Maintenance Command","service":"registered","allDevices":true,"allApplications":"","allDeviceTypes":true,"allEvents":true,"allCommands":false,"allFormats":"","qos":0,"x":205.11912536621094,"y":1690.5714111328125,"wires":[["2df69dd8.c7f422","391e4c89.365314"]]},{"id":"391e4c89.365314","type":"set properties","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"Set Maintenance Stop","propAll":false,"prop":"1bd9b63f4b60","valueType":"msg","value":"payload.stop","x":471.6191101074219,"y":1708.5714206695557,"wires":[[]]},{"id":"9d6ca2e9.a1a3","type":"generate event","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","evt":"0612deed98b7","name":"Send Status Event","x":698.1427917480469,"y":1291.9998779296875,"wires":[["5c735603.1cf4f8"]]},{"id":"be3a60ad.d7f0d","type":"comment","z":"4cb9f36b.f002ac","name":"Start Device","info":"","x":382.85715103149414,"y":382.4999990463257,"wires":[]},{"id":"a7756901.fdd7a8","type":"comment","z":"4cb9f36b.f002ac","name":"Stop Device","info":"","x":149.83331298828125,"y":1798.2858047485352,"wires":[]},{"id":"a9dd5188.0a841","type":"comment","z":"4cb9f36b.f002ac","name":"Handle maintenance commands","info":"","x":206.49993896484375,"y":1638,"wires":[]},{"id":"ac9e2b91.f7c6a8","type":"device function","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"check if not in maintenance state","func":"if(state === \"maintenance\"){\n return [null, msg];\n}\nelse {\n return [msg, msg];\n}","outputs":"2","noerr":0,"x":389.6786804199219,"y":1280.9998931884766,"wires":[["9d6ca2e9.a1a3"],["420376d6.82fbe8"]]},{"id":"420376d6.82fbe8","type":"delay","z":"4cb9f36b.f002ac","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":408.2143249511719,"y":1352.5713500976562,"wires":[["ac9e2b91.f7c6a8"]]},{"id":"2df69dd8.c7f422","type":"set properties","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"Set Maintenance Reason","propAll":false,"prop":"bd4d2913cb07","valueType":"msg","value":"payload.reason","x":474.9762878417969,"y":1669.5714054107666,"wires":[[]]},{"id":"49da86c8.46a308","type":"generate event","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","evt":"21024c33b8dd","name":"Send Maintenance Stop","x":871.2142333984375,"y":1482.2857666015625,"wires":[["5c735603.1cf4f8"]]},{"id":"23784c1a.9a2954","type":"comment","z":"4cb9f36b.f002ac","name":"Switch States","info":"","x":122.5,"y":572.6666488647461,"wires":[]},{"id":"b74125f5.65daf8","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["1bd9b63f4b60"],"name":"On Maintenance Stop","x":184.5714111328125,"y":1482.1428699493408,"wires":[["10416910.612717"]]},{"id":"746fb53b.07fecc","type":"device function","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"do initial settings","func":"//Set bad MotorTemp (15% likelihood)\nvar outOfNormalRange = Math.random() * 100 < 15;\nif(outOfNormalRange){\n maxMotorTemp = Math.floor(Math.random() * (220 - 185 + 1)) + 185;\n}\nreturn msg;","outputs":"1","noerr":0,"x":564.1190185546875,"y":447.5713920593262,"wires":[["f03df576.049558","832051e2.d1a91","11a486a9.1e27e9"]]},{"id":"10416910.612717","type":"device function","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"Reset maintenance reason ","func":"if(maintenanceStop === false){\n maintenanceReason = \"\";\n}\nreturn msg;","outputs":1,"noerr":0,"x":436.42852783203125,"y":1482.4283447265625,"wires":[["d4027df2.203b5"]]},{"id":"bb84334a.a8087","type":"comment","z":"4cb9f36b.f002ac","name":"*************************************** Device UI ***************************************","info":"","x":448.3570556640625,"y":1986.5,"wires":[]},{"id":"8e5aa549.6a69e8","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":350.16662216186523,"y":3039.285614013672,"wires":[["526adf02.9e908","d5e1f2d1.d6afe","e35cffca.46dc","8c15af06.72e5b","40082e53.a6974","4183a0e2.fe22c","7bbebb01.dd3e74","db75387a.435308","a00c24a8.28d458","f3e188a.6550d78","7382b99a.4067b8","946bbea8.f08f9","4455f5bb.c2f81c","9a960930.44a018","7e7a89a7.1dd758","1ad60c2.5c125f4","9ddcebc5.07ea78","e316dac9.54f938","a8f759bf.839048","91307660.b9a6f8","f7ae9270.ab6d6","27a3bf1f.a2076","310c12c2.af25fe","c3f30064.8c521","d0bdd356.72afa"]]},{"id":"526adf02.9e908","type":"change","z":"4cb9f36b.f002ac","name":"format payload","rules":[{"t":"move","p":"payload.properties.motorTemp","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":470.9285430908203,"y":2692.1428661346436,"wires":[["f81fe497.0d7c68"]]},{"id":"d5e1f2d1.d6afe","type":"ui_text","z":"4cb9f36b.f002ac","group":"777dfe18.fc423","order":9,"width":0,"height":0,"name":"Load","label":"load (kg)","format":"{{msg.payload.properties.load}}","layout":"row-left","x":522.3571014404297,"y":3232,"wires":[]},{"id":"e35cffca.46dc","type":"ui_text","z":"4cb9f36b.f002ac","group":"777dfe18.fc423","order":5,"width":0,"height":0,"name":"Cabin Speed","label":"Cabin Speed (feet/sec)","format":"{{msg.payload.properties.cabinSpeed}}","layout":"row-left","x":531.3571014404297,"y":3338,"wires":[]},{"id":"8c15af06.72e5b","type":"ui_text","z":"4cb9f36b.f002ac","group":"777dfe18.fc423","order":6,"width":0,"height":0,"name":"State","label":"State","format":"{{msg.payload.properties.state}}","layout":"row-left","x":515.0237884521484,"y":3386.666748046875,"wires":[]},{"id":"40082e53.a6974","type":"ui_text","z":"4cb9f36b.f002ac","group":"777dfe18.fc423","order":8,"width":0,"height":0,"name":"Current Floor","label":"Current Floor","format":"{{msg.payload.properties.currentFloor}}","layout":"row-left","x":489.69045639038086,"y":3472.000009536743,"wires":[]},{"id":"4183a0e2.fe22c","type":"ui_text","z":"4cb9f36b.f002ac","group":"777dfe18.fc423","order":7,"width":0,"height":0,"name":"Door open","label":"Door open","format":"{{msg.payload.properties.doorOpen}}","layout":"row-left","x":504.0237693786621,"y":3514.666679382324,"wires":[]},{"id":"7bbebb01.dd3e74","type":"ui_text","z":"4cb9f36b.f002ac","group":"777dfe18.fc423","order":10,"width":0,"height":0,"name":"Direction","label":"Direction","format":"{{msg.payload.properties.direction === 1 ? \"UP\" : \"DOWN\"}}","layout":"row-left","x":583.3571166992188,"y":3558.3333129882812,"wires":[]},{"id":"f81fe497.0d7c68","type":"ui_slider","z":"4cb9f36b.f002ac","name":"Motor Temp","label":"Motor Temp","group":"8d5bfc2c.7e319","order":1,"width":0,"height":0,"passthru":false,"topic":"","min":"120","max":"220","x":661.6428070068359,"y":2688.428575515747,"wires":[["79b8f6a9.f23da8"]]},{"id":"753d8c37.b18a24","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":311.9285430908203,"y":2688.1428661346436,"wires":[["526adf02.9e908"]]},{"id":"aefe6992.47fa58","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":304.357120513916,"y":3239,"wires":[["d5e1f2d1.d6afe"]]},{"id":"559a7fc8.25f0f","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":306.357120513916,"y":3292,"wires":[["310c12c2.af25fe"]]},{"id":"d238a048.41ca5","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":333.357120513916,"y":3347,"wires":[["e35cffca.46dc"]]},{"id":"67e269f.f79d098","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":329.35711669921875,"y":3390,"wires":[["8c15af06.72e5b"]]},{"id":"f0501a75.300ce8","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":336.357120513916,"y":3469,"wires":[["40082e53.a6974"]]},{"id":"bdbc9aab.d55668","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":337.357120513916,"y":3525,"wires":[["4183a0e2.fe22c"]]},{"id":"ef592dd1.e0b92","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":329.357120513916,"y":3569,"wires":[["7bbebb01.dd3e74"]]},{"id":"79b8f6a9.f23da8","type":"function","z":"4cb9f36b.f002ac","name":"set ID","func":"msg.deviceId = flow.get(\"deviceId\");\nreturn msg;","outputs":1,"noerr":0,"x":834.071418762207,"y":2690.000015258789,"wires":[["82aa484.93ea4b8"]]},{"id":"80bca40e.e7a638","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["e76a0e692587"],"name":"On motor temp change","x":122.92854309082031,"y":2687.142873764038,"wires":[["753d8c37.b18a24"]]},{"id":"9d56f337.62eb7","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["bcca0e31b9d6"],"name":"On load Change","x":127.35712051391602,"y":3238,"wires":[["aefe6992.47fa58"]]},{"id":"39f0e64b.e1327a","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["80cc3cb81053"],"name":"On Cabin Temp Change","x":138.35712051391602,"y":3287,"wires":[["559a7fc8.25f0f"]]},{"id":"923a9ff3.33713","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["40741d3132a4"],"name":"On Cabin Speed Change","x":147.35712051391602,"y":3347,"wires":[["d238a048.41ca5"]]},{"id":"b4e6538c.01b5e","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["745ce852562a"],"name":"On State Change","x":118.35711669921875,"y":3390,"wires":[["67e269f.f79d098"]]},{"id":"47bffc0.2d9e804","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["c2881d12e8f3"],"name":"On Current floor Change","x":150.35712051391602,"y":3469,"wires":[["f0501a75.300ce8"]]},{"id":"cc7dad15.abf17","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["38416d39cffe"],"name":"On Door Open Change","x":141.35712051391602,"y":3525,"wires":[["bdbc9aab.d55668"]]},{"id":"8e75b87e.eb4748","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["297fd95abda8"],"name":"On Direction Change","x":133.35712051391602,"y":3569,"wires":[["ef592dd1.e0b92"]]},{"id":"82aa484.93ea4b8","type":"set properties","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"Set motor Temp","propAll":false,"prop":"e76a0e692587","valueType":"msg","value":"payload","x":1020.7142868041992,"y":2691.1428689956665,"wires":[[]]},{"id":"2b7cd04.06d8f3","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":306.357120513916,"y":3152,"wires":[["c3f30064.8c521"]]},{"id":"774a1ee4.9a4ee","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["e76a0e692587"],"name":"On motor temp change","x":136.35712051391602,"y":3157,"wires":[["2b7cd04.06d8f3"]]},{"id":"5580223b.ba94dc","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["80cc3cb81053"],"name":"On Cabin Temp change","x":122.49997329711914,"y":2628.4285736083984,"wires":[["6ec4059f.01d21c"]]},{"id":"6ec4059f.01d21c","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":311.49997329711914,"y":2629.428565979004,"wires":[["db75387a.435308"]]},{"id":"db75387a.435308","type":"change","z":"4cb9f36b.f002ac","name":"format payload","rules":[{"t":"move","p":"payload.properties.cabinTemp","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":470.49997329711914,"y":2633.428565979004,"wires":[["dc2282ce.78c7b"]]},{"id":"dc2282ce.78c7b","type":"ui_slider","z":"4cb9f36b.f002ac","name":"Cabin Temp","label":"Cabin Temp","group":"8d5bfc2c.7e319","order":2,"width":0,"height":0,"passthru":false,"topic":"","min":"60","max":"100","x":661.2142372131348,"y":2629.7142753601074,"wires":[["1f3e7ba6.c9a9a4"]]},{"id":"1f3e7ba6.c9a9a4","type":"function","z":"4cb9f36b.f002ac","name":"set ID","func":"msg.deviceId = flow.get(\"deviceId\");\nreturn msg;","outputs":1,"noerr":0,"x":833.6428489685059,"y":2631.2857151031494,"wires":[["38e94b49.4aec94"]]},{"id":"38e94b49.4aec94","type":"set properties","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"Set Cabin Temp","propAll":false,"prop":"80cc3cb81053","valueType":"msg","value":"payload","x":1020.285717010498,"y":2632.428568840027,"wires":[[]]},{"id":"c4517cd5.417a3","type":"set properties","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"Set Force Open Door Temp","propAll":false,"prop":"717226438586","valueType":"msg","value":"payload","x":1056.7142906188965,"y":2764.142868041992,"wires":[[]]},{"id":"900f9ff4.b3486","type":"function","z":"4cb9f36b.f002ac","name":"set ID","func":"msg.deviceId = flow.get(\"deviceId\");\nreturn msg;","outputs":1,"noerr":0,"x":847.2142562866211,"y":2760.142868041992,"wires":[["c4517cd5.417a3"]]},{"id":"a00c24a8.28d458","type":"change","z":"4cb9f36b.f002ac","name":"format payload","rules":[{"t":"move","p":"payload.properties.forceOpenDoor","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":482.6428871154785,"y":2759.4285926818848,"wires":[["6b013caf.8362a4"]]},{"id":"6aad013.198ee","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":325.0714340209961,"y":2761.142873764038,"wires":[["a00c24a8.28d458"]]},{"id":"bd3d5b36.877b88","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["e76a0e692587"],"name":"On force door open change","x":138.92854690551758,"y":2760.1428728103638,"wires":[["6aad013.198ee"]]},{"id":"6b013caf.8362a4","type":"ui_switch","z":"4cb9f36b.f002ac","name":"Force Open Door","label":"Force Open Door","group":"8d5bfc2c.7e319","order":4,"width":0,"height":0,"passthru":false,"topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":678.928539276123,"y":2759.857147216797,"wires":[["900f9ff4.b3486"]]},{"id":"3a33d72e.7cb218","type":"set properties","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"Set maintenance stop","propAll":false,"prop":"1bd9b63f4b60","valueType":"msg","value":"payload","x":1042.4285888671875,"y":2808.2857055664062,"wires":[[]]},{"id":"ab8cd33b.c377f","type":"function","z":"4cb9f36b.f002ac","name":"set ID","func":"msg.deviceId = flow.get(\"deviceId\");\nreturn msg;","outputs":1,"noerr":0,"x":840.9285888671875,"y":2810.2857055664062,"wires":[["3a33d72e.7cb218","cf1195e9.d7f728"]]},{"id":"2a5e320.7e751ce","type":"ui_switch","z":"4cb9f36b.f002ac","name":"maintenanceStop","label":"maintenanceStop","group":"8d5bfc2c.7e319","order":5,"width":0,"height":0,"passthru":false,"topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":684.6428489685059,"y":2816.999984741211,"wires":[["ab8cd33b.c377f"]]},{"id":"f3e188a.6550d78","type":"change","z":"4cb9f36b.f002ac","name":"format payload","rules":[{"t":"move","p":"payload.properties.maintenanceStop","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":488.3571968078613,"y":2816.571430206299,"wires":[["2a5e320.7e751ce"]]},{"id":"81aea15.b3a0a6","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":330.7857437133789,"y":2818.285711288452,"wires":[["f3e188a.6550d78"]]},{"id":"714e7573.b307ac","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["1bd9b63f4b60"],"name":"On maintenanceStop change","x":144.6428565979004,"y":2817.285710334778,"wires":[["81aea15.b3a0a6"]]},{"id":"e63d74f7.bffc88","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["bd4d2913cb07"],"name":"On Maintenance Reason Change","x":145,"y":3611,"wires":[["8b986923.23c978"]]},{"id":"8b986923.23c978","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":354,"y":3609,"wires":[["7382b99a.4067b8"]]},{"id":"7382b99a.4067b8","type":"ui_text","z":"4cb9f36b.f002ac","group":"777dfe18.fc423","order":11,"width":0,"height":0,"name":"Maintenance Reason","label":"Maintenance Reason","format":"{{msg.payload.properties.maintenanceReason}}","layout":"row-left","x":551.3333206176758,"y":3614.6666622161865,"wires":[]},{"id":"946bbea8.f08f9","type":"ui_text","z":"4cb9f36b.f002ac","group":"9396bced.f047d","order":15,"width":0,"height":0,"name":"Max Motor Temp","label":"Max Motor Temp","format":"{{msg.payload.properties.maxMotorTemp}}","layout":"row-left","x":501,"y":3198,"wires":[]},{"id":"94665ef0.ece6","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":324,"y":3195,"wires":[["946bbea8.f08f9"]]},{"id":"6ed7499e.c66f68","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["efd6898dd4db"],"name":"On max motor temp change","x":135,"y":3196,"wires":[["94665ef0.ece6"]]},{"id":"e603a62b.918398","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["efd6898dd4db"],"name":"On Max Motor temp change","x":135,"y":2724,"wires":[["3bc50e0.88723f2"]]},{"id":"3bc50e0.88723f2","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":323,"y":2724.9999923706055,"wires":[["9a960930.44a018"]]},{"id":"9a960930.44a018","type":"change","z":"4cb9f36b.f002ac","name":"format payload","rules":[{"t":"move","p":"payload.properties.maxMotorTemp","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":483,"y":2725,"wires":[["153b1107.76ee6f"]]},{"id":"153b1107.76ee6f","type":"ui_slider","z":"4cb9f36b.f002ac","name":"Max Motor Temp","label":"Max Motor Temp","group":"8d5bfc2c.7e319","order":6,"width":0,"height":0,"passthru":false,"topic":"","min":"141","max":"220","x":692.7142639160156,"y":2725.285701751709,"wires":[["b40961ce.c7c5a"]]},{"id":"b40961ce.c7c5a","type":"function","z":"4cb9f36b.f002ac","name":"set ID","func":"msg.deviceId = flow.get(\"deviceId\");\nreturn msg;","outputs":1,"noerr":0,"x":845.1428756713867,"y":2726.857141494751,"wires":[["d2579658.4d1d88"]]},{"id":"d2579658.4d1d88","type":"set properties","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"Set max motor Temp","propAll":false,"prop":"efd6898dd4db","valueType":"msg","value":"payload","x":1051.785743713379,"y":2727.9999952316284,"wires":[[]]},{"id":"929f7356.8c0db","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["c15961c2f7bf"],"name":"On Next Stop","x":112,"y":3435,"wires":[["2173c53e.8266ba"]]},{"id":"2173c53e.8266ba","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":338,"y":3435,"wires":[["7e7a89a7.1dd758"]]},{"id":"7e7a89a7.1dd758","type":"ui_text","z":"4cb9f36b.f002ac","group":"777dfe18.fc423","order":14,"width":0,"height":0,"name":"Next Stop","label":"Next Stop","format":"{{msg.payload.properties.gotoFloor}}","layout":"row-left","x":491.3333206176758,"y":3436.3333225250244,"wires":[]},{"id":"9d332f81.87818","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["bcca0e31b9d6"],"name":"On load change","x":108.33332824707031,"y":2583.3333320617676,"wires":[["bf756e3b.c3b35"]]},{"id":"bf756e3b.c3b35","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":317.3333282470703,"y":2584.333324432373,"wires":[["4455f5bb.c2f81c"]]},{"id":"4455f5bb.c2f81c","type":"change","z":"4cb9f36b.f002ac","name":"format payload","rules":[{"t":"move","p":"payload.properties.load","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":476.3333282470703,"y":2588.333324432373,"wires":[["43d3437d.337a5c"]]},{"id":"43d3437d.337a5c","type":"ui_slider","z":"4cb9f36b.f002ac","name":"Load","label":"Load","group":"8d5bfc2c.7e319","order":3,"width":0,"height":0,"passthru":false,"topic":"","min":"0","max":"2000","x":647.0475921630859,"y":2584.6190338134766,"wires":[["8f03d4e7.cc0de8"]]},{"id":"8f03d4e7.cc0de8","type":"function","z":"4cb9f36b.f002ac","name":"set ID","func":"msg.deviceId = flow.get(\"deviceId\");\nreturn msg;","outputs":1,"noerr":0,"x":839.476203918457,"y":2586.1904735565186,"wires":[["9506732e.e137d"]]},{"id":"9506732e.e137d","type":"set properties","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"Set Load","propAll":false,"prop":"bcca0e31b9d6","valueType":"msg","value":"payload","x":1006.1190719604492,"y":2587.333327293396,"wires":[[]]},{"id":"27ca993f.f1fc26","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["438e94df7c4a"],"name":"On Min Motor temp change","x":141.66665649414062,"y":2875,"wires":[["47559d73.fd9c74"]]},{"id":"47559d73.fd9c74","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":329.6666564941406,"y":2875.9999923706055,"wires":[["1ad60c2.5c125f4"]]},{"id":"1ad60c2.5c125f4","type":"change","z":"4cb9f36b.f002ac","name":"format payload","rules":[{"t":"move","p":"payload.properties.minMotorTemp","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":489.6666564941406,"y":2876,"wires":[["da8535c3.db1f48"]]},{"id":"da8535c3.db1f48","type":"ui_slider","z":"4cb9f36b.f002ac","name":"Min Motor Temp","label":"Min Motor Temp","group":"8d5bfc2c.7e319","order":7,"width":0,"height":0,"passthru":false,"topic":"","min":"100","max":"140","x":689.3809204101562,"y":2876.285701751709,"wires":[["8b4c0366.871a6"]]},{"id":"8b4c0366.871a6","type":"function","z":"4cb9f36b.f002ac","name":"set ID","func":"msg.deviceId = flow.get(\"deviceId\");\nreturn msg;","outputs":1,"noerr":0,"x":851.8095321655273,"y":2877.857141494751,"wires":[["f4810782.9f37c8"]]},{"id":"f4810782.9f37c8","type":"set properties","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"Set min motor Temp","propAll":false,"prop":"438e94df7c4a","valueType":"msg","value":"payload","x":1058.4524002075195,"y":2878.9999952316284,"wires":[[]]},{"id":"9ddcebc5.07ea78","type":"ui_text","z":"4cb9f36b.f002ac","group":"9396bced.f047d","order":16,"width":0,"height":0,"name":"Min Motor Temp","label":"Min Motor Temp","format":"{{msg.payload.properties.minMotorTemp}}","layout":"row-left","x":752.3332977294922,"y":3084.6666259765625,"wires":[]},{"id":"2ae2c4f4.c53bcc","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":337.3333282470703,"y":3108.6666564941406,"wires":[["9ddcebc5.07ea78"]]},{"id":"7cf4c1dc.50d07","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["438e94df7c4a"],"name":"On min motor temp change","x":148.3333282470703,"y":3109.6666564941406,"wires":[["2ae2c4f4.c53bcc"]]},{"id":"34826a33.9de376","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["2b397533cfa2"],"name":"curtainOfLightBreak Change","x":135,"y":3683,"wires":[["7a42e395.f1932c"]]},{"id":"7a42e395.f1932c","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":354,"y":3681,"wires":[["e316dac9.54f938"]]},{"id":"e316dac9.54f938","type":"ui_text","z":"4cb9f36b.f002ac","group":"777dfe18.fc423","order":13,"width":0,"height":0,"name":"curtain Of Light Break","label":"Curtain Of LightBreak","format":"{{msg.payload.properties.curtainOfLightBreak}}","layout":"row-left","x":551.3333206176758,"y":3686.6666622161865,"wires":[]},{"id":"7e1fa82f.a13518","type":"ui_gauge","z":"4cb9f36b.f002ac","name":"","group":"777dfe18.fc423","order":2,"width":0,"height":0,"gtype":"gage","title":"Motor Temp","label":"Motor Temp","format":"{{value | number:1}}°F","min":"130","max":"200.00","colors":["#00b500","#e6e600","#ca3838"],"x":1013.4999847412109,"y":3167,"wires":[]},{"id":"337b78ce.f63978","type":"ui_gauge","z":"4cb9f36b.f002ac","name":"","group":"777dfe18.fc423","order":4,"width":0,"height":0,"gtype":"gage","title":"Cabin Temp","label":"°F","format":"{{value}}°F","min":"50","max":"140","colors":["#00b500","#e6e600","#ca3838"],"x":1019.6250457763672,"y":3217.125,"wires":[]},{"id":"aff6a4d.dbc4658","type":"set properties","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"Set maintenance Reason","propAll":false,"prop":"bd4d2913cb07","valueType":"msg","value":"payload","x":1166,"y":2843,"wires":[[]]},{"id":"cf1195e9.d7f728","type":"change","z":"4cb9f36b.f002ac","name":"Set maintenance reason ","rules":[{"t":"set","p":"payload","pt":"msg","to":"manual","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":927.5,"y":2843,"wires":[["aff6a4d.dbc4658"]]},{"id":"a8f759bf.839048","type":"ui_text","z":"4cb9f36b.f002ac","group":"777dfe18.fc423","order":12,"width":0,"height":0,"name":"cleanessOfFloor","label":"Cleaness of floor","format":"{{msg.payload.properties.cleanessOfFloor}}","layout":"row-left","x":531.3333206176758,"y":3740,"wires":[]},{"id":"e24f844b.fc2498","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":354,"y":3734.3333377838135,"wires":[["a8f759bf.839048"]]},{"id":"f8c19f76.48ead","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["299639e87d50"],"name":"cleanessOfFloor Change","x":125,"y":3736.3333377838135,"wires":[["e24f844b.fc2498"]]},{"id":"f173e86c.4030d8","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["459e0d4c3af6"],"name":"On curtainOfLightBreakRate","x":161.66665649414062,"y":2948.3333129882812,"wires":[["8f068356.ac247"]]},{"id":"8f068356.ac247","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":349.6666564941406,"y":2949.3333053588867,"wires":[["91307660.b9a6f8"]]},{"id":"91307660.b9a6f8","type":"change","z":"4cb9f36b.f002ac","name":"format payload","rules":[{"t":"move","p":"payload.properties.curtainOfLightBreakRate","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":509.6666564941406,"y":2949.3333129882812,"wires":[["66db8d44.7847b4"]]},{"id":"66db8d44.7847b4","type":"ui_slider","z":"4cb9f36b.f002ac","name":"Curtain of Light Break Rate","label":"Curtain of Light Break Rate","group":"8d5bfc2c.7e319","order":8,"width":0,"height":0,"passthru":false,"topic":"","min":"10","max":"20","x":751.0475769042969,"y":2957.9523487091064,"wires":[["aef7c8d7.139e38"]]},{"id":"aef7c8d7.139e38","type":"function","z":"4cb9f36b.f002ac","name":"set ID","func":"msg.deviceId = flow.get(\"deviceId\");\nreturn msg;","outputs":1,"noerr":0,"x":938.476188659668,"y":2944.523780822754,"wires":[["ea5d93bf.1377a"]]},{"id":"ea5d93bf.1377a","type":"set properties","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"Set Curtain of Light Break Rate","propAll":false,"prop":"459e0d4c3af6","valueType":"msg","value":"payload","x":1158.452392578125,"y":2945.666633605957,"wires":[[]]},{"id":"f7ae9270.ab6d6","type":"ui_text","z":"4cb9f36b.f002ac","group":"9396bced.f047d","order":17,"width":0,"height":0,"name":"Curtain of Light Break Rate","label":"Curtain of Light Break Rate","format":"{{msg.payload.properties.curtainOfLightBreakRate}}","layout":"row-left","x":738,"y":3806.6666774749756,"wires":[]},{"id":"f741800.9883b8","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":435.6666717529297,"y":3801.000009536743,"wires":[["f7ae9270.ab6d6"]]},{"id":"e4c9ad18.8ced2","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["459e0d4c3af6"],"name":"On Curtain of Light Break Rate Change","x":165,"y":3806.3333377838135,"wires":[["f741800.9883b8"]]},{"id":"27a3bf1f.a2076","type":"ui_text","z":"4cb9f36b.f002ac","group":"9396bced.f047d","order":18,"width":0,"height":0,"name":"floorStopReq","label":"Next Stops","format":"{{msg.payload.properties.floorStopReq}}","layout":"row-left","x":688,"y":3870,"wires":[]},{"id":"2371cbc3.cae434","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":435.6666717529297,"y":3864.3333320617676,"wires":[["27a3bf1f.a2076"]]},{"id":"346c369a.52e87a","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["7fa0c8927a50"],"name":"On Floor Req Change","x":115,"y":3869.666660308838,"wires":[["2371cbc3.cae434"]]},{"id":"63b748ad.a02008","type":"ui_button","z":"4cb9f36b.f002ac","name":"","group":"7cca88d7.3bc948","order":2,"width":"1","height":"1","label":"0","color":"","icon":"","payload":"0","payloadType":"num","topic":"","x":104.5,"y":2230.0001220703125,"wires":[["58dfd306.3ef15c"]]},{"id":"4c277c44.856654","type":"ui_button","z":"4cb9f36b.f002ac","name":"","group":"7cca88d7.3bc948","order":3,"width":"1","height":"1","label":"1","color":"","icon":"","payload":"1","payloadType":"num","topic":"","x":109,"y":2264.0001220703125,"wires":[["58dfd306.3ef15c"]]},{"id":"aa37c182.4faef","type":"ui_button","z":"4cb9f36b.f002ac","name":"","group":"7cca88d7.3bc948","order":4,"width":"1","height":"1","label":"2","color":"","icon":"","payload":"2","payloadType":"num","topic":"","x":111,"y":2297.0001220703125,"wires":[["58dfd306.3ef15c"]]},{"id":"fa9f8149.5cecf","type":"ui_button","z":"4cb9f36b.f002ac","name":"","group":"7cca88d7.3bc948","order":5,"width":"1","height":"1","label":"3","color":"","icon":"","payload":"3","payloadType":"num","topic":"","x":112,"y":2331.0001220703125,"wires":[["58dfd306.3ef15c"]]},{"id":"78bd87a2.23dc58","type":"ui_button","z":"4cb9f36b.f002ac","name":"","group":"7cca88d7.3bc948","order":6,"width":"1","height":"1","label":"4","color":"","icon":"","payload":"4","payloadType":"num","topic":"","x":113,"y":2366.0001220703125,"wires":[["58dfd306.3ef15c"]]},{"id":"ab381d9c.f4103","type":"ui_button","z":"4cb9f36b.f002ac","name":"","group":"7cca88d7.3bc948","order":7,"width":"1","height":"1","label":"5","color":"","icon":"","payload":"5","payloadType":"num","topic":"","x":117,"y":2400.0001220703125,"wires":[["58dfd306.3ef15c"]]},{"id":"86d69891.f9c8c8","type":"ui_button","z":"4cb9f36b.f002ac","name":"","group":"7cca88d7.3bc948","order":8,"width":"1","height":"1","label":"6","color":"","icon":"","payload":"6","payloadType":"num","topic":"","x":118,"y":2432.0001220703125,"wires":[["58dfd306.3ef15c"]]},{"id":"58dfd306.3ef15c","type":"function","z":"4cb9f36b.f002ac","name":"set ID","func":"msg.deviceId = flow.get(\"deviceId\");\nreturn msg;","outputs":1,"noerr":0,"x":314,"y":2291.0001220703125,"wires":[["707f574b.c5bbd8"]]},{"id":"707f574b.c5bbd8","type":"device function","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"Add floor stop","func":"floorStopReq.push(msg.payload);\nfloorStopReq.touch();\nreturn msg;","outputs":1,"noerr":0,"x":522.5,"y":2288.0001220703125,"wires":[[]]},{"id":"c3f30064.8c521","type":"change","z":"4cb9f36b.f002ac","name":"format payload","rules":[{"t":"move","p":"payload.properties.motorTemp","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":813.6190032958984,"y":3174.33349609375,"wires":[["7e1fa82f.a13518"]]},{"id":"310c12c2.af25fe","type":"change","z":"4cb9f36b.f002ac","name":"format payload","rules":[{"t":"move","p":"payload.properties.cabinTemp","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":843.6190032958984,"y":3240.3333740234375,"wires":[["337b78ce.f63978"]]},{"id":"b07c4682.edc8f8","type":"link in","z":"4cb9f36b.f002ac","name":"Reset Values","links":["208b03c8.73255c","57a17dcc.06a814"],"x":227.47619247436523,"y":3037.9999866485596,"wires":[["8e5aa549.6a69e8"]]},{"id":"e73470e5.aaf1c","type":"comment","z":"4cb9f36b.f002ac","name":"Reset values (when a devices is created or active device is changed","info":"","x":300.33331298828125,"y":2998.476219177246,"wires":[]},{"id":"95a4a8b4.2092e8","type":"comment","z":"4cb9f36b.f002ac","name":"Send 'Status' event each 5 sec if not in Maintenance State","info":"","x":551.6431274414062,"y":1251.952392578125,"wires":[]},{"id":"f03df576.049558","type":"set properties","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"Set state to idle","propAll":false,"prop":"745ce852562a","valueType":"str","value":"idle","x":834.0714111328125,"y":457.0476303100586,"wires":[["c4094d8d.2030e"]]},{"id":"4cf579d7.e0ac78","type":"set properties","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"Set state to off","propAll":false,"prop":"745ce852562a","valueType":"str","value":"off","x":596.4523391723633,"y":1843.4167861938477,"wires":[["df321cd2.aae86"]]},{"id":"5c735603.1cf4f8","type":"ibmiot out","z":"4cb9f36b.f002ac","authentication":"boundService","apiKey":"","outputType":"evt","deviceId":"frompayload","deviceType":"0.14.6","eventCommandType":"frompayload","format":"json","data":"{}","qos":0,"name":"IBM IoT","service":"registered","x":1052.5001525878906,"y":1375.3809814453125,"wires":[]},{"id":"d4027df2.203b5","type":"delay","z":"4cb9f36b.f002ac","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":640.7856750488281,"y":1482.2857666015625,"wires":[["49da86c8.46a308"]]},{"id":"fec4010d.ff005","type":"switch","z":"4cb9f36b.f002ac","name":"Switch State","property":"payload.properties.state","propertyType":"msg","rules":[{"t":"eq","v":"idle","vt":"str"},{"t":"eq","v":"moving","vt":"str"},{"t":"eq","v":"stopped","vt":"str"},{"t":"eq","v":"loading","vt":"str"},{"t":"eq","v":"maintenance","vt":"str"}],"checkall":"true","outputs":5,"x":234.78570556640625,"y":670.333381652832,"wires":[["503c19ba.14c838"],["64d0e0b2.7e187"],["8a59b3d9.9dc58"],["879045f6.df11f8"],["e89fb9d6.d125c8"]]},{"id":"503c19ba.14c838","type":"device function","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"idle","func":"if(!forceOpenDoor)\n doorOpen = false;\ndirection = 0;\n//cool down motor\nvar newMotorTemp = motorTemp - 0.05;\nmotorTemp = (newMotorTemp < minMotorTemp) ? minMotorTemp : (newMotorTemp > maxMotorTemp) ? maxMotorTemp :newMotorTemp;\nreturn msg;\n","outputs":"1","noerr":0,"x":485.952392578125,"y":686.0000534057617,"wires":[["84102a.a6b0dfd8"]]},{"id":"e89fb9d6.d125c8","type":"device function","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"Maintenance ","func":"doorOpen = true;\ndirection = 0;\nvar newMotorTemp = motorTemp - 0.2;\nmotorTemp = (newMotorTemp < minMotorTemp) ? minMotorTemp : (newMotorTemp > maxMotorTemp) ? maxMotorTemp : newMotorTemp;\n;\nreturn msg;","outputs":1,"noerr":0,"x":482.9523620605469,"y":1096.333396911621,"wires":[["269daf26.cde54"]]},{"id":"269daf26.cde54","type":"delay","z":"4cb9f36b.f002ac","name":"maintenance Stop For 10 minutes ","pauseType":"delay","timeout":"10","timeoutUnits":"minutes","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":735.6190185546875,"y":1095.000144958496,"wires":[["f5c2e76f.be12f8"]]},{"id":"f5c2e76f.be12f8","type":"device function","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"Done Maintenance Stop","func":"if(maintenanceStop){//if still in maintenanceStop (was not canceled)\n maintenanceStop = false;\n maintenanceReason = \"\";\n return msg;\n}\nelse\n return null;","outputs":"1","noerr":0,"x":1010.6190185546875,"y":1094.0000839233398,"wires":[["ec1465bf.909b38"]]},{"id":"ec1465bf.909b38","type":"device function","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"calc next state","func":"var nextState = null;\nswitch(state){\ncase \"idle\":\n\tif(maintenanceStop){\n\t\tnextState = \"maintenance\";\n\t}\n\telse if(floorStopReq.length > 0){\n\t\tnextState = \"moving\";\t\t\n\t}\n\telse{\n\t\tnextState = \"idle\"\n\t}\n\tbreak;\n\t\ncase \"moving\":\n\tnextState = \"stopped\";\n\tbreak;\n\t\ncase \"stopped\":\n\tnextState = \"loading\";\n\tbreak;\n\t\ncase \"loading\":\n\tif(maintenanceStop){\n\t\tnextState = \"maintenance\";\n\t}\n\telse if(floorStopReq.length > 0){\n\t\tnextState = \"moving\";\t\t\n\t}\n\telse{\n\t\tnextState = \"idle\";\t\t\n\t}\n\tbreak;\n\t\ncase \"maintenance\":\n\tnextState = \"idle\";\n\tbreak;\n\t\ndefault:\n var err = \"unknow state: \" + state;\n node.error(err);\n\tnode.status({fill:\"red\",shape:\"ring\",text: err});\n\treturn null;\n}\nnode.status({fill:\"green\",shape:\"ring\",text: msg.deviceId + \":\" + nextState});\nmsg.payload.properties = {state: nextState};\nreturn msg;","outputs":1,"noerr":0,"x":1141.7856750488281,"y":783.666748046875,"wires":[["a2f7e597.cb8a08"]]},{"id":"914e3d4.e488dc","type":"device function","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"moving","func":"//increase cabin speed\nif(cabinSpeed <15){\ncabinSpeed = ( (cabinSpeed + 4) <= 14) ? cabinSpeed + 4 : 14;\n}\n\n//increase motor tepm\nvar newMotorTemp = motorTemp + 0.02;\nmotorTemp = (newMotorTemp < minMotorTemp) ? minMotorTemp : (newMotorTemp > maxMotorTemp) ? maxMotorTemp :newMotorTemp;\n\n//update current floor\nvar nextFloor = currentFloor + direction;\n//make sure floor is in range \nif(nextFloor < 0){\n direction = 1;\n currentFloor = 0;\n} \nelse if(nextFloor > numberOfFloors){\n direction = -1;\n currentFloor = numberOfFloors;\n}\nelse{//set as current floor\n currentFloor = nextFloor;\n}\n\n//if maintenanceStop is set the stop at this floor\nif(maintenanceStop)\n gotoFloor = currentFloor;\n\n//check if need to stop\nif(currentFloor === gotoFloor){\n return [msg, null];//stop\n}\nelse{//keep moving\n return [null,msg];//keep moving \n}\n","outputs":"2","noerr":0,"x":880.6189956665039,"y":797.6667556762695,"wires":[["ec1465bf.909b38"],["380d4c4a.c90b44"]]},{"id":"380d4c4a.c90b44","type":"delay","z":"4cb9f36b.f002ac","name":"moving 3 sec per floor ","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":848.6189270019531,"y":846.6667938232422,"wires":[["914e3d4.e488dc"]]},{"id":"64d0e0b2.7e187","type":"device function","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"moving (start)","func":"\nif(!forceOpenDoor){\n doorOpen = false;\n}\n//set dest floor\ndo {\n gotoFloor = floorStopReq.shift();\n}\nwhile(gotoFloor === currentFloor);//filter out req to current floor\nfloorStopReq.touch();\ndirection = (gotoFloor > currentFloor) ? 1 : -1;\nreturn msg;","outputs":"1","noerr":0,"x":497.2856750488281,"y":793.3334884643555,"wires":[["87fd36c2.45d768"]]},{"id":"87fd36c2.45d768","type":"delay","z":"4cb9f36b.f002ac","name":"Start moving 3 sec","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":697.2856750488281,"y":795.3334884643555,"wires":[["914e3d4.e488dc"]]},{"id":"84102a.a6b0dfd8","type":"delay","z":"4cb9f36b.f002ac","name":"Ideal state 10 sec","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":691.2857055664062,"y":687.3333969116211,"wires":[["ec1465bf.909b38"]]},{"id":"8a59b3d9.9dc58","type":"device function","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"Stopping","func":"doorOpen = true;\ncabinSpeed = 0;\nreturn msg;\n\n","outputs":"1","noerr":0,"x":480.619140625,"y":922.3333969116211,"wires":[["1a89d71c.252999"]]},{"id":"1a89d71c.252999","type":"delay","z":"4cb9f36b.f002ac","name":"stopped state 6 sec","pauseType":"delay","timeout":"6","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":720.6190490722656,"y":924.3333969116211,"wires":[["ec1465bf.909b38"]]},{"id":"879045f6.df11f8","type":"device function","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"loading","func":"//if in maintenanceStop put all people out\nif(maintenanceStop){\n load = 0;\n return msg;\n}\n\n//else load & unload poeple (70kg avg each)\nvar minPersonsIn = (load === 0) ? 1 : 0;\nvar personsIn = Math.floor(Math.random() * (4 - minPersonsIn + 1)) + minPersonsIn;\nvar personsOut = Math.floor(Math.random() * (Math.floor(load/70) + 1));\nvar newLoad = load + (personsIn*70) - (personsOut*70);\nload = (newLoad < 0) ? 0 : newLoad;\n\n//curtainOfLightBreak every 10 stops \nif(curtainOfLightBreak !== 1){\n curtainOfLightBreakCount++;\n if(curtainOfLightBreakCount === curtainOfLightBreakRate){\n curtainOfLightBreakCount = 0;\n curtainOfLightBreak = 1;\n }\n}\n\nreturn msg;\n\n","outputs":"1","noerr":0,"x":478.28570556640625,"y":1018.0000228881836,"wires":[["4720d233.37469c"]]},{"id":"4720d233.37469c","type":"delay","z":"4cb9f36b.f002ac","name":"loading state 8 sec","pauseType":"delay","timeout":"8","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":663.9524459838867,"y":1017.6666946411133,"wires":[["7bd02168.260db"]]},{"id":"7bd02168.260db","type":"device function","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"reset curtainOfLightBreak","func":"curtainOfLightBreak = 0;\nreturn msg;","outputs":"1","noerr":0,"x":901.5952758789062,"y":1019.6666793823242,"wires":[["ec1465bf.909b38"]]},{"id":"7db5174d.fb3328","type":"comment","z":"4cb9f36b.f002ac","name":"Idle State","info":"","x":475.9523620605469,"y":648.6666488647461,"wires":[]},{"id":"c8bbb84e.e5dac8","type":"comment","z":"4cb9f36b.f002ac","name":"Moving State","info":"","x":488.9523620605469,"y":760.6666564941406,"wires":[]},{"id":"3ce58ddc.3a6ce2","type":"comment","z":"4cb9f36b.f002ac","name":"Stopping State","info":"","x":494.9523620605469,"y":889.6666793823242,"wires":[]},{"id":"ffbcf8ef.1681b8","type":"comment","z":"4cb9f36b.f002ac","name":"Loading State","info":"","x":483.9523620605469,"y":983.6666870117188,"wires":[]},{"id":"2bd61931.572a66","type":"comment","z":"4cb9f36b.f002ac","name":"Maintenance State","info":"","x":506.9523620605469,"y":1063.6666870117188,"wires":[]},{"id":"35a55e0c.0214a2","type":"link in","z":"4cb9f36b.f002ac","name":"Switch State","links":["c4094d8d.2030e"],"x":179.11903381347656,"y":602.0000228881836,"wires":[["fec4010d.ff005"]]},{"id":"c4094d8d.2030e","type":"link out","z":"4cb9f36b.f002ac","name":"Switch State","links":["35a55e0c.0214a2"],"x":1240.4048500061035,"y":633.3333225250244,"wires":[]},{"id":"b0fb3ec2.56f49","type":"comment","z":"4cb9f36b.f002ac","name":"Switch States","info":"","x":1330.2380828857422,"y":631.6666622161865,"wires":[]},{"id":"6d08ff00.4abe7","type":"comment","z":"4cb9f36b.f002ac","name":"Send Events","info":"","x":134.23807525634766,"y":1204.952392578125,"wires":[]},{"id":"2065a53f.58c21a","type":"link in","z":"4cb9f36b.f002ac","name":"Send Events","links":["832051e2.d1a91"],"x":167.1904754638672,"y":1242.90478515625,"wires":[["ac9e2b91.f7c6a8"]]},{"id":"832051e2.d1a91","type":"link out","z":"4cb9f36b.f002ac","name":"Send Events","links":["2065a53f.58c21a"],"x":733.6189575195312,"y":377.5238037109375,"wires":[]},{"id":"ea7f34ec.188db8","type":"comment","z":"4cb9f36b.f002ac","name":"Start Status Events","info":"","x":844.5237731933594,"y":379.09525299072266,"wires":[]},{"id":"d15b874f.6c5378","type":"comment","z":"4cb9f36b.f002ac","name":"Send 'Maintenance' event when occured","info":"","x":238.6666259765625,"y":1444.6667442321777,"wires":[]},{"id":"a2f7e597.cb8a08","type":"set properties","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"Set state ","propAll":false,"prop":"745ce852562a","valueType":"msg","value":"payload.properties.state","x":1246.2857246398926,"y":717.2500057220459,"wires":[["c4094d8d.2030e"]]},{"id":"56f84107.964e8","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["1bd9b63f4b60"],"name":"On Maintenance Stop Change","x":834.9523010253906,"y":1145.0000305175781,"wires":[["4f4cea93.504134"]]},{"id":"4f4cea93.504134","type":"device function","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"on Cancel Maintenance Stop ","func":"if(maintenanceStop === false && state === \"maintenance\")\n return msg;\nelse\n return null;","outputs":"1","noerr":0,"x":1123.9523010253906,"y":1144.3334045410156,"wires":[["ec1465bf.909b38"]]},{"id":"457f744e.e41f1c","type":"device listener","z":"4cb9f36b.f002ac","monitor":"property","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":false,"schema":"b6e56c3f.e8dd1","props":["3e84a9a94615"],"name":"On auto floors selection change","x":145,"y":2487,"wires":[["6b39cb22.425184"]]},{"id":"6b39cb22.425184","type":"switch","z":"4cb9f36b.f002ac","name":"","property":"payload.deviceId","propertyType":"msg","rules":[{"t":"eq","v":"deviceId","vt":"flow"}],"checkall":"true","outputs":1,"x":341.1428871154785,"y":2490.0000009536743,"wires":[["d0bdd356.72afa"]]},{"id":"d0bdd356.72afa","type":"change","z":"4cb9f36b.f002ac","name":"format payload","rules":[{"t":"move","p":"payload.properties.autoFloorSelection","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":498.71434020996094,"y":2488.285719871521,"wires":[["5f423616.55e8c8"]]},{"id":"5f423616.55e8c8","type":"ui_switch","z":"4cb9f36b.f002ac","name":"Auto Floors Selection","label":"Auto Floors Selection","group":"7cca88d7.3bc948","order":1,"width":0,"height":0,"passthru":false,"topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":704.9999923706055,"y":2488.714274406433,"wires":[["3465b730.5c40f8"]]},{"id":"3465b730.5c40f8","type":"function","z":"4cb9f36b.f002ac","name":"set ID","func":"msg.deviceId = flow.get(\"deviceId\");\nreturn msg;","outputs":1,"noerr":0,"x":873.2857360839844,"y":2485,"wires":[["198d7891.62b927"]]},{"id":"198d7891.62b927","type":"set properties","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"Set auto floors selection ","propAll":false,"prop":"3e84a9a94615","valueType":"msg","value":"payload","x":1074.7857360839844,"y":2476,"wires":[[]]},{"id":"11a486a9.1e27e9","type":"link out","z":"4cb9f36b.f002ac","name":"Auto Floor Selection","links":["71e1e28a.d7a07c","e63ac715.8cbc08"],"x":718.2857055664062,"y":518.6666488647461,"wires":[]},{"id":"4f8c82a.d4d917c","type":"comment","z":"4cb9f36b.f002ac","name":"Auto Floor Selection","info":"","x":823.1906127929688,"y":517.2380981445312,"wires":[]},{"id":"e63ac715.8cbc08","type":"link in","z":"4cb9f36b.f002ac","name":"Auto Floor Selection","links":["11a486a9.1e27e9"],"x":104.61895942687988,"y":1574.666591644287,"wires":[["53ad9b15.78d044"]]},{"id":"6b5f71e.128699","type":"comment","z":"4cb9f36b.f002ac","name":"Auto Floor Selection","info":"","x":173.94050216674805,"y":1539.1546268463135,"wires":[]},{"id":"cb804883.9d5448","type":"delay","z":"4cb9f36b.f002ac","name":"","pauseType":"delay","timeout":"7","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":693.1189880371094,"y":1590.4166259765625,"wires":[["53ad9b15.78d044"]]},{"id":"53ad9b15.78d044","type":"device function","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"Add floor stop","func":"if(!autoFloorSelection)//autoFloorSelection disabled\n return msg;\n \nvar floor = Math.floor(Math.random() * (numberOfFloors - 1));\nif(floorStopReq.indexOf(floor) === -1){\n floorStopReq.push(floor);\n floorStopReq.touch();\n}\nreturn msg;","outputs":1,"noerr":0,"x":381.1190185546875,"y":1576.1666259765625,"wires":[["cb804883.9d5448"]]},{"id":"55564bd8.53a054","type":"function","z":"4cb9f36b.f002ac","name":"setDeviceId","func":"var deviceMsgs = []\nfor(var i = 0; i < msg.payload.instances; i++){\n var deviceId;\n if(i < 9) {\n \n deviceId = \"Elevator0\" + (i+1); \n } else {\n deviceId = \"Elevator\" + (i+1); \n }\n deviceMsgs.push({payload: {deviceId: deviceId}});\n}\nreturn [deviceMsgs];\n","outputs":1,"noerr":0,"x":195.03571319580078,"y":423.83333015441895,"wires":[["39f0f922.022e86"]]},{"id":"cde4d3be.0312","type":"function","z":"4cb9f36b.f002ac","name":"setDeviceId","func":"var deviceMsgs = []\nfor(var i = 0; i < msg.payload.instances; i++){\n var deviceId;\n if(i < 9) {\n \n deviceId = \"Elevator0\" + (i+1); \n } else {\n deviceId = \"Elevator\" + (i+1); \n }\n deviceMsgs.push({payload: {deviceId: deviceId}});\n}\nreturn [deviceMsgs];\n","outputs":1,"noerr":0,"x":397.53570556640625,"y":1843.8334140777588,"wires":[["4cf579d7.e0ac78"]]},{"id":"c63f55ea.d1e978","type":"inject","z":"4cb9f36b.f002ac","name":"stop 10 elevators","topic":"","payload":"{\"instances\" : 10 }","payloadType":"json","repeat":"","crontab":"","once":false,"x":182.3928565979004,"y":1839.2500381469727,"wires":[["cde4d3be.0312"]]},{"id":"365a4188.7b9c6e","type":"set properties","z":"4cb9f36b.f002ac","deviceId":"","schema":"b6e56c3f.e8dd1","name":"get active device properties","propAll":true,"prop":"9f9135f2be17","valueType":"msg","value":"payload","x":1061.0235290527344,"y":2121.3333740234375,"wires":[["57a17dcc.06a814"]]},{"id":"e11ec2e0.6a949","type":"function","z":"4cb9f36b.f002ac","name":"Change active Device","func":"flow.set(\"deviceId\",msg.payload);\nreturn {payload:{deviceId:msg.payload}};","outputs":1,"noerr":0,"x":788.0951232910156,"y":2120.4881591796875,"wires":[["365a4188.7b9c6e"]]},{"id":"dbdeba23.4040b8","type":"function","z":"4cb9f36b.f002ac","name":"add device instance","func":"var devices = flow.get(\"activeDevices\") || [];\nvar selectedId = flow.get(\"deviceId\") || null;\nvar deviceId = msg.payload.deviceId;\nnode.log(msg.payload.deviceId);\nif (devices.indexOf(deviceId) < 0)\n{\n devices.push(msg.payload.deviceId);\n flow.set(\"activeDevices\", devices);\n if (selectedId === null)\n {\n selectedId = devices[0];\n flow.set(\"deviceId\", selectedId);\n }\n}\n\n\nvar msg = {payload: selectedId, options: devices};\n\nreturn msg;\n\n\n\n","outputs":1,"noerr":0,"x":325.78570556640625,"y":2099.2025146484375,"wires":[["98cfca94.78b158"]]},{"id":"3eaee276.b3730e","type":"function","z":"4cb9f36b.f002ac","name":"remove device instance","func":"var devices = flow.get(\"activeDevices\") || [];\nvar selectedId = flow.get(\"deviceId\");\n\nvar deviceId = msg.payload.deviceId;\nvar index = devices.indexOf(deviceId);\nif (index >= 0)\n{\n devices.splice(index,1);\n flow.set(\"activeDevices\", devices);\n\n if (selectedId === deviceId)\n {\n selectedId = devices[0];\n flow.set(\"deviceId\", selectedId);\n \n }\n}\n\nvar msg = {payload: selectedId, options: devices};\n\nreturn msg;\n","outputs":1,"noerr":0,"x":315.8571472167969,"y":2151.631103515625,"wires":[["98cfca94.78b158"]]},{"id":"b9e09042.679c4","type":"device listener","z":"4cb9f36b.f002ac","monitor":"start","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":true,"schema":"b6e56c3f.e8dd1","props":[],"name":"device started","x":101.92855072021484,"y":2064.6312255859375,"wires":[["dbdeba23.4040b8","57a17dcc.06a814"]]},{"id":"4bd8f75d.bee7d8","type":"device listener","z":"4cb9f36b.f002ac","monitor":"stop","monitorAll":false,"deviceId":"","allDeviceIds":true,"allSchemas":false,"allProps":true,"schema":"","props":[],"name":"device deleted","x":107,"y":2117.0594482421875,"wires":[["3eaee276.b3730e"]]},{"id":"98cfca94.78b158","type":"ui_dropdown","z":"4cb9f36b.f002ac","name":"Select instance","label":"Select Device instance","group":"60388ef0.c8684","order":9,"width":"0","height":"0","options":[{"label":"","value":""}],"payload":"","topic":"","x":577.1427917480469,"y":2123.34521484375,"wires":[["e11ec2e0.6a949"]]},{"id":"57a17dcc.06a814","type":"link out","z":"4cb9f36b.f002ac","name":"Reset Values","links":["b07c4682.edc8f8"],"x":1330.4047546386719,"y":2070.297607421875,"wires":[]},{"id":"512a26d6.f60fd8","type":"comment","z":"4cb9f36b.f002ac","name":"Set properties in UI","info":"","x":1441.6666259765625,"y":2066.666748046875,"wires":[]},{"id":"15b288be.b1bbb7","type":"comment","z":"4cb9f36b.f002ac","name":"**************************************** Device Behavior ****************************************","info":"","x":470,"y":43,"wires":[]},{"id":"2ddb266.d9793da","type":"function","z":"4cb9f36b.f002ac","name":"Register Elevators","func":"var payload = msg.payload;\nvar orgid = flow.get(\"orgid\");\n\nmsg = {\n url:\"https://\" + orgid + \".internetofthings.ibmcloud.com/api/v0002/device/types/Elevator/devices\",\n payload: payload,\n headers:{\n \"Accept\":\"application/json\",\n \"Content-type\":\"application/json\"\n }\n};\n\nreturn msg;","outputs":1,"noerr":0,"x":670.11669921875,"y":175.11666870117188,"wires":[["b799969.8984a68"]]},{"id":"b799969.8984a68","type":"http request","z":"4cb9f36b.f002ac","name":"Send to Watson IoT Platform","method":"POST","ret":"txt","url":"","tls":"","x":824.1167297363281,"y":255.31668090820312,"wires":[["c3548e9f.856808"]]},{"id":"78a34299.e0e87c","type":"function","z":"4cb9f36b.f002ac","name":"Form register Payload","func":"var result = [];\nfor(var i = 0; i < msg.payload.instances; i++){\n var deviceId;\n if(i < 9) {\n \n deviceId = \"Elevator0\" + (i+1); \n } else {\n deviceId = \"Elevator\" + (i+1); \n }\n result.push({payload:{deviceId:deviceId}});\n}\nreturn [result];","outputs":1,"noerr":0,"x":422.0667419433594,"y":175.20004272460938,"wires":[["2ddb266.d9793da"]]},{"id":"700345d4.626344","type":"function","z":"4cb9f36b.f002ac","name":"Set organization ID","func":"flow.set(\"orgid\", \"yq8qg5\");\nreturn msg;","outputs":1,"noerr":0,"x":430.0667419433594,"y":117.20002746582031,"wires":[["ada6103.d3ec57"]]},{"id":"ada6103.d3ec57","type":"function","z":"4cb9f36b.f002ac","name":"Register Elevator Type","func":"var orgid = flow.get(\"orgid\");\n\nmsg = {\n url:\"https://\" + orgid + \".internetofthings.ibmcloud.com/api/v0002/device/types\",\n payload: {\"id\":\"Elevator\"},\n headers:{\n \"Accept\":\"application/json\",\n \"Content-type\":\"application/json\"\n }\n};\n\nreturn msg;","outputs":1,"noerr":0,"x":693.7333984375,"y":118.03335571289062,"wires":[["b799969.8984a68"]]},{"id":"c3548e9f.856808","type":"debug","z":"4cb9f36b.f002ac","name":"","active":true,"console":"false","complete":"false","x":822.0666809082031,"y":327.6500244140625,"wires":[]},{"id":"39bbfd3f.33e2ba","type":"inject","z":"4cb9f36b.f002ac","name":"start 10 elevators","topic":"","payload":"{\"instances\" : 10 }","payloadType":"json","repeat":"","crontab":"","once":true,"x":144.11666870117188,"y":111,"wires":[["700345d4.626344","55564bd8.53a054","c545bff1.573328"]]},{"id":"c545bff1.573328","type":"delay","z":"4cb9f36b.f002ac","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":380.4499816894531,"y":233.78334045410156,"wires":[["78a34299.e0e87c"]]},{"id":"b6e56c3f.e8dd1","type":"Device Schema","z":"","deviceType":"Elevator","props":[{"guid":"e76a0e692587","name":"motorTemp","random":{"func":"floating","args":{"min":150,"max":170,"fixed":4}}},{"guid":"c2881d12e8f3","name":"currentFloor","random":{"func":"integer","args":{"min":0,"max":6}}},{"guid":"38416d39cffe","name":"doorOpen","defaultValue":{"type":"bool","value":"false"}},{"guid":"745ce852562a","name":"state","defaultValue":{"type":"str","value":"idle"}},{"guid":"d1ebf05ff8fb","name":"numberOfFloors","defaultValue":{"type":"num","value":"6"}},{"guid":"80cc3cb81053","name":"cabinTemp","random":{"func":"integer","args":{"min":70,"max":95}}},{"guid":"40741d3132a4","name":"cabinSpeed","defaultValue":{"type":"num","value":"0"}},{"guid":"297fd95abda8","name":"direction","defaultValue":{"type":"num","value":"1"}},{"guid":"bcca0e31b9d6","name":"load","defaultValue":{"type":"num","value":"0"}},{"guid":"c15961c2f7bf","name":"gotoFloor","defaultValue":{"type":"num","value":"0"}},{"guid":"1bd9b63f4b60","name":"maintenanceStop","defaultValue":{"type":"bool","value":"false"}},{"guid":"717226438586","name":"forceOpenDoor","defaultValue":{"type":"bool","value":"false"}},{"guid":"bd4d2913cb07","name":"maintenanceReason","defaultValue":{"type":"str","value":""}},{"guid":"efd6898dd4db","name":"maxMotorTemp","defaultValue":{"type":"num","value":"180"}},{"guid":"438e94df7c4a","name":"minMotorTemp","defaultValue":{"type":"num","value":"140"}},{"guid":"2b397533cfa2","name":"curtainOfLightBreak","defaultValue":{"type":"num","value":"0"}},{"guid":"299639e87d50","name":"cleanessOfFloor","defaultValue":{"type":"num","value":"1"}},{"guid":"ba7d2793453d","name":"curtainOfLightBreakCount","defaultValue":{"type":"num","value":"0"}},{"guid":"459e0d4c3af6","name":"curtainOfLightBreakRate","defaultValue":{"type":"num","value":"10"}},{"guid":"7fa0c8927a50","name":"floorStopReq","defaultValue":{"type":"json","value":"[]"}},{"guid":"3e84a9a94615","name":"autoFloorSelection","defaultValue":{"type":"bool","value":"true"}}],"evts":[{"guid":"0612deed98b7","name":"Status","payload":{"properties":{"0":"e76a0e692587","1":"c2881d12e8f3","2":"38416d39cffe","3":"745ce852562a","4":"d1ebf05ff8fb","5":"80cc3cb81053","6":"40741d3132a4","7":"297fd95abda8","8":"bcca0e31b9d6","9":"2b397533cfa2","10":"299639e87d50","length":11,"prevObject":{"0":"e76a0e692587","1":"c2881d12e8f3","2":"38416d39cffe","3":"745ce852562a","4":"d1ebf05ff8fb","5":"80cc3cb81053","6":"40741d3132a4","7":"297fd95abda8","8":"bcca0e31b9d6","9":"2b397533cfa2","10":"299639e87d50","length":11,"prevObject":{"0":{},"1":{},"2":{},"3":{},"4":{},"5":{},"6":{},"7":{},"8":{},"9":{},"10":{},"length":11,"prevObject":{"0":{"sizzle1475756474458":{"parentNode":[1051,29,true]}},"selector":".red-ui-editableList-item-content","context":{},"length":1},"context":{},"selector":".red-ui-editableList-item-content .node-input-evts-payload option:selected"},"context":{}},"context":{}}}},{"guid":"21024c33b8dd","name":"Maintenance_event","payload":{"properties":{"0":"1bd9b63f4b60","1":"bd4d2913cb07","length":2,"prevObject":{"0":"1bd9b63f4b60","1":"bd4d2913cb07","length":2,"prevObject":{"0":{},"1":{},"length":2,"prevObject":{"0":{"sizzle1475756474458":{"parentNode":[1052,29,true]}},"selector":".red-ui-editableList-item-content","context":{},"length":1},"context":{},"selector":".red-ui-editableList-item-content .node-input-evts-payload option:selected"},"context":{}},"context":{}}}}]},{"id":"35fcbc9f.e98294","type":"ibmiot","z":"","name":"yq8qg5","keepalive":"60","cleansession":true,"appId":"1234","shared":true},{"id":"777dfe18.fc423","type":"ui_group","z":"94306133.bd72a","name":"Elevator Properties","tab":"d55e3220.06ae","order":4,"disp":true,"width":"6"},{"id":"8d5bfc2c.7e319","type":"ui_group","z":"94306133.bd72a","name":"Elevator Control","tab":"d55e3220.06ae","order":3,"disp":true,"width":"6"},{"id":"9396bced.f047d","type":"ui_group","z":"94306133.bd72a","name":"Simulation Config","tab":"d55e3220.06ae","order":5,"disp":true,"width":"6"},{"id":"7cca88d7.3bc948","type":"ui_group","z":"94306133.bd72a","name":"Floors panel","tab":"d55e3220.06ae","order":2,"disp":true,"width":"7"},{"id":"60388ef0.c8684","type":"ui_group","z":"94306133.bd72a","name":"Instance","tab":"d55e3220.06ae","order":1,"disp":true,"width":"6"},{"id":"d55e3220.06ae","type":"ui_tab","z":"94306133.bd72a","name":"Elevator","icon":"dashboard","order":1}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment