1. install diagslave

2. enable modbus and create sensors

vi /config/configuration.yaml
///
modbus: !include_dir_merge_list modbus/
mkdir -p /config/modbus/
vi /config/modbus/diagslave.yaml
#
- name: diagslave
  type: tcp
  host: 127.0.0.1
  port: 502
  delay: 0
  timeout: 5

  sensors:

    - name: diagslave_1001
      unique_id: diagslave_1001
      slave: 1
      address: 1001
      scan_interval: 5

    - name: diagslave_1002
      unique_id: diagslave_1002
      slave: 1
      address: 1002
      scan_interval: 5
ha core restart

3. create max current sliderbar

Settings -> Devices & services -> Helpers -> Number

./pic/max_current.png

4. create dashboard

Edit dashboard -> hamburger -> Raw configuration editor
views:
  - title: Home
    cards:
      - type: entities
        entities:
          - entity: sensor.diagslave_1001
          - entity: sensor.diagslave_1002
          - entity: input_number.max_current

5. create service

Tip diagslave is the name as defined in /config/modbus/diagslave.yaml

6. create automation rule

Services -> Automations & scenes -> + CREATE AUTOMATION -> Create new automation
ADD TRIGGER -> Entity -> State -> Entity -> max_current
ADD ACTION -> Call service -> Modbus: Write register
  -> Address 1001
  -> Slave 1
  -> Value "{{ states('input_number.max_current') }}"
  -> Hub diagslave
SAVE
cat /config/automations.yaml
- id: '1708906321534'
  alias: max_current
  description: ''
  trigger:
  - platform: state
    entity_id:
    - input_number.max_current
  condition: []
  action:
  - service: modbus.write_register
    data:
      hub: diagslave
      address: 1001
      slave: 1
      value: '{{ states(''input_number.max_current'') }}'
  mode: single