I’m wondering, if it’s possible to shorten such a long list of entities. E.g, loop some ${num} variable that changes from 1 to 16, so that this all would be templated as (pseudocode):
Home Assistant process YAML first then Jinja2 second therefore you cannot use Jinja templating to generate YAML within configuration.yaml. More information here.
What you can do is use Jinja2 templating in the Template Editor to generate YAML, then copy the generated YAML into configuration.yaml (see example). It’s up to you to decide if that’s faster than creating a single entity’s configuration and then copy-pasting it to create other entity configurations.
When I compared the result with the previous file written manually, I even found some small errors/typos I had.
So, templating (even such one done with bash) itself is a great thing that helps to avoid errors. And it’s a pity that it can’t be done with configuration files…
Unless of course the bash script that generates YAML contains an error …
Regardless of the chosen programming language (bash script, Jinja2, python, etc), there are pros and cons to creating YAML- generating code. The time needed to compose and test the code may be longer than simply copy-pasting a few blocks of YAML.
For future projects, you may wish to familiarize yourself with the concept of YAML Anchors and Aliases. I posted an example here: