Modbus RTU 1/2/4/8 Channel Relay Output Board

I have problems with configurantion modbus RTU reley like this:


I have tried with code
`modbus:
  • type: serial
    name: hubrelay
    method: rtu
    port: /dev/ttySC0
    baudrate: 9600
    stopbits: 1
    bytesize: 8
    parity: N
    timeout: 1
    switch:
    platform: modbus
    coils:
    • name: Switch1
      hub: hub1
      slave: 1
      coil: 1

registers:
- name: Register1
hub: hub1
slave: 1
register: 1
command_on: 1
command_off: 0
`
I can use the relay wit this code: echo -en ‘\x01\x05\x00\x00\xFF\x00\x8C\x3A’ > /dev/ttySC0 (open)
echo -en ‘\x01\x05\x00\x00\x00\x00\xCD\xCa’ > /dev/ttySC0 (close)
The adress is 01 and 0xFF00 represents opening the relay, and 0x0000 represents closing the relay
It can also:
Read relay status
Send: FF 01 00 00 00 08 28 12
Returns: FF 01 01 01 A1 A0
Remarks: Bit 0–Bit 7 of the 4th byte of the returned frame, 0x01, represent relay 1–relay 8, 0 is off, 1 is on
Read optocoupler input status
Send: FF 02 00 00 00 08 6C 12
Returns: FF 02 01 01 51 A0
Remarks: IN1–IN8 of the 4th byte of the returned frame, 0x01, represents the input signal of optocoupler 1–optocoupler 8, 0 represents low level, 1 represents high level

Please halp me. I have serched whole forum but cant find the solution with using the relay and the digital inputs.

Just started poking the board. Did you have any success integrating it with HA?

@stivi or @visstro Was you successful? I have similar problem.

