How do I write 0xFF00 to a modbus coil?

Hi,

I have a HF6508 modbus IO device and reading it works fine and writing to a coil using node.js also works like a charm. I am having difficulty translating this from my node.js program that uses the modbus-serial module:

client.writeCoils(0x0010, [0xFF00])

to Node-RED. I have tried using a buffer in a function node, like so:

var buf=Buffer.alloc(2);
buf.writeUInt16BE(65280);
msg.payload = buf;
return msg;

and several other buffer methods, but I end up with 0xFF,0x00 instead of 0xFF00. My test flow looks like this:

[{"id":"290d0ae.61b23f6","type":"inject","z":"a1af1547.bf2128","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":500,"wires":[["67cc427b.67f66c"]]},{"id":"62f62918.be02e8","type":"modbus-write","z":"a1af1547.bf2128","name":"","showStatusActivities":false,"showErrors":false,"unitid":"1","dataType":"Coil","adr":"0010","quantity":"1","server":"ffd3a923.ab29f8","x":440,"y":500,"wires":[["ecf06b74.18a238"],["ecf06b74.18a238"]]},{"id":"ecf06b74.18a238","type":"debug","z":"a1af1547.bf2128","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":630,"y":500,"wires":[]},{"id":"67cc427b.67f66c","type":"function","z":"a1af1547.bf2128","name":"","func":"var buf=Buffer.alloc(2);\nbuf.writeUInt16BE(65280);\nmsg.payload = buf;\nreturn msg;","outputs":1,"noerr":0,"x":290,"y":500,"wires":[["62f62918.be02e8"]]},{"id":"ffd3a923.ab29f8","type":"modbus-client","z":"","name":"hf6508","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"tcpHost":"172.16.66.107","tcpPort":"8899","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":1,"commandDelay":1,"clientTimeout":1000,"reconnectOnTimeout":false,"reconnectTimeout":2000,"parallelUnitIdsAllowed":true}]

The HF6508 manual tells me this:

Read or write relay status .Write data(2bytes):
on: 0xff00 off: 0x0000

Could someone please point me in the right direction?

hi
first make sure that the port you are using is correct (8899), Modbus normally works on port 502.
To write ON you have to send Hex 0xFF00 command (255 dec), try to launch it directly via inject, then if it works, focus on the function code, I am attaching the basic flow from which to take inspiration (change IP address and port).

it may be that you have to add +1 to the address you want to write on, read your manual of the instrument protocol or simply test (e.g. 10 becomes 11).

[{"id":"bc826ca3.bfca5","type":"debug","z":"719e0878.8bb988","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","x":550,"y":340,"wires":[]},{"id":"5fdc2801.c67188","type":"modbus-response","z":"719e0878.8bb988","name":"","registerShowMax":20,"x":570,"y":400,"wires":[]},{"id":"7bbe114b.75e7a","type":"inject","z":"719e0878.8bb988","name":"on dec","topic":"","payload":"255","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":360,"wires":[["71be201a.1fc8e"]]},{"id":"49c353a7.22270c","type":"inject","z":"719e0878.8bb988","name":"off","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":440,"wires":[["71be201a.1fc8e"]]},{"id":"71be201a.1fc8e","type":"modbus-write","z":"719e0878.8bb988","name":"","showStatusActivities":false,"showErrors":false,"unitid":"1","dataType":"Coil","adr":"10","quantity":"1","server":"98defed2.95a52","x":360,"y":380,"wires":[["5fdc2801.c67188","bc826ca3.bfca5"],[]]},{"id":"660d716b.c926d","type":"inject","z":"719e0878.8bb988","name":"on  hex","topic":"","payload":"[\"0xff00\"]","payloadType":"bin","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":320,"wires":[["71be201a.1fc8e"]]},{"id":"98defed2.95a52","type":"modbus-client","z":"","name":"","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":1,"commandDelay":1,"clientTimeout":1000,"reconnectOnTimeout":true,"reconnectTimeout":2000,"parallelUnitIdsAllowed":true}]

Hi

I solved it. The problem was that I had put 0010 as the address in the modbus write node instead of 0x0010. Pfff... Thanks for your answer, it did put me on the right track by you mentioning the HEX vs decimal again :slight_smile:

Hi @nrbrt,

I've also purchased a few of these HF6508 units via Aliexpress, would you be able to share a working flow of controlling the relay?

Also have you managed to read from the DI pins or read the status of the relays?

Thanks!

Hi natm,

I have got everything working with these modules. Digital input, digital output and analog input. Also reading the status of the DO works fine. I am very happy with these hf6508’s.
Of course I can share a working flow. It might be a bit much, but it should cover everything this module is capable of. I have used several modules that you might not have installed, such as node-red-contrib-ui-led, but I am sure you can figure it out. What you end up with is something like this:

I tried to upload the flow, in one go, but the forum software doesn't allow such large messages. I will split it up in a couple of parts. First the Digital Output (relays). I have created a special number 0 relay that means all of them. That way you can switch everything on or off with one command. What is also good to know, is that I store the state of everything in global variables and my flow uses an mqtt server. Also, these hf6508 modules only support a limited amount of connections per socket and you will have to define 3 in total, so 2 more other than the standard "netp" socket.

[{"id":"c4eb14f2.8fc3e8","type":"modbus-flex-write","z":"497de2b1.933d2c","name":"","showStatusActivities":false,"showErrors":false,"server":"ffd3a923.ab29f8","emptyMsgOnFail":false,"x":1190,"y":240,"wires":[[],["dbf46f46.f1da4"]]},{"id":"26625939.7276f6","type":"function","z":"497de2b1.933d2c","name":"switch HF6508 any relay","func":"// this node takes a msg with the properties unitid (modbus ID), topic (relay number) \n// and a payload \"on\" or \"off\"\n\nvar state;\n\nif (msg.payload){\n    state = 255;\n}else{\n    state = 0;\n}\n\n\nswitch (Number(msg.topic)){\n    case 1:\n       execute_command(0x0010);\n       break;\n    case 2:\n        execute_command(0x0011);\n        break;\n    case 3:\n        execute_command(0x0012);\n        break;\n    case 4:\n        execute_command(0x0013);\n        break;\n    case 5:\n        execute_command(0x0014);\n        break;\n    case 6:\n        execute_command(0x0015);\n        break;\n    case 7:\n        execute_command(0x0016);\n        break;\n    case 8:\n        execute_command(0x0017);\n        break;\n}\n\n\nfunction execute_command(address){\n    msg.payload = { 'value': state,\n                    'fc': 5,\n                    'unitid': Number(msg.unitid),\n                    'address': address,\n                    'quantity': 1 };\n}\n\n\n\n\nreturn msg;\n","outputs":1,"noerr":0,"x":930,"y":400,"wires":[["c4eb14f2.8fc3e8"]]},{"id":"5ef0ed79.94b304","type":"change","z":"497de2b1.933d2c","name":"select unit id 1","rules":[{"t":"set","p":"unitid","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":240,"wires":[["37f1f8ca.eed3c8"]]},{"id":"dbf46f46.f1da4","type":"switch","z":"497de2b1.933d2c","name":"","property":"payload.address","propertyType":"msg","rules":[{"t":"eq","v":"16","vt":"num"},{"t":"eq","v":"17","vt":"num"},{"t":"eq","v":"18","vt":"num"},{"t":"eq","v":"19","vt":"num"},{"t":"eq","v":"20","vt":"num"},{"t":"eq","v":"21","vt":"num"},{"t":"eq","v":"22","vt":"num"},{"t":"eq","v":"23","vt":"num"}],"checkall":"true","repair":false,"outputs":8,"x":1370,"y":220,"wires":[["97354ea4.6cc02"],["33ec196e.9dc7a6"],["486df541.a380dc"],["6f6ffe2a.6cefa"],["9ee50374.2f52"],["2ce1ffbb.aa12"],["66d3cbaa.480904"],["343178fc.d2a258"]]},{"id":"33ec196e.9dc7a6","type":"change","z":"497de2b1.933d2c","name":"state","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.state","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1550,"y":80,"wires":[["f5d0282d.a036f8"]]},{"id":"486df541.a380dc","type":"change","z":"497de2b1.933d2c","name":"state","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.state","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1550,"y":140,"wires":[["b5509b36.60a778"]]},{"id":"6f6ffe2a.6cefa","type":"change","z":"497de2b1.933d2c","name":"state","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.state","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1550,"y":200,"wires":[["e4472f9a.673bf"]]},{"id":"9ee50374.2f52","type":"change","z":"497de2b1.933d2c","name":"state","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.state","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1550,"y":260,"wires":[["e20779e7.3ee5c8"]]},{"id":"2ce1ffbb.aa12","type":"change","z":"497de2b1.933d2c","name":"state","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.state","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1550,"y":320,"wires":[["843541c.fdbf9c"]]},{"id":"66d3cbaa.480904","type":"change","z":"497de2b1.933d2c","name":"state","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.state","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1550,"y":380,"wires":[["48957346.59c1bc"]]},{"id":"343178fc.d2a258","type":"change","z":"497de2b1.933d2c","name":"state","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.state","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1550,"y":440,"wires":[["87214b90.677808"]]},{"id":"37f1f8ca.eed3c8","type":"switch","z":"497de2b1.933d2c","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":710,"y":240,"wires":[["973a832a.5ccb6","3a753336.41bbec","4a61f7cf.11c0f8","f3763306.d2299","8e2df64.e1ab508","c5b29f0.931556","f337244a.f28798","dd6d546c.fea088"],["26625939.7276f6"]]},{"id":"973a832a.5ccb6","type":"function","z":"497de2b1.933d2c","name":"switch HF6508 relay 1","func":"// this node takes a msg with the properties unitid (modbus ID), topic (relay number) \n// and a payload \"on\" or \"off\"\n\nvar state;\n\nif (msg.payload){\n    state = 255;\n}else{\n    state = 0;\n}\n\nexecute_command(0x0010);\n\nfunction execute_command(address){\n    msg.payload = { 'value': state,\n                    'fc': 5,\n                    'unitid': Number(msg.unitid),\n                    'address': address,\n                    'quantity': 1 };\n}\n\nreturn msg;\n","outputs":1,"noerr":0,"x":920,"y":80,"wires":[["c4eb14f2.8fc3e8"]]},{"id":"3a753336.41bbec","type":"function","z":"497de2b1.933d2c","name":"switch HF6508 relay 2","func":"// this node takes a msg with the properties unitid (modbus ID), topic (relay number) \n// and a payload \"on\" or \"off\"\n\nvar state;\n\nif (msg.payload){\n    state = 255;\n}else{\n    state = 0;\n}\n\nexecute_command(0x0011);\n\nfunction execute_command(address){\n    msg.payload = { 'value': state,\n                    'fc': 5,\n                    'unitid': Number(msg.unitid),\n                    'address': address,\n                    'quantity': 1 };\n}\n\nreturn msg;\n","outputs":1,"noerr":0,"x":920,"y":120,"wires":[["c4eb14f2.8fc3e8"]]},{"id":"4a61f7cf.11c0f8","type":"function","z":"497de2b1.933d2c","name":"switch HF6508 relay 3","func":"// this node takes a msg with the properties unitid (modbus ID), topic (relay number) \n// and a payload \"on\" or \"off\"\n\nvar state;\n\nif (msg.payload){\n    state = 255;\n}else{\n    state = 0;\n}\n\nexecute_command(0x0012);\n\nfunction execute_command(address){\n    msg.payload = { 'value': state,\n                    'fc': 5,\n                    'unitid': Number(msg.unitid),\n                    'address': address,\n                    'quantity': 1 };\n}\n\nreturn msg;\n","outputs":1,"noerr":0,"x":920,"y":160,"wires":[["c4eb14f2.8fc3e8"]]},{"id":"f3763306.d2299","type":"function","z":"497de2b1.933d2c","name":"switch HF6508 relay 4","func":"// this node takes a msg with the properties unitid (modbus ID), topic (relay number) \n// and a payload \"on\" or \"off\"\n\nvar state;\n\nif (msg.payload){\n    state = 255;\n}else{\n    state = 0;\n}\n\nexecute_command(0x0013);\n\nfunction execute_command(address){\n    msg.payload = { 'value': state,\n                    'fc': 5,\n                    'unitid': Number(msg.unitid),\n                    'address': address,\n                    'quantity': 1 };\n}\n\nreturn msg;\n","outputs":1,"noerr":0,"x":920,"y":200,"wires":[["c4eb14f2.8fc3e8"]]},{"id":"8e2df64.e1ab508","type":"function","z":"497de2b1.933d2c","name":"switch HF6508 relay 5","func":"// this node takes a msg with the properties unitid (modbus ID), topic (relay number) \n// and a payload \"on\" or \"off\"\n\nvar state;\n\nif (msg.payload){\n    state = 255;\n}else{\n    state = 0;\n}\n\nexecute_command(0x0014);\n\nfunction execute_command(address){\n    msg.payload = { 'value': state,\n                    'fc': 5,\n                    'unitid': Number(msg.unitid),\n                    'address': address,\n                    'quantity': 1 };\n}\n\nreturn msg;\n","outputs":1,"noerr":0,"x":920,"y":240,"wires":[["c4eb14f2.8fc3e8"]]},{"id":"c5b29f0.931556","type":"function","z":"497de2b1.933d2c","name":"switch HF6508 relay 6","func":"// this node takes a msg with the properties unitid (modbus ID), topic (relay number) \n// and a payload \"on\" or \"off\"\n\nvar state;\n\nif (msg.payload){\n    state = 255;\n}else{\n    state = 0;\n}\n\nexecute_command(0x0015);\n\nfunction execute_command(address){\n    msg.payload = { 'value': state,\n                    'fc': 5,\n                    'unitid': Number(msg.unitid),\n                    'address': address,\n                    'quantity': 1 };\n}\n\nreturn msg;\n","outputs":1,"noerr":0,"x":920,"y":280,"wires":[["c4eb14f2.8fc3e8"]]},{"id":"f337244a.f28798","type":"function","z":"497de2b1.933d2c","name":"switch HF6508 relay 7","func":"// this node takes a msg with the properties unitid (modbus ID), topic (relay number) \n// and a payload \"on\" or \"off\"\n\nvar state;\n\nif (msg.payload){\n    state = 255;\n}else{\n    state = 0;\n}\n\nexecute_command(0x0016);\n\nfunction execute_command(address){\n    msg.payload = { 'value': state,\n                    'fc': 5,\n                    'unitid': Number(msg.unitid),\n                    'address': address,\n                    'quantity': 1 };\n}\n\nreturn msg;\n","outputs":1,"noerr":0,"x":920,"y":320,"wires":[["c4eb14f2.8fc3e8"]]},{"id":"dd6d546c.fea088","type":"function","z":"497de2b1.933d2c","name":"switch HF6508 relay 8","func":"// this node takes a msg with the properties unitid (modbus ID), topic (relay number) \n// and a payload \"on\" or \"off\"\n\nvar state;\n\nif (msg.payload){\n    state = 255;\n}else{\n    state = 0;\n}\n\nexecute_command(0x0017);\n\nfunction execute_command(address){\n    msg.payload = { 'value': state,\n                    'fc': 5,\n                    'unitid': Number(msg.unitid),\n                    'address': address,\n                    'quantity': 1 };\n}\n\nreturn msg;\n","outputs":1,"noerr":0,"x":920,"y":360,"wires":[["c4eb14f2.8fc3e8"]]},{"id":"b5509b36.60a778","type":"ui_switch","z":"497de2b1.933d2c","name":"","label":"DO3 9kW element","tooltip":"","group":"54991f8d.e80ce","order":3,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"3","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":1730,"y":140,"wires":[["584e3afc.08e014"]]},{"id":"f5d0282d.a036f8","type":"ui_switch","z":"497de2b1.933d2c","name":"","label":"DO2 4.5kW element","tooltip":"","group":"54991f8d.e80ce","order":2,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"2","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":1740,"y":80,"wires":[["584e3afc.08e014"]]},{"id":"e4472f9a.673bf","type":"ui_switch","z":"497de2b1.933d2c","name":"","label":"DO4 9kW element","tooltip":"","group":"54991f8d.e80ce","order":4,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"4","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":1730,"y":200,"wires":[["584e3afc.08e014"]]},{"id":"e20779e7.3ee5c8","type":"ui_switch","z":"497de2b1.933d2c","name":"","label":"Relay 5","tooltip":"","group":"54991f8d.e80ce","order":5,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"5","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":1700,"y":260,"wires":[["584e3afc.08e014"]]},{"id":"843541c.fdbf9c","type":"ui_switch","z":"497de2b1.933d2c","name":"","label":"Relay 6","tooltip":"","group":"54991f8d.e80ce","order":6,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"6","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":1700,"y":320,"wires":[["584e3afc.08e014"]]},{"id":"48957346.59c1bc","type":"ui_switch","z":"497de2b1.933d2c","name":"","label":"Relay 7","tooltip":"","group":"54991f8d.e80ce","order":7,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"7","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":1700,"y":380,"wires":[["584e3afc.08e014"]]},{"id":"87214b90.677808","type":"ui_switch","z":"497de2b1.933d2c","name":"","label":"Relay 8","tooltip":"","group":"54991f8d.e80ce","order":8,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"8","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":1700,"y":440,"wires":[["584e3afc.08e014"]]},{"id":"42159d1c.016eb4","type":"mqtt in","z":"497de2b1.933d2c","name":"","topic":"control/hf6508-1","qos":"2","datatype":"auto","broker":"7cde6843.362a58","x":140,"y":160,"wires":[["5f5e48c1.f53238"]]},{"id":"97354ea4.6cc02","type":"change","z":"497de2b1.933d2c","name":"state","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.state","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1550,"y":20,"wires":[["a8702afa.f8b7b8"]]},{"id":"a8702afa.f8b7b8","type":"ui_switch","z":"497de2b1.933d2c","name":"","label":"DO1 18kW element","tooltip":"","group":"54991f8d.e80ce","order":1,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"1","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":1730,"y":20,"wires":[["584e3afc.08e014"]]},{"id":"adc81b6e.c64858","type":"link in","z":"497de2b1.933d2c","name":"hf6508-1-relays","links":["584e3afc.08e014"],"x":75,"y":240,"wires":[["5ef0ed79.94b304"]]},{"id":"584e3afc.08e014","type":"link out","z":"497de2b1.933d2c","name":"hf6508-1-relay-manual-control","links":["adc81b6e.c64858"],"x":1875,"y":240,"wires":[]},{"id":"5f5e48c1.f53238","type":"function","z":"497de2b1.933d2c","name":"split mqtt command","func":"var command = msg.payload.split(\":\");\nmsg.topic = command[0];\nif(command[1] == \"1\"){\n    msg.payload = true;\n}else{\n    msg.payload = false;\n}\nreturn msg;","outputs":1,"noerr":0,"x":340,"y":160,"wires":[["5ef0ed79.94b304"]]},{"id":"5bba45b.d80283c","type":"comment","z":"497de2b1.933d2c","name":"HF6508-1","info":"","x":80,"y":20,"wires":[]},{"id":"4e1529c1.47516","type":"function","z":"497de2b1.933d2c","name":"set global variables hf6508-1-do","func":"var controllerid = 'hf6508-1';\n\nglobal.set(controllerid + '-do1',msg.payload[0]);\nglobal.set(controllerid + '-do2',msg.payload[1]);\nglobal.set(controllerid + '-do3',msg.payload[2]);\nglobal.set(controllerid + '-do4',msg.payload[3]);\nglobal.set(controllerid + '-do5',msg.payload[4]);\nglobal.set(controllerid + '-do6',msg.payload[5]);\nglobal.set(controllerid + '-do7',msg.payload[6]);\nglobal.set(controllerid + '-do8',msg.payload[7]);\n\nvar do1= {  'payload': msg.payload[0],\n            'topic': 'status/' + controllerid + '/do1'};\nvar do2= {  'payload': msg.payload[1],\n            'topic': 'status/' + controllerid + '/do2'};\nvar do3= {  'payload': msg.payload[2],\n            'topic': 'status/' + controllerid + '/do3'};\nvar do4= {  'payload': msg.payload[3],\n            'topic': 'status/' + controllerid + '/do4'};\nvar do5= {  'payload': msg.payload[4],\n            'topic': 'status/' + controllerid + '/do5'};\nvar do6= {  'payload': msg.payload[5],\n            'topic': 'status/' + controllerid + '/do6'};\nvar do7= {  'payload': msg.payload[6],\n            'topic': 'status/' + controllerid + '/do7'};\nvar do8= {  'payload': msg.payload[7],\n            'topic': 'status/' + controllerid + '/do8'};\n\n\n\nreturn [do1,do2,do3,do4,do5,do6,do7,do8]","outputs":8,"noerr":0,"x":2690,"y":240,"wires":[["d9d524a5.f94da8"],["d5eb5c5f.1f085"],["66ccaa30.eb2204"],["58fb24d5.7a16dc"],["e5e8e856.667188"],["a1192fa2.33711"],["4e07edd.cdf5c14"],["cd6006c3.37843"]]},{"id":"d9d524a5.f94da8","type":"mqtt out","z":"497de2b1.933d2c","name":"do1","topic":"","qos":"0","retain":"false","broker":"7cde6843.362a58","x":2950,"y":20,"wires":[]},{"id":"d5eb5c5f.1f085","type":"mqtt out","z":"497de2b1.933d2c","name":"do2","topic":"","qos":"0","retain":"false","broker":"7cde6843.362a58","x":2950,"y":80,"wires":[]},{"id":"66ccaa30.eb2204","type":"mqtt out","z":"497de2b1.933d2c","name":"d03","topic":"","qos":"0","retain":"false","broker":"7cde6843.362a58","x":2950,"y":140,"wires":[]},{"id":"58fb24d5.7a16dc","type":"mqtt out","z":"497de2b1.933d2c","name":"do4","topic":"","qos":"0","retain":"false","broker":"7cde6843.362a58","x":2950,"y":200,"wires":[]},{"id":"e5e8e856.667188","type":"mqtt out","z":"497de2b1.933d2c","name":"do5","topic":"","qos":"0","retain":"false","broker":"7cde6843.362a58","x":2950,"y":260,"wires":[]},{"id":"a1192fa2.33711","type":"mqtt out","z":"497de2b1.933d2c","name":"do6","topic":"","qos":"0","retain":"false","broker":"7cde6843.362a58","x":2950,"y":320,"wires":[]},{"id":"4e07edd.cdf5c14","type":"mqtt out","z":"497de2b1.933d2c","name":"do7","topic":"","qos":"0","retain":"false","broker":"7cde6843.362a58","x":2950,"y":380,"wires":[]},{"id":"cd6006c3.37843","type":"mqtt out","z":"497de2b1.933d2c","name":"do8","topic":"","qos":"0","retain":"false","broker":"7cde6843.362a58","x":2950,"y":440,"wires":[]},{"id":"1400ea4d.b6d556","type":"comment","z":"497de2b1.933d2c","name":"relay control","info":"","x":130,"y":100,"wires":[]},{"id":"ec53d0ca.8b86d","type":"modbus-flex-getter","z":"497de2b1.933d2c","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"ffd3a923.ab29f8","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":2440,"y":240,"wires":[["4e1529c1.47516"],[]]},{"id":"999d5aa0.e9f12","type":"inject","z":"497de2b1.933d2c","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":2010,"y":240,"wires":[["ac2aefbc.071a1"]]},{"id":"ac2aefbc.071a1","type":"function","z":"497de2b1.933d2c","name":"read all Digital Outputs","func":"msg.payload = { 'value': msg.payload,\n                'fc': 1,\n                'unitid': 1,\n                'address': 0x0010 ,\n                'quantity': 8 } \n\nreturn msg;","outputs":1,"noerr":0,"x":2210,"y":240,"wires":[["ec53d0ca.8b86d"]]},{"id":"e536b441.a084b","type":"comment","z":"497de2b1.933d2c","name":"digital Outputs (relays)","info":"","x":2020,"y":200,"wires":[]},{"id":"ffd3a923.ab29f8","type":"modbus-client","z":"","name":"hf6508-1-netp","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"172.16.66.107","tcpPort":"8899","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true},{"id":"54991f8d.e80ce","type":"ui_group","z":"","name":"HF6508-1 Relays H150","tab":"8c8f93ec.c5f47","order":2,"disp":true,"width":"6","collapse":false},{"id":"7cde6843.362a58","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"8c8f93ec.c5f47","type":"ui_tab","z":"","name":"Modbus Controllers","icon":"dashboard","order":4,"disabled":false,"hidden":false}]
2 Likes

Ok, here we go with the second part. The digital inputs.

[{"id":"93fa397a.852f98","type":"modbus-flex-getter","z":"497de2b1.933d2c","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"53242561.f4df5c","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":3680,"y":240,"wires":[["1259c459.693214"],[]]},{"id":"68c7485b.126c1","type":"inject","z":"497de2b1.933d2c","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":3250,"y":240,"wires":[["ed5dfcc5.0dabf"]]},{"id":"ed5dfcc5.0dabf","type":"function","z":"497de2b1.933d2c","name":"read all Digital Inputs","func":"msg.payload = { 'value': msg.payload,\n                'fc': 1,\n                'unitid': 1,\n                'address': 0x0000 ,\n                'quantity': 8 } \n\nreturn msg;","outputs":1,"noerr":0,"x":3450,"y":240,"wires":[["93fa397a.852f98"]]},{"id":"1259c459.693214","type":"function","z":"497de2b1.933d2c","name":"set global variables hf6508-1-di","func":"var controllerid = 'hf6508-1';\n\nglobal.set(controllerid + '-di1',msg.payload[0]);\nglobal.set(controllerid + '-di2',msg.payload[1]);\nglobal.set(controllerid + '-di3',msg.payload[2]);\nglobal.set(controllerid + '-di4',msg.payload[3]);\nglobal.set(controllerid + '-di5',msg.payload[4]);\nglobal.set(controllerid + '-di6',msg.payload[5]);\nglobal.set(controllerid + '-di7',msg.payload[6]);\nglobal.set(controllerid + '-di8',msg.payload[7]);\n\n\nvar di1= { 'payload': msg.payload[0],\n            'topic': 'status/' + controllerid + '/di1'};\nvar di2= { 'payload': msg.payload[1],\n            'topic': 'status/' + controllerid + '/di2'};\nvar di3= { 'payload': msg.payload[2],\n            'topic': 'status/' + controllerid + '/di3'};\nvar di4= { 'payload': msg.payload[3],\n            'topic': 'status/' + controllerid + '/di4'};\nvar di5= { 'payload': msg.payload[4],\n            'topic': 'status/' + controllerid + '/di5'};\nvar di6= { 'payload': msg.payload[5],\n            'topic': 'status/' + controllerid + '/di6'};\nvar di7= { 'payload': msg.payload[6],\n            'topic': 'status/' + controllerid + '/di7'};\nvar di8= { 'payload': msg.payload[7],\n            'topic': 'status/' + controllerid + '/di8'};\n\n\n\nreturn [di1,di2,di3,di4,di5,di6,di7,di8];","outputs":8,"noerr":0,"x":3950,"y":240,"wires":[["1f2b911f.ce84ef","bc726c33.d60a98"],["adb43b0.a4b3dc8","9ef106e9.eaa6d"],["bc922821.61d1a8","4a4d8daa.dd52d4"],["536b01e7.2ce7c","89efd517.b2af9"],["8a1d83c6.e0386","de44827c.954f4"],["105ea6a3.d31209","6395abc1.84f35c"],["c9fa0866.4034f8","6d9f33a9.3087dc"],["5872ba17.39e4f4","ab822a6e.aa8e9"]]},{"id":"12bc9464.351bb4","type":"comment","z":"497de2b1.933d2c","name":"digital inputs 3-30V REVERSE LOGIC","info":"","x":3330,"y":180,"wires":[]},{"id":"1f2b911f.ce84ef","type":"ui_led","z":"497de2b1.933d2c","group":"405f7a3b.e79b54","order":0,"width":0,"height":0,"label":"DI1","labelPlacement":"left","labelAlignment":"center","colorForValue":[{"color":"red","value":"false","valueType":"bool"},{"color":"green","value":"true","valueType":"bool"}],"allowColorForValueInMessage":false,"name":"","x":4210,"y":40,"wires":[]},{"id":"adb43b0.a4b3dc8","type":"ui_led","z":"497de2b1.933d2c","group":"405f7a3b.e79b54","order":0,"width":0,"height":0,"label":"DI2","labelPlacement":"left","labelAlignment":"center","colorForValue":[{"color":"red","value":"false","valueType":"bool"},{"color":"green","value":"true","valueType":"bool"}],"allowColorForValueInMessage":false,"name":"","x":4210,"y":100,"wires":[]},{"id":"bc922821.61d1a8","type":"ui_led","z":"497de2b1.933d2c","group":"405f7a3b.e79b54","order":0,"width":0,"height":0,"label":"DI3","labelPlacement":"left","labelAlignment":"center","colorForValue":[{"color":"red","value":"false","valueType":"bool"},{"color":"green","value":"true","valueType":"bool"}],"allowColorForValueInMessage":false,"name":"","x":4210,"y":160,"wires":[]},{"id":"536b01e7.2ce7c","type":"ui_led","z":"497de2b1.933d2c","group":"405f7a3b.e79b54","order":0,"width":0,"height":0,"label":"DI4","labelPlacement":"left","labelAlignment":"center","colorForValue":[{"color":"red","value":"false","valueType":"bool"},{"color":"green","value":"true","valueType":"bool"}],"allowColorForValueInMessage":false,"name":"","x":4210,"y":220,"wires":[]},{"id":"8a1d83c6.e0386","type":"ui_led","z":"497de2b1.933d2c","group":"405f7a3b.e79b54","order":0,"width":0,"height":0,"label":"DI5","labelPlacement":"left","labelAlignment":"center","colorForValue":[{"color":"red","value":"false","valueType":"bool"},{"color":"green","value":"true","valueType":"bool"}],"allowColorForValueInMessage":false,"name":"","x":4210,"y":280,"wires":[]},{"id":"105ea6a3.d31209","type":"ui_led","z":"497de2b1.933d2c","group":"405f7a3b.e79b54","order":0,"width":0,"height":0,"label":"DI6","labelPlacement":"left","labelAlignment":"center","colorForValue":[{"color":"red","value":"false","valueType":"bool"},{"color":"green","value":"true","valueType":"bool"}],"allowColorForValueInMessage":false,"name":"","x":4210,"y":340,"wires":[]},{"id":"c9fa0866.4034f8","type":"ui_led","z":"497de2b1.933d2c","group":"405f7a3b.e79b54","order":0,"width":0,"height":0,"label":"DI7","labelPlacement":"left","labelAlignment":"center","colorForValue":[{"color":"red","value":"false","valueType":"bool"},{"color":"green","value":"true","valueType":"bool"}],"allowColorForValueInMessage":false,"name":"","x":4210,"y":403.33331298828125,"wires":[]},{"id":"5872ba17.39e4f4","type":"ui_led","z":"497de2b1.933d2c","group":"405f7a3b.e79b54","order":0,"width":0,"height":0,"label":"DI8","labelPlacement":"left","labelAlignment":"center","colorForValue":[{"color":"red","value":"false","valueType":"bool"},{"color":"green","value":"true","valueType":"bool"}],"allowColorForValueInMessage":false,"name":"","x":4210,"y":460,"wires":[]},{"id":"bc726c33.d60a98","type":"mqtt out","z":"497de2b1.933d2c","name":"di1","topic":"","qos":"0","retain":"false","broker":"7cde6843.362a58","x":4350,"y":40,"wires":[]},{"id":"9ef106e9.eaa6d","type":"mqtt out","z":"497de2b1.933d2c","name":"di2","topic":"","qos":"0","retain":"false","broker":"7cde6843.362a58","x":4350,"y":100,"wires":[]},{"id":"4a4d8daa.dd52d4","type":"mqtt out","z":"497de2b1.933d2c","name":"di3","topic":"","qos":"0","retain":"false","broker":"7cde6843.362a58","x":4350,"y":160,"wires":[]},{"id":"89efd517.b2af9","type":"mqtt out","z":"497de2b1.933d2c","name":"di4","topic":"","qos":"0","retain":"false","broker":"7cde6843.362a58","x":4350,"y":220,"wires":[]},{"id":"de44827c.954f4","type":"mqtt out","z":"497de2b1.933d2c","name":"di5","topic":"","qos":"0","retain":"false","broker":"7cde6843.362a58","x":4350,"y":280,"wires":[]},{"id":"6395abc1.84f35c","type":"mqtt out","z":"497de2b1.933d2c","name":"di6","topic":"","qos":"0","retain":"false","broker":"7cde6843.362a58","x":4350,"y":340,"wires":[]},{"id":"6d9f33a9.3087dc","type":"mqtt out","z":"497de2b1.933d2c","name":"di7","topic":"","qos":"0","retain":"false","broker":"7cde6843.362a58","x":4350,"y":400,"wires":[]},{"id":"ab822a6e.aa8e9","type":"mqtt out","z":"497de2b1.933d2c","name":"di8","topic":"","qos":"0","retain":"false","broker":"7cde6843.362a58","x":4350,"y":460,"wires":[]},{"id":"53242561.f4df5c","type":"modbus-client","z":"","name":"hf6508-1-digital-in","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"172.16.66.107","tcpPort":"7799","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true},{"id":"405f7a3b.e79b54","type":"ui_group","z":"","name":"HF6508-1 Digital Input H150","tab":"8c8f93ec.c5f47","order":3,"disp":true,"width":"6","collapse":false},{"id":"7cde6843.362a58","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"8c8f93ec.c5f47","type":"ui_tab","z":"","name":"Modbus Controllers","icon":"dashboard","order":4,"disabled":false,"hidden":false}]
1 Like

This is the last part. The analog inputs and a small thing I made to check the network connectivity.
I hope it is useful to you and let me know if something isn't clear.

[{"id":"21c2bcb.076c444","type":"modbus-flex-getter","z":"497de2b1.933d2c","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"b09914d0.95bee","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":560,"y":740,"wires":[["f4f4de3f.a7c168"],[]]},{"id":"d91e78ad.36336","type":"inject","z":"497de2b1.933d2c","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":740,"wires":[["16188f5.f1c78f1"]]},{"id":"16188f5.f1c78f1","type":"function","z":"497de2b1.933d2c","name":"read all Analog Inputs","func":"msg.payload = { 'value': msg.payload,\n                'fc': 4,\n                'unitid': 1,\n                'address': 0x0000,\n                'quantity': 8 } \n\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":740,"wires":[["21c2bcb.076c444"]]},{"id":"f4f4de3f.a7c168","type":"function","z":"497de2b1.933d2c","name":"set global variables hf6508-1-ai","func":"var controllerid = 'hf6508-1';\n\n//first we read the analog 0-5V inputs\nglobal.set(controllerid + '-ai1',(Number(msg.payload[0])/1024)*5);\nglobal.set(controllerid + '-ai2',(Number(msg.payload[1])/1024)*5);\nglobal.set(controllerid + '-ai3',(Number(msg.payload[2])/1024)*5);\nglobal.set(controllerid + '-ai4',(Number(msg.payload[3])/1024)*5);\n\nvar ai1= { 'payload': (Number(msg.payload[0])/1024)*5,\n            'topic': 'status/' + controllerid + '/ai1'};\n\nvar ai2= { 'payload': (Number(msg.payload[1])/1024)*5,\n            'topic': 'status/h' + controllerid + '/ai2'};\n\nvar ai3= { 'payload': (Number(msg.payload[2])/1024)*5,\n            'topic': 'status/' + controllerid + '/ai3'};\n\nvar ai4= { 'payload': (Number(msg.payload[3])/1024)*5,\n            'topic': 'status/' + controllerid + '/ai4'};\n\n//((value / 102) * 5) / 200\n\n//now we read the current inputs\nglobal.set(controllerid + '-ci1',(((Number(msg.payload[4])/1024)*5)/200)*1000);\nglobal.set(controllerid + '-ci2',(((Number(msg.payload[5])/1024)*5)/200)*1000);\nglobal.set(controllerid + '-ci3',(((Number(msg.payload[6])/1024)*5)/200)*1000);\nglobal.set(controllerid + '-ci4',(((Number(msg.payload[7])/1024)*5)/200)*1000);\n\nvar ci1= { 'payload': (((Number(msg.payload[4])/1024)*5)/200)*1000,\n            'topic': 'status/' + controllerid + '/ci1'};\n\nvar ci2= { 'payload': (((Number(msg.payload[5])/1024)*5)/200)*1000,\n            'topic': 'status/' + controllerid + '/ci2'};\n\nvar ci3= { 'payload': (((Number(msg.payload[6])/1024)*5)/200)*1000,\n            'topic': 'status/' + controllerid + '/ci3'};\n\nvar ci4= { 'payload': (((Number(msg.payload[7])/1024)*5)/200)*1000,\n            'topic': 'status/' + controllerid + '/ci4'};\n\nreturn [ai1,ai2,ai3,ai4,ci1,ci2,ci3,ci4]","outputs":8,"noerr":0,"x":830,"y":720,"wires":[["b62b13f6.2e239"],["5f01f5f0.7053ec"],["ad891aae.deb148"],["da870c68.1861c"],["57691f41.f08a3"],["1e3c2330.4fff7d"],["ce220ed3.97ee5"],["52416ea2.b9e15"]],"outputLabels":["ai1","ai2","ai3","ai4","ci1","ci2","ci3","ci4"]},{"id":"45b26d37.41cd2c","type":"mqtt out","z":"497de2b1.933d2c","name":"ai1","topic":"","qos":"0","retain":"false","broker":"7cde6843.362a58","x":1570,"y":520,"wires":[]},{"id":"7f54ab29.e66cd4","type":"mqtt out","z":"497de2b1.933d2c","name":"ci1","topic":"","qos":"0","retain":"false","broker":"7cde6843.362a58","x":1570,"y":760,"wires":[]},{"id":"ee8188be.80abf","type":"mqtt out","z":"497de2b1.933d2c","name":"ci2","topic":"","qos":"0","retain":"false","broker":"7cde6843.362a58","x":1570,"y":820,"wires":[]},{"id":"c7ab2791.d4d6b8","type":"mqtt out","z":"497de2b1.933d2c","name":"ci3","topic":"","qos":"0","retain":"false","broker":"7cde6843.362a58","x":1570,"y":880,"wires":[]},{"id":"d20b930d.a1e68","type":"mqtt out","z":"497de2b1.933d2c","name":"ci4","topic":"","qos":"0","retain":"false","broker":"7cde6843.362a58","x":1570,"y":940,"wires":[]},{"id":"f35f4661.34d37","type":"mqtt out","z":"497de2b1.933d2c","name":"ai2","topic":"","qos":"0","retain":"false","broker":"7cde6843.362a58","x":1570,"y":580,"wires":[]},{"id":"9281207b.7e1fd8","type":"mqtt out","z":"497de2b1.933d2c","name":"ai3","topic":"","qos":"0","retain":"false","broker":"7cde6843.362a58","x":1570,"y":640,"wires":[]},{"id":"338e80c4.f189e8","type":"mqtt out","z":"497de2b1.933d2c","name":"ai4","topic":"","qos":"0","retain":"false","broker":"7cde6843.362a58","x":1570,"y":700,"wires":[]},{"id":"51978230.b591ec","type":"comment","z":"497de2b1.933d2c","name":"analog inputs 1-4=0-5V, 5-8=4-20mA","info":"","x":210,"y":680,"wires":[]},{"id":"92e964d0.4b0d18","type":"ui_text","z":"497de2b1.933d2c","group":"f82d451b.4d1c58","order":0,"width":0,"height":0,"name":"","label":"AI1","format":"{{msg.payload}} V","layout":"row-spread","x":1450,"y":520,"wires":[]},{"id":"fc387495.cb7108","type":"ui_text","z":"497de2b1.933d2c","group":"f82d451b.4d1c58","order":0,"width":0,"height":0,"name":"","label":"AI2","format":"{{msg.payload}} V","layout":"row-spread","x":1450,"y":580,"wires":[]},{"id":"266123c1.c67a2c","type":"ui_text","z":"497de2b1.933d2c","group":"f82d451b.4d1c58","order":0,"width":0,"height":0,"name":"","label":"AI3","format":"{{msg.payload}} V","layout":"row-spread","x":1450,"y":640,"wires":[]},{"id":"3ffb040.5f889fc","type":"ui_text","z":"497de2b1.933d2c","group":"f82d451b.4d1c58","order":0,"width":0,"height":0,"name":"","label":"AI4","format":"{{msg.payload}} V","layout":"row-spread","x":1450,"y":700,"wires":[]},{"id":"29c9c4e9.930b5c","type":"ui_text","z":"497de2b1.933d2c","group":"f82d451b.4d1c58","order":0,"width":0,"height":0,"name":"","label":"CI1","format":"{{msg.payload}} mA","layout":"row-spread","x":1450,"y":760,"wires":[]},{"id":"150c475d.61ed29","type":"ui_text","z":"497de2b1.933d2c","group":"f82d451b.4d1c58","order":0,"width":0,"height":0,"name":"","label":"CI2","format":"{{msg.payload}} mA","layout":"row-spread","x":1450,"y":820,"wires":[]},{"id":"988ee80c.ccfa88","type":"ui_text","z":"497de2b1.933d2c","group":"f82d451b.4d1c58","order":0,"width":0,"height":0,"name":"","label":"CI3","format":"{{msg.payload}} mA","layout":"row-spread","x":1450,"y":880,"wires":[]},{"id":"799ff288.44269c","type":"ui_text","z":"497de2b1.933d2c","group":"f82d451b.4d1c58","order":0,"width":0,"height":0,"name":"","label":"CI4","format":"{{msg.payload}} mA","layout":"row-spread","x":1450,"y":940,"wires":[]},{"id":"b62b13f6.2e239","type":"calculate","z":"497de2b1.933d2c","name":"median","pauseType":"rate","calculation":"median","timeout":"10","timeoutUnits":"milliseconds","rate":"8","x":1100,"y":520,"wires":[["99f591e1.0f668"]]},{"id":"5f01f5f0.7053ec","type":"calculate","z":"497de2b1.933d2c","name":"median","pauseType":"rate","calculation":"median","timeout":"10","timeoutUnits":"milliseconds","rate":"8","x":1100,"y":580,"wires":[["6d618087.ee3cc"]]},{"id":"ad891aae.deb148","type":"calculate","z":"497de2b1.933d2c","name":"median","pauseType":"rate","calculation":"median","timeout":"10","timeoutUnits":"milliseconds","rate":"8","x":1100,"y":640,"wires":[["8215e052.6cc68"]]},{"id":"da870c68.1861c","type":"calculate","z":"497de2b1.933d2c","name":"median","pauseType":"rate","calculation":"median","timeout":"10","timeoutUnits":"milliseconds","rate":"8","x":1100,"y":700,"wires":[["f18b0659.ac2208"]]},{"id":"57691f41.f08a3","type":"calculate","z":"497de2b1.933d2c","name":"median","pauseType":"rate","calculation":"median","timeout":"10","timeoutUnits":"milliseconds","rate":"8","x":1100,"y":760,"wires":[["396fb130.300c6e"]]},{"id":"1e3c2330.4fff7d","type":"calculate","z":"497de2b1.933d2c","name":"median","pauseType":"rate","calculation":"median","timeout":"10","timeoutUnits":"milliseconds","rate":"8","x":1100,"y":820,"wires":[["4a894f05.90aec"]]},{"id":"ce220ed3.97ee5","type":"calculate","z":"497de2b1.933d2c","name":"median","pauseType":"rate","calculation":"median","timeout":"10","timeoutUnits":"milliseconds","rate":"8","x":1100,"y":880,"wires":[["26ac3eab.6f4682"]]},{"id":"52416ea2.b9e15","type":"calculate","z":"497de2b1.933d2c","name":"median","pauseType":"rate","calculation":"median","timeout":"10","timeoutUnits":"milliseconds","rate":"8","x":1100,"y":940,"wires":[["43910860.250ec8"]]},{"id":"99f591e1.0f668","type":"calculator","z":"497de2b1.933d2c","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"rdec","constant":"2","x":1280,"y":520,"wires":[["92e964d0.4b0d18","45b26d37.41cd2c"]]},{"id":"6d618087.ee3cc","type":"calculator","z":"497de2b1.933d2c","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"rdec","constant":"2","x":1280,"y":580,"wires":[["fc387495.cb7108","f35f4661.34d37"]]},{"id":"8215e052.6cc68","type":"calculator","z":"497de2b1.933d2c","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"rdec","constant":"2","x":1280,"y":640,"wires":[["266123c1.c67a2c","9281207b.7e1fd8"]]},{"id":"f18b0659.ac2208","type":"calculator","z":"497de2b1.933d2c","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"rdec","constant":"2","x":1280,"y":700,"wires":[["3ffb040.5f889fc","338e80c4.f189e8"]]},{"id":"396fb130.300c6e","type":"calculator","z":"497de2b1.933d2c","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"rdec","constant":"2","x":1280,"y":760,"wires":[["29c9c4e9.930b5c","7f54ab29.e66cd4"]]},{"id":"4a894f05.90aec","type":"calculator","z":"497de2b1.933d2c","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"rdec","constant":"2","x":1280,"y":820,"wires":[["150c475d.61ed29","ee8188be.80abf"]]},{"id":"26ac3eab.6f4682","type":"calculator","z":"497de2b1.933d2c","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"rdec","constant":"2","x":1280,"y":880,"wires":[["988ee80c.ccfa88","c7ab2791.d4d6b8"]]},{"id":"43910860.250ec8","type":"calculator","z":"497de2b1.933d2c","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"rdec","constant":"2","x":1280,"y":940,"wires":[["799ff288.44269c","d20b930d.a1e68"]]},{"id":"84799e20.1fb86","type":"ping","z":"497de2b1.933d2c","mode":"timed","name":"","host":"172.16.66.107","timer":"10","inputs":0,"x":1830,"y":680,"wires":[["67939bb6.0ed944"]]},{"id":"67939bb6.0ed944","type":"switch","z":"497de2b1.933d2c","name":"network state","property":"payload","propertyType":"msg","rules":[{"t":"false"},{"t":"gt","v":"100","vt":"num"},{"t":"lt","v":"100","vt":"num"}],"checkall":"false","repair":false,"outputs":3,"x":2000,"y":680,"wires":[["cc12a6df.e7e868"],["ced16bd9.a86e88"],["3c15548c.f652fc"]]},{"id":"45207120.09da4","type":"change","z":"497de2b1.933d2c","name":"orange","rules":[{"t":"set","p":"payload","pt":"msg","to":"orange","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2400,"y":600,"wires":[["26477d76.0c89b2"]]},{"id":"3c15548c.f652fc","type":"change","z":"497de2b1.933d2c","name":"green","rules":[{"t":"set","p":"payload","pt":"msg","to":"green","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2390,"y":680,"wires":[["26477d76.0c89b2"]]},{"id":"a89cca92.28ab28","type":"change","z":"497de2b1.933d2c","name":"red","rules":[{"t":"set","p":"payload","pt":"msg","to":"red","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2390,"y":720,"wires":[["26477d76.0c89b2"]]},{"id":"26477d76.0c89b2","type":"ui_led","z":"497de2b1.933d2c","group":"ae943f42.af495","order":1,"width":0,"height":0,"label":"HF6508-1 H150","labelPlacement":"left","labelAlignment":"left","colorForValue":[{"color":"red","value":"red","valueType":"str"},{"color":"orange","value":"orange","valueType":"str"},{"color":"green","value":"green","valueType":"str"}],"allowColorForValueInMessage":false,"name":"hf6508-1 H150","x":2760,"y":680,"wires":[]},{"id":"aad42f40.3ea9e","type":"comment","z":"497de2b1.933d2c","name":"Network Connection","info":"","x":1850,"y":620,"wires":[]},{"id":"5ddae2.07bd652","type":"ui_toast","z":"497de2b1.933d2c","position":"dialog","displayTime":"3","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"","raw":false,"topic":"","name":"","x":2750,"y":720,"wires":[[]]},{"id":"e9d2d98f.bef068","type":"change","z":"497de2b1.933d2c","name":"congested","rules":[{"t":"set","p":"payload","pt":"msg","to":"The network connection with HF6508-1 is congested","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2410,"y":640,"wires":[["f9492465.dc5698"]]},{"id":"5569449e.a45d7c","type":"change","z":"497de2b1.933d2c","name":"lost","rules":[{"t":"set","p":"payload","pt":"msg","to":"The network connection with HF6508-1 is LOST","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2390,"y":760,"wires":[["f9492465.dc5698"]]},{"id":"f9492465.dc5698","type":"rbe","z":"497de2b1.933d2c","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":2610,"y":720,"wires":[["5ddae2.07bd652"]]},{"id":"ced16bd9.a86e88","type":"frequency","z":"497de2b1.933d2c","name":"freq1","interval":"30000","ntfyinterval":"30000","x":2150,"y":620,"wires":[["21c4af18.93de"]]},{"id":"21c4af18.93de","type":"switch","z":"497de2b1.933d2c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0.1","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":2270,"y":620,"wires":[["45207120.09da4","e9d2d98f.bef068"]]},{"id":"cc12a6df.e7e868","type":"frequency","z":"497de2b1.933d2c","name":"freq1","interval":"30000","ntfyinterval":"30000","x":2150,"y":740,"wires":[["75da3f20.a1685"]]},{"id":"75da3f20.a1685","type":"switch","z":"497de2b1.933d2c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0.1","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":2270,"y":740,"wires":[["5569449e.a45d7c","a89cca92.28ab28"]]},{"id":"b09914d0.95bee","type":"modbus-client","z":"","name":"hf6508-1-analog-in","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"tcpHost":"172.16.66.107","tcpPort":"9999","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true},{"id":"7cde6843.362a58","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"f82d451b.4d1c58","type":"ui_group","z":"","name":"HF6508-1 Analog Input H150","tab":"8c8f93ec.c5f47","order":4,"disp":true,"width":"6","collapse":false},{"id":"ae943f42.af495","type":"ui_group","z":"","name":"State","tab":"8c8f93ec.c5f47","order":1,"disp":true,"width":"6","collapse":false},{"id":"8c8f93ec.c5f47","type":"ui_tab","z":"","name":"Modbus Controllers","icon":"dashboard","order":4,"disabled":false,"hidden":false}]
1 Like

Hi @nrbrt,

Many thanks for quick reply and all the example flows, I'll give them a go this evening.

I tried a couple of low cost relay boards, but settled on the HF6508 as the build quality seemed pretty good, the case is nice and it is din rail mountable. I bought 3 for my home automation cabinet, I'm planning on buying 2 more.

I'll let you know how I get on, thanks again!

2 Likes

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.