MODBUS TCP/IP write multiple registers

hi, i would like to write in multiple registers with funtion code 16 (0x10) some values (integer 16 bit signed).
for example:
I need to write this:
address 28301 value 1
address 28302 value 1
address 28303 value 6

I expect an output packet formatted like this (HEX):
[TCP]>Tx > 13:30:07:747 - 00 01 00 00 00 0D 01 10 6E 8D 00 03 06 00 01 00 01 00 06

10 → function code
6E 8D → Starting address (28301 in HEX)
00 03 → quantity of register
06 → byte count
00 01 00 01 00 06 → value

I try to set that in the service tool to development area in Home assisistan:

service: modbus.write_register
data:
  hub: modbustcp1
  address: 28301
  unit: 1
  value:
    - 1
    - 1
    - 6

but it doesn’t work…
P.S. I can read all the registers with sensor whitout any problems

Can anyone help me?

service: modbus.write_register
data:
  address: <target register address>
  unit: <target slave address>
  hub: <hub name>
  value: [0x4120, 0x0000]

tankyou for the answere, but it’s the same to this, and doesn’t work:

service: modbus.write_register
data:
  address: <target register address>
  unit: <target slave address>
  hub: <hub name>
  value: 
    - 16672
    - 0

Is this for a fancoil? I am trying to send commands to it and I can’t make it. I am asking because the addresses and integers are the same with what I am tying to do.

Yes it is. I solved it by creating scripts like this:

alias: Velocità 1 climatizzatore camera
sequence:
  - service: modbus.write_register
    data:
      hub: modbustcp1
      address: 28301
      unit: 3
    data_template:
      value:
        - 1
        - "{{states('sensor.modalita_climatizzatore_camera')}}"    
        - 2
mode: queued
max: 10
icon: mdi:fan-speed-1

I also had the problem that too many calls to the sensors saturated the line

2 Likes

I just found that my fan coil (Phnix is the maker) accepts writes with function code 10. That means that instead of write_type: holding I have to put write_type: holdings

From HA documentation

image

      - name: "Phnix Living Room ON/OFF"
        unique_id: phnix_living_room_on/off
        slave: 15
        address: 28301
        command_on: 1
        command_off: 0
        scan_interval: 10
        write_type: holdings        
        verify:

Of course I am not finished yet, I have to find out how to make the fan speed adjustments, set temperatures etc.
Also there is a big delay on my commands…

Ciao!!!
Ho gli stessi indirizzi tuoi per il mio fancoil, di che marca è il tuo? perché il mio è della IdealClima ma effettivamente non ha tanti registri da poter leggere, per esempio la funzione ventilazione non mi va.

Hi, I’m also working on the ideal clima fan coils and I’m having a lot of problems writing the registers. If you have information, please share, I’ll share mine. Thank you.