type: markdown
content: >-
# Diesel:
{% for entity in expand('group.all_fuel_sensors') | sort(attribute='state') |
map(attribute='entity_id') | map('string') | list %}
{% if 'ZG' in state_attr(entity,'station_name') %}
![Image](/local/img/ZG.png)
{%elif 'bft' in state_attr(entity,'station_name') %}
![Image](/local/img/bft.png)
{%elif 'Vimbuch' in state_attr(entity,'station_name') %}
![Image](/local/img/bft.png)
{%elif 'Aral' in state_attr(entity,'station_name') %}
![Image](/local/img/Aral.png)
{% endif %}
{{ state_attr(entity,'station_name') }}
{% if 'unknown' in states(entity) %}
## Geschlossen
{% else %}
## {{ states(entity) }} €
{% endif %}
***
{% endfor %}
Now I want to get this shown in a table which is like:
| Icon | Name of gas station | price |
How is it possible, to get the results in the for loop formated to be table rows?
Do I have to push the results into variables and print them at the end? The table should be sorted at the end?
I am a new in home assistant and having no clue how to proceed here.
Thank you, that looks great also. I want to add an additonal column for the price of e10 of the stations. the name of of the sensor is the same, but has the suffix _e10 instead of _diesel. Do you have an idea how I could get this addes?
Given this a bit more thought… I doubt that one can put both diesel and e10 on the same line for the same station UNLESS these are in a single entity.
Else, on a db level as example, you would need grouping on station name and put value 1 in column A and value 2 in column B, or do a join… but I have not yet seen this type of actions for a card …which does not mean that it does not exist.
Maybe with a markdown this could work
sort all objects on name and petrol type
run through them 1 by 1, if previous name is not current name then print data in column A (name) , column B (price1) else in column C (price2)
This is doable but I donot see me doing this (timewise and lack of data)
EDIT: or… you have to write a jonja code combining both sensors in a sable and then another one splitting them out…if you really need this then I suggest to go to the discord forum on templates…there are some great wizards out there,you’d have to provide the data and an example of course, be very specific with the question
Thank you very much again. Of course I do not want to write you the code, the hints are all I need. At the moment I have no idea what to search for. At the moment I try to sort out for me, when using using which language oder formating and what I can do there.
Your last thought is, what I think would be the best, I will go for this approach. I will print the code here, when I figured it out
I can share this with you as markdown iterating through data, not sure if it will help.
it iterates through a list of objects (dates)
if date[i] <> date[i-1) . [if date now is not equal to previous date ]
then print previous sensor subject and previous aqname
else print current sensor subject and aqname