Hello. I don’t know if this is the right category but I got a question regarding “programming” in YAML.
So I’m using this code for a fuel app named “Tankerkoenig” that somebody created:
type: markdown
content: >-
# E5: {% for entity in expand('group.all_fuel_sensors') |
sort(attribute='state') | map(attribute='entity_id') | map('string') | list
%}
{% if 'Shell' in state_attr(entity, "station_name") %}
![Image](/local/shell.png)
{% elif 'JET' in state_attr(entity, "station_name") %}
![Image](/local/JET.png)
{% endif %}
{{state_attr(entity, "station_name")}}
## {{states(entity) }} €
***
{% endfor%}
I have no clue what kind of programming language that is. I’ve read something about python and jinja2. The syntax also seems to be “special”.
What I want to achieve is that the 5th character is smaller than the other ones. But I have no idea where to begin. Currently, it looks on the right side of the image here with the current price in numbers and a manually added € sign:
It is markdown with jinja2 templates in it. state_attr and such are defined by Home Assistant: Templating - Home Assistant
Which character do you want to make smaller? The € sign? You should be able to use standard HTML syntax for that.
type: markdown
content: >-
# E5: {% for entity in expand('group.all_fuel_sensors') |
sort(attribute='state') | map(attribute='entity_id') | map('string') | list
%}
{% if 'Shell' in state_attr(entity, "station_name") %}
![Image](/local/shell.png)
{% elif 'JET' in state_attr(entity, "station_name") %}
![Image](/local/JET.png)
{% endif %}
{{state_attr(entity, "station_name")}}
## {{states(entity) }} <small>€</small>
***
{% endfor%}
Thank you. I was searching for the templating site. No, I want to make the last character of the entity string small. So I guess I need a rewriting. But I don’t know how to do this with jinja2. Just found something for Python.
What this does is rounds that last digit off, then extracts it by reversing the value as a string and truncating it. There may need to be an additional conversion in there if you get an error, I am not sure if the state is a string or an integer
You can also do <small><small> to make it even smaller
just keep chaining them until you get the desired size, I think <small><small><small> looks pretty good, that part is not actually jinja, since it is outside the braces, it is just standard html at that point