Sample with ModbusFlexConnector
[{"id":"ca6d31db8909b2f6","type":"inject","z":"13b11b04.342725","name":"","repeat":"3600","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":130,"y":1220,"wires":[["ec442f7307e32a81","acac9bff0a533975"]]},{"id":"ec442f7307e32a81","type":"function","z":"13b11b04.342725","name":"","func":"var table1 = msg.c1;\nvar query = \"SELECT delta, nazwa, host, modbus_id from temp_tid where delta>0\";\nmsg.topic = query;\nreturn msg;","outputs":1,"noerr":0,"x":300,"y":1220,"wires":[["36ac1d98a418f21c"]]},{"id":"36ac1d98a418f21c","type":"mysql","z":"13b11b04.342725","mydb":"36c886e2.421612","name":"db","x":430,"y":1220,"wires":[["ebe864bd81c84cc5"]]},{"id":"ebe864bd81c84cc5","type":"debug","z":"13b11b04.342725","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":600,"y":1220,"wires":[]},{"id":"931f37b035f53f14","type":"modbus-flex-connector","z":"13b11b04.342725","name":"","maxReconnectsPerMinute":4,"emptyQueue":false,"showStatusActivities":true,"showErrors":false,"server":"5cac7a09.32364c","x":630,"y":1320,"wires":[["bb18a1e21ba1d629"]]},{"id":"c4ae37ebd438db19","type":"modbus-flex-sequencer","z":"13b11b04.342725","name":"sequencer 1","sequences":[{"name":"1","unitid":"1","fc":"FC4","address":"10009","quantity":"1"}],"server":"5cac7a09.32364c","showStatusActivities":true,"showErrors":true,"logIOActivities":false,"useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"x":1010,"y":1320,"wires":[["bc2bc1764d1916c2","e12b723b657d0bcb"],[]]},{"id":"bc2bc1764d1916c2","type":"debug","z":"13b11b04.342725","name":"output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1170,"y":1320,"wires":[]},{"id":"bb18a1e21ba1d629","type":"delay","z":"13b11b04.342725","name":"","pauseType":"delay","timeout":"9","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"outputs":1,"x":840,"y":1320,"wires":[["c4ae37ebd438db19"]]},{"id":"52b1389934190985","type":"function","z":"13b11b04.342725","name":"f1","func":"var devices1 =[{\"delta\":1,\"nazwa\":\"ED_9373\",\"host\":\"10.0.0.202\",\"modbus_id\":8},{\"delta\":2,\"nazwa\":\"ED_9376\",\"host\":\"10.0.0.132\",\"modbus_id\":2},{\"delta\":3,\"nazwa\":\"ED_9377\",\"host\":\"10.0.0.201\",\"modbus_id\":4},{\"delta\":4,\"nazwa\":\"ED_9375\",\"host\":\"10.0.0.203\",\"modbus_id\":9},{\"delta\":5,\"nazwa\":\"ED_9379\",\"host\":\"10.0.0.204\",\"modbus_id\":5},{\"delta\":6,\"nazwa\":\"ED_9374\",\"host\":\"10.0.0.203\",\"modbus_id\":3},{\"delta\":8,\"nazwa\":\"ED_9380\",\"host\":\"10.0.0.202\",\"modbus_id\":7},{\"delta\":9,\"nazwa\":\"ED_9381\",\"host\":\"10.0.0.203\",\"modbus_id\":6},{\"delta\":7,\"nazwa\":\"ED_9378\",\"host\":\"10.0.0.131\",\"modbus_id\":10}];\nvar devices = msg.payload;\n\n\ndevices.forEach(dev => {\n\n node.send({\n \"topic\": dev.nazwa,\n \"payload\": {\n \"connectorType\" : \"TCP\",\n \"tcpHost\": dev.host,\n \"tcpPort\": \"502\",\n \"unitId\": dev.modbus_id\n },\n \"sequences\": [\n {\n name: dev.host,\n unitid: dev.modbus_id,\n fc: 4,\n address: 10009,\n quantity: 1\n }\n ]\n });\n\n})\n\n\n\nreturn null;","outputs":1,"noerr":0,"x":230,"y":1320,"wires":[["589fdf93fe8d790d","297df7472b57f343"]]},{"id":"589fdf93fe8d790d","type":"debug","z":"13b11b04.342725","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":410,"y":1360,"wires":[]},{"id":"297df7472b57f343","type":"delay","z":"13b11b04.342725","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"10","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"outputs":1,"x":400,"y":1320,"wires":[["931f37b035f53f14"]]},{"id":"e12b723b657d0bcb","type":"function","z":"13b11b04.342725","name":"","func":"var table = 'alarmy';\nvar bat = msg.payload[0];\nvar modbus_id = msg.unitId;\nvar query = '';\n\n\nquery= `UPDATE temp_tid set bat = ${bat} WHERE modbus_id= ${modbus_id};`;\n\n\nmsg.query = query;\nmsg.topic = query;\n\n\nreturn msg;\n\n\n\n\n","outputs":1,"noerr":0,"x":1020,"y":1400,"wires":[["9cba012d79a7d3e1"]]},{"id":"9cba012d79a7d3e1","type":"mysql","z":"13b11b04.342725","mydb":"36c886e2.421612","name":"db","x":1150,"y":1400,"wires":[[]]},{"id":"59dd46656ff38922","type":"comment","z":"13b11b04.342725","name":"json","info":"[{\"delta\":1,\"nazwa\":\"ED_9373\",\"host\":\"192.168.98.201\",\"modbus_id\":8},{\"delta\":2,\"nazwa\":\"ED_9376\",\"host\":\"192.168.98.203\",\"modbus_id\":2},{\"delta\":3,\"nazwa\":\"ED_9377\",\"host\":\"192.168.98.202\",\"modbus_id\":4},{\"delta\":4,\"nazwa\":\"ED_9375\",\"host\":\"192.168.98.203\",\"modbus_id\":9},{\"delta\":5,\"nazwa\":\"ED_9379\",\"host\":\"192.168.98.204\",\"modbus_id\":5},{\"delta\":6,\"nazwa\":\"ED_9374\",\"host\":\"192.168.98.203\",\"modbus_id\":4},{\"delta\":8,\"nazwa\":\"ED_9380\",\"host\":\"192.168.98.202\",\"modbus_id\":7},{\"delta\":9,\"nazwa\":\"ED_9381\",\"host\":\"192.168.1.132\",\"modbus_id\":6},{\"delta\":7,\"nazwa\":\"ED_9378\",\"host\":\"10.0.0.1\",\"modbus_id\":10}]","x":770,"y":1220,"wires":[]},{"id":"acac9bff0a533975","type":"function","z":"13b11b04.342725","name":"","func":"msg.payload = [{\"delta\":1,\"nazwa\":\"ED_9373\",\"host\":\"192.168.98.201\",\"modbus_id\":8},{\"delta\":2,\"nazwa\":\"ED_9376\",\"host\":\"192.168.98.203\",\"modbus_id\":2},{\"delta\":3,\"nazwa\":\"ED_9377\",\"host\":\"192.168.98.202\",\"modbus_id\":4},{\"delta\":4,\"nazwa\":\"ED_9375\",\"host\":\"192.168.98.203\",\"modbus_id\":9},{\"delta\":5,\"nazwa\":\"ED_9379\",\"host\":\"192.168.98.204\",\"modbus_id\":5},{\"delta\":6,\"nazwa\":\"ED_9374\",\"host\":\"192.168.98.203\",\"modbus_id\":4},{\"delta\":8,\"nazwa\":\"ED_9380\",\"host\":\"192.168.98.202\",\"modbus_id\":7},{\"delta\":9,\"nazwa\":\"ED_9381\",\"host\":\"192.168.1.132\",\"modbus_id\":6},{\"delta\":7,\"nazwa\":\"ED_9378\",\"host\":\"10.0.0.1\",\"modbus_id\":10}];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":100,"y":1320,"wires":[["52b1389934190985"]]},{"id":"36c886e2.421612","type":"MySQLdatabase","name":"","host":"localhost","port":"3306","db":"chema","tz":"","charset":"UTF8"},{"id":"5cac7a09.32364c","type":"modbus-client","name":"","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"192.168.98.203","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"0","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":false,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]