Hi all. I am new to HA and trying to build a smart home system over rs485 bus. I’m running into a problem editing the YAML config file correctly. I am not a programmer. I’m trying to get information about the status of the relay and relay module inputs. From the description of the module, I know what commands should be sent to the module in order to receive a response with input states and relay states. If I send these requests through a third-party terminal, then everything works. But all my attempts to create a query in a YAML file fail. I get a message that the file has not been edited correctly. For several days I tried to find YAML examples that can be copied and that would work, but there is nothing on the Internet. Only some scraps of non-working configurations. I wrote to several messages on the forums, but did not receive a single response. I’m confused and don’t understand why this is happening. Complete lack of support. I am willing to pay money to someone who will help me set up my configuration. Please somebody help!
I see this all the time. Editing/Creating yaml is not programming. It’s a data format. Just learn the format and you’re good. If you can fill out a form, you can edit yaml. Don’t let the thought of “Programming” yaml hold you back.
As for your modbus configuration. It looks correct assuming you’re using a USB serial connection with default settings. Typically default settings for serial connections are 9600 baudrate, 1 stopbit, 8 bytesize, with a parity of None (N).
The only thing in question is your port. Ensure that is the correct port.
Post the message as well. Please don’t paraphrase the message, post it exactly.
My dude, what you have written is an example. It should work. You’re using the modbus protocol. What’s the address that you need to read? Do you know how modbus works?
Remarks: Bit0–Bit7 of the 4th byte of the return frame, 0x01, represent relay 1–relay 8, 0 means off, and 1 means on.
Read optocoupler input status
Send: FF 02 00 00 00 08 6C 12
Returns: FF 02 01 01 51 AO
Remarks: IN1–IN8 of the 4th byte of the return frame 0x01 represent the input signal of optocoupler 1 to optocoupler 8, 0 represents low level, and 1 represents high level
How to send the request described in paragraph 8 and paragraph 9?
That does not look like a normal modbus protocol. Normally, you read a register by polling it to get information. They tell you what the register address is, then you poll it.
What you’re posting here looks like a separate protocal, unrelated to modbus.
The device lists modbus, but does it actually use modbus?
EDIT: Unless the bytes represent the address. 08 28 12
Remarks: (1) The 3-4 bytes of the sending frame represent the relay address. The addresses of relay 1-relay 8 are 0x0000, 0x0001,0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007
(2) The 5-6 bytes of the sending frame represent data, 0xFF00 means opening the relay, and 0x0000 means closing the relay.
Turn off the No. 1 relay (manual mode)
Send: FF 05 00 00 00 00 D8 14
Return as it is: FF 05 00 00 00 00 D8 14
Turn on all relays
Send: FF 0F 00 00 00 08 01 FF 30 1D
Return: FF 0F 00 00 00 08 41 D3
Turn off all relays
Send: FF OF 00 00 00 08 01 00 70 5D
Returns: FF OF 00 00 00 08 41 D3
At least this part works like a modbus (the code I posted earlier)
I’m sorry, but I’ve written a modbus protocol from the ground up. That does not look like a typical modbus protocol. There’s information in the manual for that product that’s missing. How is it expecting you to send that information? Via write_register or write_coils?
I do not know how in your Modbus system you need to correctly send a request. That’s why I created a topic with the question “how to get the data”? I have not found clear instructions on how to do this.
I guess it’s possible that they are simply telling you the information users typically don’t use? Very odd way to present the information. I guess they are assuming you aren’t using a modbus library.
Ok, I guess we have to assume that FF is the address and 05 or 0F is the function.
05 is write single coil. 0F is Write Multiple Registers.
Through the terminal window, I was also able to change the address of the slave device from 255 to 3. So all the functions of the Chinese module work as described.
Yes, it’s light. Before proceeding with the installation, I want the system to start working stably on the table. I don’t want to use radio communication in my house. All devices must be wired only. Control of lighting, heating, ventilation, etc.
As I said before, typically API’s do not give you this information. They tell you the commands to run with the values to create. Right now, we have to reverse engineer the RAW api.
Looks like you’re going to have to learn how to reverse engineer protocols then. What you’re after is the hardest possible route with what appears to be a poorly documented device.
EDIT: Also keep in mind that you’re using modbus which means you have to poll the status of the light in order to react to it. It does not provide live changes…
IMO you’re going the wrong route. All you’re gaining is the ability to turn lights on and off, you won’t be able to react to them in real time. You’ll always be limited to a polling frequency.
And it turns on and off your light? Makes no sense based on what your documentation says. Anyways, if that works, then don’t bother trying what I wrote and throw out that manual.
That’s it works. This code only controls the relay. How to add a login poll? I don’t want to delite the code for relay control. I want to add a new fragment to the already existing code, with the help of which you can poll the state of the inputs or some other functions.