How to configure lots of I/O Pins, Ports, etc

I am wondering if there is an alternative to the individual definitions of ports like this one:

# Example configuration entry
sn74hc165:
  - id: sn74hc165_hub
    clock_pin: GPIO16
    data_pin: GPIO17
    load_pin: GPIO4
    clock_inhibit_pin: GPIO18
    sr_count: 2

# Individual inputs
binary_sensor:
  - platform: gpio
    name: "SN74HC165 Pin #0"
    pin:
      sn74hc165: sn74hc165_hub
      # Use pin number 0
      number: 0
      inverted: false
  - platform: gpio
    name: "SN74HC165 Pin #1"
    pin:
      sn74hc165: sn74hc165_hub
      # Use pin number 1
      number: 1
      inverted: false

This copy&paste definition gets old pretty quickly. Envision deploying the maximum of 256 Shift registers * 8 ports.

Would it be an option to define this in a for loop i.e. in a lambda?

No you can’t template configuration, only values.

Yaml anchors may help, otherwise - cut and paste.

Hello
I cannot find cloch_inhibit_pin on 74hc165 chip ?

Pin 15 of the IC according to the datasheet.
https://www.ti.com/lit/ds/symlink/sn74hc165.pdf
Screenshot 2023-12-23 at 08-38-27 SNx4HC165 8-Bit Parallel-Load Shift Registers datasheet (Rev. H) - sn74hc165.pdf

I’ve found AI who shall not be named very good at extending a repeating code pattern like this… E.g give it 0 and 1 and tell it to do it up to 20 etc.

:face_with_raised_eyebrow: