Selecting values and updating via modbus

I successfully read values from my boiler by adding this code to my modbus.config:

  - name: modbus_kwb
    type: tcp
    host: 192.168.11.21
    port: 502
    sensors:
    - name: Heizkreis_Programm
      slave: 1
      address: 24589
      input_type: holding
      state_class: measurement
      data_type: int16
      precision: 1
      scale: 1

i successfully managed to show text intstead of integers with a template named select.heizkreis.

it presents the current state correctly with:

{{ [ 'Automatik',
     'Frostschutz',
     'Aus',
     'Komfort',
     'Absenk'][states('sensor.heizkreis_programm')|int] }}

it prepares the options of the selection correctly with:

{{ [ 'Automatik',
     'Frostschutz',
     'Aus',
     'Komfort',
     'Absenk'] }}

what kind of actions do i need to add to write the selected value (an integer from 0 to 4) into the corresponding modbus register?

You’ll be using the modbus write_register actions. You can make a template select entity that does all the work for you.