How to create Dynamic SNMP sensor and Switch list

How to create a dynamic list of multiple items instead of adding each sensor and switch individually in yaml?

I have multiple items:

  - platform: snmp
    name: "energy_rack_1"
    baseoid: .1.3.6.5.1

to

  - platform: snmp
    name: "energy_rack_10"
    baseoid: .1.3.6.5.10

Thanks.

There is no provision to do this. You will have to create each one. Copy and paste should make short work of it.

What about a script that creates the relevant yaml file that i can then point to in the configuration?

Sure if you feel that writing a Python script or other external program to construct the file for you would be less effort, then go for it. Home Assistant will have to be restarted after you update the file.

If you mean a Home Assistant script, then no.