I solved the problem in node red, here you have the code.
[{“id”:“5aee700cef3dcb9b”,“type”:“tab”,“label”:“Flow 3”,“disabled”:false,“info”:"",“env”:[]},{“id”:“50a21f04cf34a1a4”,“type”:“server-state-changed”,“z”:“5aee700cef3dcb9b”,“name”:"",“server”:“42e85e30.84e02”,“version”:4,“exposeToHomeAssistant”:false,“haConfig”:[{“property”:“name”,“value”:""},{“property”:“icon”,“value”:""}],“entityidfilter”:“input_boolean.wlacz_ciepla_wode”,“entityidfiltertype”:“exact”,“outputinitially”:true,“state_type”:“str”,“haltifstate”:"",“halt_if_type”:“str”,“halt_if_compare”:“is”,“outputs”:1,“output_only_on_state_change”:true,“for”:“0”,“forType”:“num”,“forUnits”:“minutes”,“ignorePrevStateNull”:false,“ignorePrevStateUnknown”:false,“ignorePrevStateUnavailable”:false,“ignoreCurrentStateUnknown”:false,“ignoreCurrentStateUnavailable”:false,“outputProperties”:[{“property”:“payload”,“propertyType”:“msg”,“value”:"",“valueType”:“entityState”},{“property”:“data”,“propertyType”:“msg”,“value”:"",“valueType”:“eventData”},{“property”:“topic”,“propertyType”:“msg”,“value”:"",“valueType”:“triggerId”}],“x”:350,“y”:360,“wires”:[[“3ca9af3210559dd3”,“8e429d1e69f83ca4”]]},{“id”:“8e429d1e69f83ca4”,“type”:“function”,“z”:“5aee700cef3dcb9b”,“name”:“on”,“func”:“if (msg.payload==‘on’)\n{\n msg.payload=\n {\n ‘value’: true,\n ‘fc’: 5,\n ‘unitid’: 1,\n ‘address’: 0x0000,\n ‘quantity’: 1,\n };\n}\nreturn msg;”,“outputs”:1,“noerr”:0,“initialize”:"",“finalize”:"",“libs”:[],“x”:630,“y”:280,“wires”:[[“ed4a25cb91728459”]]},{“id”:“3ca9af3210559dd3”,“type”:“function”,“z”:“5aee700cef3dcb9b”,“name”:“off”,“func”:“if (msg.payload==‘off’)\n{\n msg.payload=\n {\n ‘value’: false,\n ‘fc’: 5,\n ‘unitid’: 1,\n ‘address’: 0x0000,\n ‘quantity’: 1,\n };\n}\nreturn msg;\n”,“outputs”:1,“noerr”:0,“initialize”:"",“finalize”:"",“libs”:[],“x”:630,“y”:460,“wires”:[[“ed4a25cb91728459”]]},{“id”:“8e0e05c643ef7f5d”,“type”:“modbus-response”,“z”:“5aee700cef3dcb9b”,“name”:"",“registerShowMax”:20,“x”:1030,“y”:380,“wires”:[]},{“id”:“676cd91d8fdb068e”,“type”:“modbus-response”,“z”:“5aee700cef3dcb9b”,“name”:"",“registerShowMax”:20,“x”:1030,“y”:280,“wires”:[]},{“id”:“ed4a25cb91728459”,“type”:“modbus-flex-write”,“z”:“5aee700cef3dcb9b”,“name”:"",“showStatusActivities”:false,“showErrors”:false,“server”:“f0f4cd4889af5c5d”,“emptyMsgOnFail”:true,“keepMsgProperties”:false,“x”:790,“y”:320,“wires”:[[“676cd91d8fdb068e”],[“8e0e05c643ef7f5d”]],“outputLabels”:["",“msg”]},{“id”:“ef2df3fd69c60e2e”,“type”:“inject”,“z”:“5aee700cef3dcb9b”,“name”:"",“props”:[{“p”:“payload”},{“p”:“topic”,“vt”:“str”}],“repeat”:"",“crontab”:"",“once”:false,“onceDelay”:0.1,“topic”:"",“payload”:“on”,“payloadType”:“str”,“x”:450,“y”:280,“wires”:[[“8e429d1e69f83ca4”]]},{“id”:“2829dfb777946395”,“type”:“inject”,“z”:“5aee700cef3dcb9b”,“name”:"",“props”:[{“p”:“payload”},{“p”:“topic”,“vt”:“str”}],“repeat”:"",“crontab”:"",“once”:false,“onceDelay”:0.1,“topic”:"",“payload”:“off”,“payloadType”:“str”,“x”:450,“y”:460,“wires”:[[“3ca9af3210559dd3”]]},{“id”:“42e85e30.84e02”,“type”:“server”,“name”:“Home Assistant”,“version”:5,“addon”:true,“rejectUnauthorizedCerts”:true,“ha_boolean”:“y|yes|true|on|home|open”,“connectionDelay”:true,“cacheJson”:true,“heartbeat”:false,“heartbeatInterval”:30,“areaSelector”:“friendlyName”,“deviceSelector”:“friendlyName”,“entitySelector”:“friendlyName”,“statusSeparator”:“at: “,“statusYear”:“hidden”,“statusMonth”:“short”,“statusDay”:“numeric”,“statusHourCycle”:“h23”,“statusTimeFormat”:“h:m”,“enableGlobalContextStore”:true},{“id”:“f0f4cd4889af5c5d”,“type”:“modbus-client”,“name”:””,“clienttype”:“simpleser”,“bufferCommands”:true,“stateLogEnabled”:false,“queueLogEnabled”:false,“tcpHost”:“127.0.0.1”,“tcpPort”:“502”,“tcpType”:“DEFAULT”,“serialPort”:"/dev/ttyUSB0",“serialType”:“RTU-BUFFERD”,“serialBaudrate”:“9600”,“serialDatabits”:“8”,“serialStopbits”:“1”,“serialParity”:“none”,“serialConnectionDelay”:“100”,“serialAsciiResponseStartDelimiter”:“0x3A”,“unit_id”:“1”,“commandDelay”:“10”,“clientTimeout”:“100”,“reconnectOnTimeout”:false,“reconnectTimeout”:"",“parallelUnitIdsAllowed”:true}]

Hi,
I’m using this relais module LINK, which is connected by this USB-RS485 Adapter.
This module can be easily controlled by these entries in configuration.yaml

modbus:
  - name: ModBusRelaisBoard
    message_wait_milliseconds: 250 
    delay: 1
    retries: 3
    retry_on_empty: true
    close_comm_on_error: false
    type: serial
    baudrate: 9600
    bytesize: 8
    method: rtu
    parity: N
    port: /dev/ttyUSB0
    stopbits: 1
    switches:
    - name: SW001
      slave: 1
      address: 0
      write_type: coil
    - name: SW002
      slave: 1
      address: 1
      write_type: coil
    - name: SW003
      slave: 1
      address: 2
      write_type: coil
    - name: SW004
      slave: 1
      address: 3
      write_type: coil
    - name: SW005
      slave: 1
      address: 4
      write_type: coil
    - name: SW006
      slave: 1
      address: 5
      write_type: coil
    - name: SW007
      slave: 1
      address: 6
      write_type: coil
    - name: SW008
      slave: 1
      address: 7
      write_type: coil 

image

Sorry, I did not see the notification.
I got it working, but have no notes from that. It was very tedious to work with. I returned it after a week and got an ESP32 board. ESPHome works much better.

I succeeded, took no longer than 15 minutes. yaml posted by luftdieb worked from the start. Thank him for that.

I managed to get relays working thanks to code by luftdieb, but how can i read inputs?
Just started with HA…