Modbus Sensor Configuration is deprecated

I’m looking at upgrading my HA from mid 2021, but there are so many breaking changes since then! I need to prepare a fix or something for everything before the upgrade.

I’m getting the following deprecation message about my Modbus sensors… Can anyone show me what the new config should be? I tried to restructure the YAML as per the documentation but couldn’t get it working (Modbus - Home Assistant).

Logger: homeassistant.components.modbus.sensor
Source: components/modbus/sensor.py:111
Integration: Modbus (documentation, issues)
First occurred: July 24, 2023 at 9:53:48 AM (2 occurrences)
Last logged: July 24, 2023 at 9:53:48 AM

Sensor configuration is deprecated, will be removed in a future release

Here’s a sample of my current config:

modbus:
  - name: SI6
    type: tcp
    host: 192.168.1.2
    port: 502

  - name: SB5
    type: tcp
    host: 192.168.1.3
    port: 502

# Sensors
sensor:
  - platform: modbus
    scan_interval: 3
    registers:
      - name: SMA Solar Total
        hub: SB5
        unit_of_measurement: MWh   # see register description in section 5.4.1 of document
        slave: 3                   # use the UnitID you found in Sunny Explorer
        register: 30531            # use a register from section 5.4.1 of the document
        register_type: input       # all registers starting with 3 need to have the type input
        count: 2
        data_type: int
        scale: 0.001
        precision: 3

      - name: SMA Solar Day Total
        hub: SB5
        unit_of_measurement: kWh   # see register description in section 5.4.1 of document
        slave: 3                   # use the UnitID you found in Sunny Explorer
        register: 30517            # use a register from section 5.4.1 of the document
#        register_type: input       # all registers starting with 3 need to have the type input
        count: 4
        data_type: int
        scale: 0.001
        precision: 3

  - platform: modbus
    scan_interval: 3
    registers:

      - name: SMA Generator Warmuptime
        hub: SI6
        slave: 3
        register: 40571
        unit_of_measurement: ''
        precision: 0
        count: 2
        data_type: uint

As example: