Issues with editing YAML

You have to add verify to the yaml.

Assuming command_on and off are correct by being defaults. You just need to provide the address to read the state from, which your documentation didn’t tell you about.

To poll, change the scan_interval.

e.g. this might work

      - name: "light1"
        slave: 3
        address: 0
        write_type: coil
        scan_interval: 20
        verify:
          address: 0
          input_type: coil

you just need to know the name of your port. Is (z) in the name of your port? If no, remove it. You’re thinking too much into that. It’s simply an identifier that lets HA know which USB to use.

It looks like this is my mistake. I still don’t understand how it turned out, but now nothing works …

Removed the “z” and pulled out and turned on the USB 485 adapter again and now everything works again.

modbus: 
  - name: hubrelay
    type: serial
    method: rtu
    port: /dev/ttyUSB0
    baudrate: 9600
    stopbits: 1 
    bytesize: 8
    parity: N
    timeout: 1
    lights:
      - name: "light1"
        slave: 3
        address: 0
        write_type: coil        
      - name: "light2"
        slave: 3
        address: 1
        write_type: coil
      - name: "light3"
        slave: 3
        address: 2
        write_type: coil
      - name: "light4"
        slave: 3
        address: 3
        write_type: coil

I added your snippet to the code and now the “light1” relay has stopped working. The control button “light1” on the control panel is not active. Other relays (“light2”-“light4”) work normally.

modbus: 
  - name: hubrelay
    type: serial
    method: rtu
    port: /dev/ttyUSB0
    baudrate: 9600
    stopbits: 1 
    bytesize: 8
    parity: N
    timeout: 1
    lights:
      - name: "light1"
        slave: 3
        address: 0
        write_type: coil
        scan_interval: 10
        verify:
          address: 0
          input_type: coil        
      - name: "light2"
        slave: 3
        address: 1
        write_type: coil
      - name: "light3"
        slave: 3
        address: 2
        write_type: coil
      - name: "light4"
        slave: 3
        address: 3
        write_type: coil

As I said, you need to figure out what address to read the state of the relay from. I made a guess because all the documentation snippets you’ve shared so far have been 100% wrong and are missing that information.

Based on that, 01 is read coils. You just need to figure out the address to read.

Is there a way to get that address?

No, you get it from the documentation of the device.

I have already written to the Chinese, but I’m not sure that they will report something useful. I need to figure out a way to determine the address myself. Or you need to find and buy other relay modules that are guaranteed to work with HA.

Do you think this module will work with HA Modbus? Should it be ordered? Modbus RTU Control I/O RS485 Interface 4DI+4DO CDE

【4DI+4DO】MA01±AXCX4040_UserManual_EN_v1.1.pdf

From China they sent a “manual” for my old relay module. Is there enough information there to read the state of the relay and inputs? Or need another module?

I’m sorry but I’m not going to reverse engineer your entire hardware system for you. They are providing information to you via hex and you need to learn the modbus protocal and convert the values into the correct calls for the configuration in HA.

This will require you to read up on how modbus works as a protocol and what each byte means.

If you aren’t willing to do that, then this product and protocol isn’t for you.

There are other hardwired systems for home automation like KNX that might be easier for you to understand.

This is a good resource to learn the bytes for modbus.

I didn’t ask you to do anything. I just asked the question: Did the particular equipment work or not. If you are a HA developer, then I want to tell you that everything is bad with you. I don’t know why you advertise that HA supports Modbus. Because it doesn’t actually work. There are no workable code examples. In the description of Modbus on your site, only a superficial description and more than one workable example. I asked a simple question: Will a particular Chinese module work or not. But you can’t even give a clear answer. Because in fact there is no Modbus in HA. Only a pathetic semblance that can turn on a relay. I don’t know your business and I don’t know why you promise people something that isn’t there.

wow, that’s a lot of bile.

I don’t know if Petro is an HA developer or not, but he’s tried hard to assist you here. The documentation you’ve been given is very poor it doesn’t provide the information required and expected by modbus standards.

Why blame HA and it’s unpaid supporters for your poor buying decisions? Do your research before spending cash and make sure what you buy will integrate into your chosen eco-system.

I imagine you’ve not paid a bean for Home Assistant, but you expect it to support a random, undocumented, bit of kit you bought cheap on the world wild webs.

2 Likes

Modbus works perfectly fine for me. Sorry but don’t buy Chinese boards without good documentation. Don’t buy products you don’t understand either. Modbus works off addresses, you can’t even get that information from the documentation, yet somehow it’s home assistants fault.

Just to put this into perspective, I’ve integrated multiple modbus devices at my actual job on assembly lines. They all have proper documentation by telling you what address to read from and write to. They tell you the function to use as well. They do not feed you this information as the underlying hex protocol like yours does. I know the protocol to an extent, but I’d have to read up on the byte order and the meaning behind them before I could progress with the board you bought. And this is my day job.

Simply put: You made a poor purchase and now you’re blaming us.

2 Likes

【4DI+4DO】MA01±AXCX4040_UserManual_EN_v1.1.pdf
I provided a link to the documentation a couple of posts ago. I was unable to upload the pdf file to this forum.
And I was trying to find a person who could write workable YAML code for money. But so far no one has responded. Any code I copied from the HA site in the Modbus section caused a compilation error. None of the examples worked. There is no description of how to read the state. (although the real Modbus protocol has such functions) But you claim that it can work, but did not provide a single code example that would actually work. Only words about the poor documentation of Chinese relay modules.

Because you need the address to read from. I don’t know how else to explain this to you. This is something YOU need to provide. YOU.

I am ready to buy any other module if it will cost adequate money. I don’t blame anyone. This is my desire to experiment in the hope of succeeding.

what would be the purpose of providing examples from different devices, when they don’t help you to understand yours?

I understand your offer to pay, but lack of uptake should be an indicator that this is not easily resolved. The people who post here are not paid by the HA project, we try to help, but, at the end of the day, HA is free to you and so are the efforts for support people have made. It’s kind of bad manners to insult them as you did in the earlier post.

I hope you get some recommendations for hardware that will do what you request, and I hope the patience of the community continues to try to support you if you need help to make that work.