z-wave context.global.zwavenodes object builder

  • This flows aim to create an keep up to date context.global.zwavenodes object, similar to node-openzwave test.js.
  • It can be used for UI creation.
[{"id":"48fb8db.fb70474","type":"mqtt-broker","broker":"192.168.11.2","port":"1883","clientid":""},{"id":"2202f237.ddfd0e","type":"mqtt in","name":"","topic":"zwave/events/driver ready/#","broker":"48fb8db.fb70474","x":142,"y":133,"z":"f3f99dc8.0c066","wires":[["ed5f5076.12a0b"]]},{"id":"9a25d4d1.65da28","type":"function","name":"driver ready","func":"msg.payload = 'Start sccanning '+ msg.payload.id;\nreturn msg;","outputs":1,"x":555,"y":144.33334350585938,"z":"f3f99dc8.0c066","wires":[[]]},{"id":"f7aff60.f085008","type":"mqtt in","name":"","topic":"zwave/events/driver failed/#","broker":"48fb8db.fb70474","x":136,"y":191.33334350585938,"z":"f3f99dc8.0c066","wires":[["59ad8a05.a65274"]]},{"id":"e58ef5db.1a7108","type":"function","name":"driver failed","func":"msg.payload='failed to start driver';\nreturn msg;","outputs":1,"x":563,"y":197.66668701171875,"z":"f3f99dc8.0c066","wires":[[]]},{"id":"611e96e1.9ee168","type":"mqtt in","name":"","topic":"zwave/events/node added/#","broker":"48fb8db.fb70474","x":139,"y":251.33334350585938,"z":"f3f99dc8.0c066","wires":[["37bc9970.c84366"]]},{"id":"5e5ffcf9.a1a004","type":"function","name":"node added","func":"if(!context.global.zwavenodes) context.global.zwavenodes = [];\ncontext.global.zwavenodes[msg.payload.nodeid] = {\n        \t\tnodeid : msg.payload.nodeid,\n        \t\tmanufacturer: '',\n        \t\tmanufacturerid: '',\n        \t\tproduct: '',\n        \t\tproducttype: '',\n        \t\tproductid: '',\n        \t\ttype: '',\n        \t\tname: '',\n        \t\tloc: '',\n        \t\tclasses: {},\n        \t\tready: false,\n        \t    status: '',\n    \t\t};\n    \t\t\nreturn msg;","outputs":1,"x":581,"y":252.66668701171875,"z":"f3f99dc8.0c066","wires":[[]]},{"id":"3613273d.c9ecd8","type":"mqtt in","name":"","topic":"zwave/events/value changed/#","broker":"48fb8db.fb70474","x":139,"y":388.3333435058594,"z":"f3f99dc8.0c066","wires":[["5b3d3ccb.a4c2c4"]]},{"id":"dc83f6b9.237c08","type":"function","name":"value changed","func":"if (context.global.zwavenodes[msg.payload.nodeid]['ready']) {\ncontext.global.zwavenodes[msg.payload.nodeid]['classes'][msg.payload.cmdclass][msg.payload.cmdidx] = msg.payload.currState; \n}\nreturn msg;","outputs":1,"x":582,"y":383.6667175292969,"z":"f3f99dc8.0c066","wires":[[]]},{"id":"f1b65803.0e49a8","type":"function","name":"node ready","func":"context.global.zwavenodes[msg.payload.nodeid]['manufacturer']= msg.payload.nodeinfo.manufacturer;\ncontext.global.zwavenodes[msg.payload.nodeid]['manufacturerid'] = msg.payload.nodeinfo.manufacturerid;\ncontext.global.zwavenodes[msg.payload.nodeid]['product'] = msg.payload.nodeinfo.product;\ncontext.global.zwavenodes[msg.payload.nodeid]['producttype'] = msg.payload.nodeinfo.producttype;\ncontext.global.zwavenodes[msg.payload.nodeid]['productid'] = msg.payload.nodeinfo.productid;\ncontext.global.zwavenodes[msg.payload.nodeid]['type'] = msg.payload.nodeinfo.type;\ncontext.global.zwavenodes[msg.payload.nodeid]['name'] = msg.payload.nodeinfo.name;\ncontext.global.zwavenodes[msg.payload.nodeid]['loc'] = msg.payload.nodeinfo.loc;\ncontext.global.zwavenodes[msg.payload.nodeid]['ready'] = true;\nreturn msg;\n","outputs":1,"x":599,"y":506.3333740234375,"z":"f3f99dc8.0c066","wires":[[]]},{"id":"4d715468.b28eac","type":"mqtt in","name":"","topic":"zwave/events/node ready/#","broker":"48fb8db.fb70474","x":153,"y":503.3333740234375,"z":"f3f99dc8.0c066","wires":[["8ca775d1.735888"]]},{"id":"f236504e.0dc9b","type":"function","name":"notification","func":"context.global.zwavenodes[msg.payload.nodeid]['status']=msg.payload.notification;\nreturn msg;","outputs":1,"x":608,"y":553,"z":"f3f99dc8.0c066","wires":[[]]},{"id":"d60dff9b.29f2","type":"mqtt in","name":"","topic":"zwave/events/notification/#","broker":"48fb8db.fb70474","x":147,"y":555,"z":"f3f99dc8.0c066","wires":[["b5b70504.4a48f8"]]},{"id":"f97533df.068ad","type":"function","name":"scan complete","func":"msg.payload=\"Scan complete\"\n\nreturn msg;","outputs":1,"x":604,"y":620,"z":"f3f99dc8.0c066","wires":[[]]},{"id":"340346a7.cbfcba","type":"mqtt in","name":"","topic":"zwave/events/scan complete/#","broker":"48fb8db.fb70474","x":162,"y":623,"z":"f3f99dc8.0c066","wires":[["c28e911a.3d717"]]},{"id":"ed5f5076.12a0b","type":"json","name":"","x":373,"y":134,"z":"f3f99dc8.0c066","wires":[["9a25d4d1.65da28"]]},{"id":"59ad8a05.a65274","type":"json","name":"","x":374,"y":194,"z":"f3f99dc8.0c066","wires":[["e58ef5db.1a7108"]]},{"id":"37bc9970.c84366","type":"json","name":"","x":366,"y":254,"z":"f3f99dc8.0c066","wires":[["5e5ffcf9.a1a004"]]},{"id":"5b3d3ccb.a4c2c4","type":"json","name":"","x":356,"y":389,"z":"f3f99dc8.0c066","wires":[["dc83f6b9.237c08"]]},{"id":"8ca775d1.735888","type":"json","name":"","x":375,"y":501,"z":"f3f99dc8.0c066","wires":[["f1b65803.0e49a8"]]},{"id":"b5b70504.4a48f8","type":"json","name":"","x":370,"y":558,"z":"f3f99dc8.0c066","wires":[["f236504e.0dc9b"]]},{"id":"c28e911a.3d717","type":"json","name":"","x":379,"y":627,"z":"f3f99dc8.0c066","wires":[["f97533df.068ad"]]},{"id":"77b7fb88.884804","type":"mqtt in","name":"","topic":"zwave/events/value added/#","broker":"48fb8db.fb70474","x":142,"y":313,"z":"f3f99dc8.0c066","wires":[["326a6191.cd959e"]]},{"id":"32a9c07e.cd564","type":"function","name":"value added","func":"if (!context.global.zwavenodes[msg.payload.nodeid]['classes'][msg.payload.cmdclass])\n     context.global.zwavenodes[msg.payload.nodeid]['classes'][msg.payload.cmdclass] = {};\ncontext.global.zwavenodes[msg.payload.nodeid]['classes'][msg.payload.cmdclass][msg.payload.cmdidx] = msg.payload.currState;\n\nreturn msg;","outputs":1,"x":583,"y":310.3333740234375,"z":"f3f99dc8.0c066","wires":[[]]},{"id":"326a6191.cd959e","type":"json","name":"","x":370,"y":318.6666564941406,"z":"f3f99dc8.0c066","wires":[["32a9c07e.cd564"]]},{"id":"8e4a010f.71b6","type":"mqtt in","name":"","topic":"zwave/events/value removed/#","broker":"48fb8db.fb70474","x":150,"y":448,"z":"f3f99dc8.0c066","wires":[["96c4aab2.693b58"]]},{"id":"7e181631.81e7e8","type":"function","name":"value removed","func":"if (context.global.zwavenodes[msg.payload.nodeid]['classes'][msg.payload.cmdclass] &&\n    context.global.zwavenodes[msg.payload.nodeid]['classes'][msg.payload.cmdclass][msg.payload.cmdidx])\n        delete context.global.zwavenodes[msg.payload.nodeid]['classes'][msg.payload.cmdclass][msg.payload.cmdidx];\n\nreturn msg;","outputs":1,"x":577,"y":451.3333740234375,"z":"f3f99dc8.0c066","wires":[[]]},{"id":"96c4aab2.693b58","type":"json","name":"","x":365,"y":448.6666564941406,"z":"f3f99dc8.0c066","wires":[["7e181631.81e7e8"]]},{"id":"48db945f.b7246c","type":"inject","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":114,"y":687,"z":"f3f99dc8.0c066","wires":[["7e3b59e0.81c4a8"]]},{"id":"7e3b59e0.81c4a8","type":"function","name":"delete context.global.zwavenodes","func":"delete context.global.zwavenodes;\nreturn msg;","outputs":1,"x":369,"y":689,"z":"f3f99dc8.0c066","wires":[[]]}]
pastukhov

Flow Info

created 3 years, 3 months ago

Node Types

Core
  • function (x10)
  • inject (x1)
  • json (x9)
  • mqtt in (x9)
  • mqtt-broker (x1)

Tags

Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option