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}]