Image

Node-Red - Distech Controls - Eclypse

Flows node-red pour la communication avec un automate Distech-Controls, récupération valeurs, écriture, etc..
Image
[{"id":"54265eb3.fabf7","type":"function","z":"6adba18f.4fb12","name":"Write Fonction","func":"var credentials = \"admin:Distech123\"\nvar base64 = new Buffer(credentials).toString('base64')\n\nmsg.method = \"POST\";\nmsg.url = \"http://192.168.1.113:80/api/rest/v1/protocols/bacnet/local/objects/write-property-multiple\";\nmsg.headers = {};\nmsg.headers['authorization'] = 'basic '+base64;\nmsg.headers['Content-Type'] = \"application/JSON\";\n\nvar body = \n{\n  \"encode\":\"text\",\n  \"propertyReferences\":[\n    { \n      \"type\":\"analogValue\",\n      \"instance\":27,\n      \"property\":\"presentValue\",\n      \"value\":\"1234.25\",\n      \"priority\":8\n    }\n  ]\n};\nmsg.payload = body;\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":340,"wires":[["3ceb52d8.b174be"]]},{"id":"e12a4f7b.ddd88","type":"inject","z":"6adba18f.4fb12","name":"Example POST","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"","x":120,"y":340,"wires":[["54265eb3.fabf7"]]},{"id":"ea19ecbe.4135a","type":"function","z":"6adba18f.4fb12","name":"Read Fonction","func":"// instance to request\n// var instances = [200,201,202,203, 220, 221]; pour la synthése\nvar instances = [1];\n// btoa credentials for basic authentification\nvar credentials = \"admin:Distech123\";\nvar base64 = new Buffer(credentials).toString('base64');\n\nmsg.url = \"http://192.168.1.113:80/api/rest/v1/protocols/bacnet/local/objects/read-property-multiple\";\n\n// create requests headers\nmsg.headers = {};\nmsg.headers['authorization'] = 'basic '+base64;\nmsg.headers['Content-Type'] = \"application/JSON\";\n\nvar propertyReferences = [];\n// generate dynamic properties to request api\ninstances.forEach(function(instance){\n    propertyReferences.push( {\n        \"type\": \"analogValue\",\n        \"instance\": instance,\n        \"property\":\"description\"\n    });\n    propertyReferences.push( {\n        \"type\": \"analogValue\",\n        \"instance\": instance,\n        \"property\":\"presentValue\"\n    })    \n    propertyReferences.push( {\n        \"type\": \"analogValue\",\n        \"instance\": instance,\n        \"property\":\"units\"\n    })    \n})\n\n// create request body\nvar body = \n{\n  \"encode\": \"text\",\n  \"propertyReferences\": propertyReferences\n};   \n\n    \nmsg.payload = body;\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":100,"wires":[["7b1ee4e0.df661c"]]},{"id":"7b1ee4e0.df661c","type":"http request","z":"6adba18f.4fb12","name":"HTTP POST","method":"POST","ret":"txt","paytoqs":false,"url":"","tls":"5529457.7d8bebc","persist":false,"proxy":"","authType":"","x":503,"y":100,"wires":[["80e0c928.5aec58"]]},{"id":"cf5c0755.ba9a58","type":"inject","z":"6adba18f.4fb12","name":"READ VALUE","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"","x":129,"y":100,"wires":[["ea19ecbe.4135a","7b88a07d.86b7"]]},{"id":"dc512156.3258f","type":"debug","z":"6adba18f.4fb12","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1290,"y":100,"wires":[]},{"id":"80e0c928.5aec58","type":"json","z":"6adba18f.4fb12","name":"","x":659,"y":100,"wires":[["7b3511bf.73137"]]},{"id":"24a2aef1.022f42","type":"function","z":"6adba18f.4fb12","name":"Example format Tweet","func":"msg.payload = ''+msg.description.value + ' : '+ msg.presentValue.value  + msg.units.value ;\n//msg.payload = 'test  '+msg.description.value + ' : '+ msg.presentValue.value;\nreturn msg;","outputs":1,"noerr":0,"x":1080,"y":100,"wires":[["dc512156.3258f"]]},{"id":"7b3511bf.73137","type":"function","z":"6adba18f.4fb12","name":"Payload Splitter kim","func":"var newMsg = {};\nmsg.payload.forEach(function(value) {\n    if(value.property === 'presentValue') {\n        newMsg.presentValue = value;    \n    }\n    if(value.property === 'description') {\n        newMsg.description = value;    \n    }\n     if(value.property === 'units') {\n        newMsg.units = value;   \n    }\n     \n    if(!!newMsg.description && !!newMsg.presentValue && !!newMsg.units ) {\n        node.send(newMsg);\n        \n    }\n})\n","outputs":1,"noerr":0,"x":840,"y":100,"wires":[["24a2aef1.022f42"]]},{"id":"2c2958e8.516798","type":"debug","z":"6adba18f.4fb12","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":730,"y":340,"wires":[]},{"id":"3ceb52d8.b174be","type":"http request","z":"6adba18f.4fb12","name":"HTTP POST","method":"use","ret":"txt","url":"","tls":"","x":530,"y":340,"wires":[["2c2958e8.516798"]]},{"id":"4894d826.b98a18","type":"comment","z":"6adba18f.4fb12","name":"Lecture Analogue Value","info":"","x":340,"y":40,"wires":[]},{"id":"70b42bc8.041dc4","type":"comment","z":"6adba18f.4fb12","name":"Lecture Analogue Input","info":"","x":340,"y":160,"wires":[]},{"id":"7b88a07d.86b7","type":"function","z":"6adba18f.4fb12","name":"Read Fonction","func":"// instance to request\n// var instances = [200,201,202,203, 220, 221]; pour la synthése\nvar instances = [101];\n// btoa credentials for basic authentification\nvar credentials = \"admin:Distech123\";\nvar base64 = new Buffer(credentials).toString('base64');\n\nmsg.url = \"http://192.168.1.113:80/api/rest/v1/protocols/bacnet/local/objects/read-property-multiple\";\n\n// create requests headers\nmsg.headers = {};\nmsg.headers['authorization'] = 'basic '+base64;\nmsg.headers['Content-Type'] = \"application/JSON\";\n\nvar propertyReferences = [];\n// generate dynamic properties to request api\ninstances.forEach(function(instance){\n    propertyReferences.push( {\n        \"type\": \"analogInput\",\n        \"instance\": instance,\n        \"property\":\"description\"\n    });\n    propertyReferences.push( {\n        \"type\": \"analogInput\",\n        \"instance\": instance,\n        \"property\":\"presentValue\"\n    })    \n    propertyReferences.push( {\n        \"type\": \"analogInput\",\n        \"instance\": instance,\n        \"property\":\"units\"\n    })    \n})\n\n// create request body\nvar body = \n{\n  \"encode\": \"text\",\n  \"propertyReferences\": propertyReferences\n};   \n\n    \nmsg.payload = body;\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":220,"wires":[["62a03659.c76f48"]]},{"id":"62a03659.c76f48","type":"http request","z":"6adba18f.4fb12","name":"HTTP POST","method":"POST","ret":"txt","paytoqs":false,"url":"","tls":"8d3becf.aca5e1","persist":false,"proxy":"","authType":"","x":503,"y":220,"wires":[["9e507d88.f8c0a"]]},{"id":"38bbee43.ee2de2","type":"debug","z":"6adba18f.4fb12","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1290,"y":220,"wires":[]},{"id":"9e507d88.f8c0a","type":"json","z":"6adba18f.4fb12","name":"","x":659,"y":220,"wires":[["c907ccc0.98da2"]]},{"id":"37671523.e2445a","type":"function","z":"6adba18f.4fb12","name":"Example format Tweet","func":"msg.payload = ''+msg.description.value + ' : '+ msg.presentValue.value  + msg.units.value ;\n//msg.payload = 'test  '+msg.description.value + ' : '+ msg.presentValue.value;\nreturn msg;","outputs":1,"noerr":0,"x":1080,"y":220,"wires":[["38bbee43.ee2de2"]]},{"id":"c907ccc0.98da2","type":"function","z":"6adba18f.4fb12","name":"Payload Splitter kim","func":"var newMsg = {};\nmsg.payload.forEach(function(value) {\n    if(value.property === 'presentValue') {\n        newMsg.presentValue = value;    \n    }\n    if(value.property === 'description') {\n        newMsg.description = value;    \n    }\n     if(value.property === 'units') {\n        newMsg.units = value;   \n    }\n     \n    if(!!newMsg.description && !!newMsg.presentValue && !!newMsg.units ) {\n        node.send(newMsg);\n        \n    }\n})\n","outputs":1,"noerr":0,"x":840,"y":220,"wires":[["37671523.e2445a"]]},{"id":"509a4f82.056e3","type":"comment","z":"6adba18f.4fb12","name":"Ecriture Analogue Value","info":"","x":340,"y":280,"wires":[]},{"id":"5529457.7d8bebc","type":"tls-config","z":"","name":"","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"caCertificate (1).crt","servername":"","verifyservercert":true},{"id":"8d3becf.aca5e1","type":"tls-config","z":"","name":"","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"caCertificate (2).crt","servername":"","verifyservercert":true}]

Recherche