Picture Elements & State Image

Please, for the sake of hundreds of lines of code, there has to be a way!!

I have a couple Picture Element cards that I use on a visual display to show various thermostats throughout my house, but I have a custom typeface for the temperature values. Specifically, I have 99 png files, each being a number, with a portion of the card the card setup like this

  - type: image
    entity: sensor.pngfmt_lvngrm_temp_act
    state_image:
      01: /local/images/thermostat/numbers/01.png
      02: /local/images/thermostat/numbers/02.png
      03: /local/images/thermostat/numbers/03.png
        ....
      97: /local/images/thermostat/numbers/97.png
      98: /local/images/thermostat/numbers/98.png
      99: /local/images/thermostat/numbers/99.png

(I deleted the rows for #'s 4-96 for this example, but they’re in my layout).

Is there a way I can create a script or something on the backend that will essentially represent these 99 rows, and in my layout, instead of having these 99 rows, I can just reference that? I’m thinking of creating a master thermostat layout that includes 6 thermostats (both integrations and generic thermostats), and with two temperature values for each thermostat, I’d much rather not have 12 instances of the 99 rows.

Thanks!

First thought came into my mind - you can specify these 99 lines for one card, then use a yaml anchor in other places.
These cards should be located in one file. If they are located in different files then anchors will not work - place these 99 lines into a separate file then use “include”.

Regarding maintaining these 99 lines. You may create a template fir generating these lines and keep this template in some file. Whenever you want to change something (filenames’ pattern etc) paste this template into the Developer tools → Template and then copy the generated code and paste into appropriate file.