Write Modbus TCP 4byte 32int register

Hello,

i want to write a Modbus Register using the Modbus Integration. The datatype is 32int. I can read the register with the following sensor settings:

input_type: holding
count: 2
data_type: int32

The value i want to change is in the second register as far as i assume.

There is no Problem in writing to Registers with 2 bytes. How do i have to write the value?

Thx

1 Like

You use the write register service, see: Modbus - Home Assistant

Thanks. I know how to use that service. I already used it to write a single register (2byte, datatype int16), which works perfectly. But it doesn’t work when i am trying to write a 4 byte register with datatype int32.

Adress, variable, read or write, Data format, Data model.

1 Like

No One an idea?

This is how iset the local time on my inverter using modbus. It’s a uint32 value:

alias: Sync klok Inverter1
trigger:
  - platform: time
    at: "14:00:00"
action:
  - service: modbus.write_register
    data:
      hub: modbusdevice
      unit: 2
      address: 40000
    data_template:
      value:
        - >-
          {{ ((as_timestamp(now()) + 7200) | round(0) | float / 65536) |
          round(0, "floor") | int }}
        - >-
          {{ ((as_timestamp(now()) + 7200) | round(0) - ((as_timestamp(now()) +
          7200) | round(0) | float / 65536) | round(0, "floor") * 65536) | int
          }}
mode: single