All languages are hard to learn if you donāt already know something about them. They all have rules and you have to follow them to be understood.
The Jinja docs says this about it:
Jinja is a fast, expressive, extensible templating engine. Special placeholders in the template allow writing code similar to Python syntax. Then the template is passed data to render the final document.
Jinja, like most programming languages use non-alphanumeric characters and punctuation to indicate structure and doesnāt care about blank space as much.
YAML says this about itself
What It Is:
YAML is a human-friendly data serialization
language for all programming languages.
YAML uses blank space to structure things. This makes the look of the text follow the structure, which also means you have to get it exactly right. This is hard to do, unless you are using an editor that helps you with that.
Years ago when I was looking at what to use for settings/configuration for a project, I discarded YAML beacuse blank space is SO important and also SO hard to do without proper editor support. I ended up using JSON, which I thought did a good job of balancing the many requirements with ease of use. Years later after spending much time with Python, I have come to appreciate the value of using blank space to indicate structure. It forces you to write configs that show the structure, but letās you do it in fewer vertical lines than the equivalent JSON.
Like most things, you have to learn the tools to get the results you want. Some tools are easy to use (probably because you already learned how to use them someplace/time else). Some tools are easy to remember how to use, once you learn them (like riding a bike). I donāt use Jinja enough to remember the syntax and therefore have to look at examples to figure out how to express what I want. If there is not example that is close, this can be hard, but I donāt believe that it is Jinja that is making it hard.
YAML is great for simple things. It is much less great for very complicated things and understanding the rules can be challenging when you need to use YAML to hold something that needs to use the special characters that YAML uses.
Here is an example:
I have a presence sensor in my bathroom and I want to use it to make my bathroom floor heater turn off when I leave. This sounds simple and it should be, but it really isnāt. It takes the floor a long time to heat up, so while I can turn it off when I leave, turning it on when I arrive wonāt have much impact (since it takes tens of minutes to change the temperature much). But, letās just use the simple thing of changing the thermostat set point when I leave.
The UI has a decent WHEN and it gives me a friendly GUI way of selecting the sensor I want and that it has stopped detecting motion. That was easy. I didnāt need any And if for this one. That just leaves Then do. For this I had to figure out Jinja templates and I got this:
service: climate.set_temperature
metadata: {}
data:
temperature: "{{ states('input_number.floor_current_vacant_temp') | int }}"
target:
device_id: e61a8edb3abd68cacbfd9de928199ff2
Jinja uses delimiters to indicate which things Jinja should process and which things it should leave alone. Since it is a templating engine, this makes sense (assuming you know what the purpose of a templating engine is). It is also a very powerful templating engine and closely aligned with Python, which is likely why it is used in HA (which is also closely aligned with Python). Note that it appears that Jinja was not designed to be used by someone who knows nothing about programming concepts. I also personally find the documentation on the Jinja site to be much less than easily understandable. The documentation in HA for Jinja2 and templates is equally dense and hard to understand (unless you already know it).
So, for me, I think the real problem is not so much Jinja2 but rather there is very little good documentation on using Jinja2 to achive actual results. Tutorials that go beyond the āhello worldā and into more real life examples are needed. I searched for and found examples on the internet (some in the forums here) that helped me get a basic enough understanding, but I also recall it being hard and requiring a large investment in time.
I started using HA because it does allow some more complicated automations and supports a lot of different systems, but it does require some effort to get it all working.