Modbus Configuration

Hi

I’ve spent hours trying to get my ventilation unit to connect to home assistant.

It uses modbus protocol and I’ve succesfully communicated with it using windows test software. However, I can’t seem to get any readings from it in home assistant.

Using the logger I think I’ve tracked down the problem in that the modbus commands being sent out dont match what the slave is expecting as per the documentation

image

and this is what the logs say modbus is sending:

pymodbus.transaction] Transaction failed. (Modbus Error: [Invalid Message] Incomplete message received, expected at least 2 bytes (0 received)) 
2021-04-25 19:15:48 DEBUG (SyncWorker_1) [pymodbus.transaction] RESETTING Transaction state to 'IDLE' for retry
2021-04-25 19:15:48 DEBUG (SyncWorker_1) [pymodbus.transaction] Retry on empty - 2
2021-04-25 19:15:48 DEBUG (SyncWorker_1) [pymodbus.transaction] SEND: 0x1 0x3 0x0 0xe 0x0 0x1 0xe5 0xc9
2021-04-25 19:15:48 DEBUG (SyncWorker_1) [pymodbus.client.sync] New Transaction state 'SENDING'
2021-04-25 19:15:48 DEBUG (SyncWorker_1) [pymodbus.transaction] Changing transaction state from 'SENDING' to 'WAITING FOR REPLY'

anyone got any ideas how to fix this?

Can we see your configuration?

modbus:

  - name: Alnor
    type: serial
    method: rtu
    port: /dev/ttyUSB0
    baudrate: 9600
    stopbits: 1
    bytesize: 8
    parity: N
    sensors:
      - name: Ra
        slave: 1
        address: 13
        input_type: holding
        unit_of_measurement: °C
        count: 2
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int

and this from the manual

image

You are sending this:

SEND: 0x1 0x3 0x0 0xe 0x0 0x1 0xe5 0xc9

Looks sort of ok to me. I think.

Address: 0x1 (this is the slave address you specified in your config, and matches your document)

Function Code: 0x3 (valid register reading code according to your document)

Register ID: 0x0 0xe  (== 14 decimal, see comment below)

Data Length: 0x0 0x1 (16 bit integer)

Failure Control: 0xe5 0xc9 (if this is a checksum it will change depending on what you send)

So the only odd thing is the register address. It’s sending a request for address 14, you specified 13 and a count of two (13 and 14).

You could try adding the reverse_order: true option to your config. See the option here: Modbus - Home Assistant

reverse_order boolean (Optional, default: false)

Reverse the order of registers when count >1.

thanks very much, that seemed to fix it. I can now read temperature readings from it.

Now I’m stuck on how to apply that fix to any other modbus platform eg. a switch which doesn’t have reverse_order as a variable.

or even to use the write register service. Im still having no luck with that.

Thanks for your time!

cancel that I can now successfully use the write register service and thats all I need!

thanks again

1 Like

Excellent. I’ve never used Modbus but read this topic and tried to find a solution as an exercise as I may soon have to use it to connect to a solar inverter. I’ll be using TCP rather than serial though.

Cool, hope you have an easier time than I had! I might try TCP next time too.

I also knew nothing about modbus up until yesterday but learned a lot in the process!

1 Like

Hi,

I also have alnor ventilation, I want to configure it via rs485.
Could you post your full configuration?