n the code is repeating css parts…
i am trying with anchor but I could noct make it work
type: picture-elements
image: local/png/rollo_uebersicht_v7.png
dark_mode_filter: invert(100%)
elements:
- type: state-icon
entity: cover.strasse
state_color: true
style:
top: 76%
left: 84%
'--mdc-icon-size': 40px
card_mod:
style: |
state-badge::after {
content: "{{ (states.cover.strasse.last_changed | as_local).strftime('%d.%m %H:%M') }}"
}
state-badge {
white-space: nowrap;
display: flex;
flex-direction: column;
row-gap: 0px;
align-items: center;
font-size: 12px;
line-height: 0px
}
- type: state-icon
entity: cover.rollo_ecke
state_color: true
style:
top: 27%
left: 8%
'--mdc-icon-size': 40px
card_mod:
style: |
state-badge::after {
content: "{{ (states.cover.rollo_ecke.last_changed | as_local).strftime('%d.%m %H:%M') }}"
}
state-badge {
white-space: nowrap;
display: flex;
flex-direction: column;
row-gap: 0px;
align-items: center;
font-size: 12px;
line-height: 0px
}
- type: state-icon
entity: cover.rollo_mitte_links
state_color: true
style:
top: 27%
left: 25%
'--mdc-icon-size': 40px
card_mod:
style: |
state-badge::after {
content: "{{ (states.cover.rollo_mitte_links.last_changed | as_local).strftime('%d.%m %H:%M') }}"
}
state-badge {
white-space: nowrap;
display: flex;
flex-direction: column;
row-gap: 0px;
align-items: center;
font-size: 12px;
line-height: 0px
}
I tried this:
type: picture-elements
image: local/png/rollo_uebersicht_v7.png
dark_mode_filter: invert(100%)
elements:
- type: state-icon
entity: cover.strasse
state_color: true
style:
top: 76%
left: 84%
'--mdc-icon-size': 40px
card_mod:
style: &common_style |
state-badge {
white-space: nowrap;
display: flex;
flex-direction: column;
row-gap: 0px;
align-items: center;
font-size: 12px;
line-height: 0px;
}
state-badge::after {
content: "{{ (states.cover.strasse.last_changed | as_local).strftime('%d.%m %H:%M') }}"
}
- type: state-icon
entity: cover.rollo_ecke
state_color: true
style:
top: 27%
left: 8%
'--mdc-icon-size': 40px
card_mod:
style: |
*common_style
state-badge::after {
content: "{{ (states.cover.rollo_ecke.last_changed | as_local).strftime('%d.%m %H:%M') }}"
}
- type: state-icon
entity: cover.rollo_mitte_links
state_color: true
style:
top: 27%
left: 25%
'--mdc-icon-size': 40px
card_mod:
style: |
*common_style
state-badge::after {
content: "{{ (states.cover.rollo_mitte_links.last_changed | as_local).strftime('%d.%m %H:%M') }}"
}
Do you have a hint what way should I go to replace the repeated elements?
Chatgpt proposes a nice looking version (only one problem it does not work -:))
type: picture-elements
image: local/png/rollo_uebersicht_v7.png
dark_mode_filter: invert(100%)
elements:
{% set common_style = {
'color': 'grey',
'white-space': 'nowrap',
'display': 'flex',
'flex-direction': 'column',
'row-gap': '0px',
'align-items': 'center',
'font-size': '12px',
'line-height': '0px'
} %}
{% set common_card_mod_style = common_style | map('join', ': ') | join('; ') %}
{% set icon_style = {
'top': '%%%',
'left': '%%%',
'--mdc-icon-size': '40px'
} %}
{% set entities = [
{'entity': 'cover.strasse', 'top': '76%', 'left': '84%'},
{'entity': 'cover.rollo_ecke', 'top': '27%', 'left': '8%'},
{'entity': 'cover.rollo_mitte_links', 'top': '27%', 'left': '25%'}
] %}
{% for item in entities %}
- type: state-icon
entity: {{ item.entity }}
state_color: true
style:
top: {{ item.top }}
left: {{ item.left }}
'--mdc-icon-size': 40px
card_mod:
style: |
state-badge::after {
content: "{{ (states['{{ item.entity }}'].last_changed | as_local).strftime('%d.%m %H:%M') }}"
}
state-badge {
{{ common_card_mod_style }}
}
{% endfor %}