RS485 relay

Greetings to all

I’m new to HA and I’m configuring a 4-relay board, type RS485.

The action of closing or opening the relays I have already got it, placing these parameters in the “configuration.yaml” file:

command_state: rele 0-1-2-3


  • platform: command_line
    command_open: echo -en ‘\x01\x05\x00\x00\xFF\x00\x8C\x3A’ > /dev/ttyUSB0
    command_close: echo -en ‘\x01\x05\x00\x00\x00\x00\xCD\xCA’ > /dev/ttyUSB0

command_state: rele2

command_open: echo -en ‘\x01\x05\x00\x01\xFF\x00\xDD\xFA’ > /dev/ttyUSB0
command_close: echo -en ‘\x01\x05\x00\x01\x00\x00\x9C\x0A’ > /dev/ttyUSB0

command_state: rele3

command_open: echo -en ‘\x01\x05\x00\x02\xFF\x00\x2D\xFA’ > /dev/ttyUSB0
command_close: echo -en ‘\x01\x05\x00\x02\x00\x00\x6C\x0A’ > /dev/ttyUSB0

command_state: rele4

command_open: echo -en ‘\x01\x05\x00\x03\xFF\x00\x7C\x3A’ > /dev/ttyUSB0
command_close: echo -en ‘\x01\x05\x00\x03\x00\x00\x3D\xCA’ > /dev/ttyUSB0

End RS485

As you can see, the relay board changes status by sending a predefined code in Hexadecimal. I also have the option to ask the board the status of each relay, but I could only do it via console, sending a hexadecimal code and receiving another code indicating the status of the relays.

for example:
-If I have all the relays open and I send the status 0101000001FDCA the result will be a Hex code with the format xx-xx-xx-xx-xx-00-xx-xx
-If I only have active the relay number 0. and then I send the status the result will be: xx-xx-xx-xx-xx-01-xx-xx and so on until reaching 0F where it indicates that all the relays are active.

Can you tell me how I can make the HA appear or show the possible status of the relays?
The ideal is to send every certain interval the status code to check the state of the relays.

Thank you