Enumerating sensors to create template sensors

Hi all,

I have a basic sensor templated and am changing icon based on state. I’m struggling to get started on templating the sensor creation by enumeration.

My configuration.yaml defines a number of asterisk extensions via the following:

ast_ext:
  host: 192.168.[REDACTED]
  port: 5038
  username: !secret asterisk_ami_username
  password: !secret asterisk_ami_password
  extension:
  - 2001
  - 2010
  - 2020
  - 2030

The python data collector code generates a number of sensors with _[extension] as the suffix.

Is it possible to generate a corresponding template sensor for each of the extensions? The extension number is always numeric, but could be anywhere between two and six numbers.

Thanks in advance.

All best,
Chris.