UNPKG

node-red-contrib-broadlink

Version:
225 lines 5.69 kB
[ { "id": "ca4f089e.409058", "type": "subflow", "name": "RM Add", "info": "Добавлет Кнопку в базу\n```\nmsg.deviceName=\"Вентилятор\";\nmsg.buttonName=\"Включить\";\nmsg.code=[];\n```\nЕсли `deviceName` не будет найдено - добавится новое", "in": [ { "x": 360, "y": 260, "wires": [ { "id": "6c5136a.9f25cc8" } ] } ], "out": [ { "x": 1100, "y": 420, "wires": [ { "id": "d4b25ba8.6c09a8", "port": 0 } ] } ] }, { "id": "6c5136a.9f25cc8", "type": "file in", "z": "ca4f089e.409058", "name": "", "filename": "/home/pi/Broadlink/jsonSubIr", "format": "utf8", "x": 540, "y": 260, "wires": [ [ "ed9d59bf.59ba38" ] ] }, { "id": "ed9d59bf.59ba38", "type": "json", "z": "ca4f089e.409058", "name": "", "x": 750, "y": 260, "wires": [ [ "ee1052f.25a7ab" ] ] }, { "id": "ee1052f.25a7ab", "type": "function", "z": "ca4f089e.409058", "name": "", "func": "msg.devices=msg.payload;\nvar devArr=msg.payload.filter(function(obj){if(obj.name==msg.deviceName) return true;});\n\nif(devArr.length>0){ \n msg.deviceId=devArr[0].id;\n return [msg,null];\n}\nelse{\n msg.deviceId=Math.max.apply(Math,msg.devices.map(function(o){return o.id;}))+1;\n msg.devices.push({id:msg.deviceId,name: msg.deviceName});\n msg.payload=msg.devices;\n return [null,msg];\n}", "outputs": "2", "noerr": 0, "x": 890, "y": 260, "wires": [ [ "ca2fc50c.ef5848" ], [ "ca2fc50c.ef5848", "8828b67b.f5b718" ] ] }, { "id": "8828b67b.f5b718", "type": "file", "z": "ca4f089e.409058", "name": "", "filename": "", "appendNewline": true, "createDir": false, "overwriteFile": "true", "x": 1070, "y": 220, "wires": [] }, { "id": "fababd94.6c74c", "type": "file in", "z": "ca4f089e.409058", "name": "", "filename": "/home/pi/Broadlink/jsonButton", "format": "utf8", "x": 550, "y": 320, "wires": [ [ "db8f992b.ba40c8" ] ] }, { "id": "db8f992b.ba40c8", "type": "json", "z": "ca4f089e.409058", "name": "", "x": 770, "y": 320, "wires": [ [ "6da18894.2ac5a8" ] ] }, { "id": "6da18894.2ac5a8", "type": "function", "z": "ca4f089e.409058", "name": "", "func": "msg.buttons=msg.payload;\nmsg.buttonsId=Math.max.apply(Math,msg.devices.map(function(o){return o.id;}))+1;\nmsg.buttons.push({id:msg.buttonsId,name: msg.buttonName,subIRId:msg.deviceId});\nmsg.payload=msg.buttons;\nreturn msg;", "outputs": "1", "noerr": 0, "x": 910, "y": 320, "wires": [ [ "48e6b9aa.ab9cc8", "9cb04d9d.eee0b" ] ] }, { "id": "ca2fc50c.ef5848", "type": "function", "z": "ca4f089e.409058", "name": "", "func": "\nreturn msg;", "outputs": 1, "noerr": 0, "x": 1070, "y": 260, "wires": [ [ "fababd94.6c74c" ] ] }, { "id": "9cb04d9d.eee0b", "type": "file", "z": "ca4f089e.409058", "name": "", "filename": "", "appendNewline": true, "createDir": false, "overwriteFile": "true", "x": 1070, "y": 320, "wires": [] }, { "id": "48e6b9aa.ab9cc8", "type": "file in", "z": "ca4f089e.409058", "name": "", "filename": "/home/pi/Broadlink/jsonIrCode", "format": "utf8", "x": 550, "y": 380, "wires": [ [ "56f7b79d.db1658" ] ] }, { "id": "56f7b79d.db1658", "type": "json", "z": "ca4f089e.409058", "name": "", "x": 770, "y": 380, "wires": [ [ "d4b25ba8.6c09a8" ] ] }, { "id": "d4b25ba8.6c09a8", "type": "function", "z": "ca4f089e.409058", "name": "", "func": "msg.codes=msg.payload;\nmsg.codeId=Math.max.apply(Math,msg.devices.map(function(o){return o.id;}))+1;\nmsg.codes.push({id:msg.codeId,code: msg.code,buttonId:msg.buttonId});\nmsg.payload=msg.codes;\nreturn msg;", "outputs": "1", "noerr": 0, "x": 910, "y": 380, "wires": [ [ "e981748f.ce9f88" ] ] }, { "id": "e981748f.ce9f88", "type": "file", "z": "ca4f089e.409058", "name": "", "filename": "", "appendNewline": true, "createDir": false, "overwriteFile": "true", "x": 1070, "y": 380, "wires": [] }, { "id": "8c63a574.631278", "type": "subflow:ca4f089e.409058", "z": "37e3d071.a4e02", "name": "", "x": 1020, "y": 1100, "wires": [ [ "b88c2405.f4b498" ] ] }, { "id": "f62ba8e6.083fc8", "type": "inject", "z": "37e3d071.a4e02", "name": "", "topic": "", "payload": "", "payloadType": "str", "repeat": "", "crontab": "", "once": false, "x": 770, "y": 1100, "wires": [ [ "fd61965a.117bc8" ] ] }, { "id": "fd61965a.117bc8", "type": "function", "z": "37e3d071.a4e02", "name": "", "func": "msg.deviceName=\"Вентилятор_\";\nmsg.buttonName=\"Включить_\";\nmsg.code=[];\nreturn msg;", "outputs": 1, "noerr": 0, "x": 890, "y": 1100, "wires": [ [ "8c63a574.631278" ] ] }, { "id": "b88c2405.f4b498", "type": "debug", "z": "37e3d071.a4e02", "name": "", "active": true, "console": "false", "complete": "true", "x": 1150, "y": 1100, "wires": [] } ]