[{"id":"dddf98bf.81661","type":"ui_switch","z":"b93533dc.c999a8","name":"","label":"Relay1","group":"9f116cb6.dcb8f","order":6,"width":"1","height":"1","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"Relay1=ON","onvalueType":"str","onicon":"","oncolor":"","offvalue":"Relay1=OFF","offvalueType":"str","officon":"","offcolor":"","x":305,"y":461.0000305175781,"wires":[["b357415.0dc474"]]},{"id":"b357415.0dc474","type":"function","z":"b93533dc.c999a8","name":"","func":"var idx = msg.payload.indexOf(\"=\")\nvar thisRelay = \"\";\nif(idx != -1){\n thisRelay = msg.payload.substring(5,idx);\n}\n \nif(flow.get(\"updatingNow\" + thisRelay) === true) {\n flow.set(\"updatingNow\" + thisRelay, false);\n return;\n} \n\nreturn msg;\n","outputs":1,"noerr":0,"x":453,"y":484.0000305175781,"wires":[["b078cfb9.bb9848"]]},{"id":"d04eef22.66b25","type":"ui_switch","z":"b93533dc.c999a8","name":"","label":"Relay2 ","group":"9f116cb6.dcb8f","order":7,"width":"1","height":"1","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"Relay2=ON","onvalueType":"str","onicon":"","oncolor":"","offvalue":"Relay2=OFF","offvalueType":"str","officon":"","offcolor":"","x":304,"y":510.0000305175781,"wires":[["b357415.0dc474"]]},{"id":"ba95868f.fc45d8","type":"ui_button","z":"b93533dc.c999a8","name":"","group":"9f116cb6.dcb8f","order":5,"width":0,"height":0,"passthru":false,"label":"Refresh","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"","x":122,"y":254,"wires":[["1a8985e0.2e3e52"]]},{"id":"6f0b502.5f5fa3","type":"ui_text","z":"b93533dc.c999a8","group":"9f116cb6.dcb8f","order":1,"width":0,"height":0,"name":"","label":"STATUS","format":"{{msg.payload}}","layout":"row-spread","x":896,"y":101,"wires":[]},{"id":"b38c4121.34dd98","type":"function","z":"b93533dc.c999a8","name":"checkResponse","func":"if(msg.payload.length== 16) {\n msg.payload = \"Success\";\n}\nelse {\n msg.payload = \"Error\";\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":667,"y":204,"wires":[["6f0b502.5f5fa3"]]},{"id":"cab26738.7a1998","type":"function","z":"b93533dc.c999a8","name":"getRelaysState","func":"var r1 = {payload: msg.payload[0] === true ? \"Relay1=ON\" : \"Relay1=OFF\"}\nvar r2 = {payload: msg.payload[1] === true ? \"Relay2=ON\" : \"Relay2=OFF\"}\n\nreturn [r1,r2];\n","outputs":2,"noerr":0,"x":139,"y":490,"wires":[["dddf98bf.81661"],["d04eef22.66b25"]]},{"id":"36f9ae5.fd6a1d2","type":"debug","z":"b93533dc.c999a8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":812,"y":382.0000305175781,"wires":[]},{"id":"b078cfb9.bb9848","type":"function","z":"b93533dc.c999a8","name":"","func":"if(msg.payload.indexOf(\"Relay1\") != -1)\n{\n if(msg.payload.indexOf(\"ON\") != -1){\n msg.payload = { value: true, 'fc': 5, 'unitid': 1, 'address': 0 , 'quantity': 1 } \n } else {\n msg.payload = { value: false, 'fc': 5, 'unitid': 1, 'address': 0 , 'quantity': 1 } \n }\n} else if(msg.payload.indexOf(\"Relay2\") != -1)\n{\n if(msg.payload.indexOf(\"ON\") != -1){\n msg.payload = { value: true, 'fc': 5, 'unitid': 1, 'address': 1 , 'quantity': 1 } \n } else {\n msg.payload = { value: false, 'fc': 5, 'unitid': 1, 'address': 1 , 'quantity': 1 } \n }\n}\nreturn msg;","outputs":1,"noerr":0,"x":615,"y":483.0000305175781,"wires":[["36f9ae5.fd6a1d2","a962c04.a34bd4"]]},{"id":"7dd91530.6e5154","type":"modbus-flex-getter","z":"b93533dc.c999a8","name":"","showStatusActivities":false,"showErrors":false,"server":"d3006745.0f94d","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":442,"y":256,"wires":[["b38c4121.34dd98","cab26738.7a1998"],[]]},{"id":"1a8985e0.2e3e52","type":"function","z":"b93533dc.c999a8","name":"","func":"for(var i=1;i<3;i++)\n flow.set(\"updatingNow\" + i, true);\n \nmsg.payload = { value: msg.payload, 'fc': 1, 'unitid': 1, 'address': 0 , 'quantity': 16 } \nreturn msg;","outputs":1,"noerr":0,"x":258,"y":254,"wires":[["7dd91530.6e5154"]]},{"id":"a962c04.a34bd4","type":"modbus-flex-write","z":"b93533dc.c999a8","name":"","showStatusActivities":false,"showErrors":false,"server":"d3006745.0f94d","x":857,"y":503,"wires":[["fc3a0ab3.e10c6"],[]]},{"id":"fc3a0ab3.e10c6","type":"debug","z":"b93533dc.c999a8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1079,"y":428,"wires":[]},{"id":"9f116cb6.dcb8f","type":"ui_group","z":"","name":"I/O","tab":"8e135d91.225a58","disp":true,"width":"6","collapse":true},{"id":"d3006745.0f94d","type":"modbus-client","z":"","name":"TCP_Modbus","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"tcpHost":"192.168.1.133","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"100","clientTimeout":"1000","reconnectTimeout":"2000"},{"id":"8e135d91.225a58","type":"ui_tab","z":"","name":"Denkovi Dashboard","icon":"dashboard"}]