Markdown problem

Having these attributes in an entity:

54

And configuring a markdown card like this:

type: markdown
content: |
    ## Snapshots      
          
    Last Snapshot: [[ sensor.snapshot_backup.attributes.last_snapshot ]]

    Snapshot in GDrive [[ sensor.snapshot_backup.attributes.snapshots_in_google_drive ]]
                        
    Snapshot in Hassio [[ sensor.snapshot_backup.attributes.snapshots_in_hassio ]]
                        
    Snapshot [[ sensor.snapshot_backup.attributes.snapshots ]]

Why i get this in lovelace UI?

24

How to get the proper attributes in UI?

You’re geting exactly what you told it, which is the object itself. What are you trying to get from it? All 3 attributes? If so, you need code it out to get them all using templates. Something like

{%- for sh in sensor.snapshot_backup.attributes.snapshots %}
- name: {{ sh.name }}
  date: {{ sh.date }}
  time: {{ sh.state }}
{%- endfor %}
1 Like

small typo:

{%- for sh in states.sensor.snapshot_backup.attributes.snapshots %}
  - name: {{ sh.name }}
    date: {{ sh.date }}
    time: {{ sh.state }}
{%- endfor %}

even better for me (don’t like the timestamps):

{%- for sh in state_attr('sensor.snapshot_backup','snapshots') %}
  - name: {{sh.name }}
    date: {{as_timestamp(sh.date)|timestamp_custom('%d %b: %X') }}
    time: {{sh.state }}
{%- endfor %}

is wat I use.

Hmmm, maybe i am not so good with templates, but i get:

20

frontend, stripped to its bare necessities:-)

36

with the above code…

Well, now, how i can get something like that?

of course :wink:

what happens if you enter the template in the template editor?

this is my full code for an include:

type: horizontal-stack
cards:

  - type: custom:button-card
    template: horizontal-filler

  - type: markdown
    style: |
      ha-card {
      background: 'var(--paper-card-background-color)';
      }
    content: >
      Snapshots
      {%- for sh in state_attr('sensor.snapshot_backup','snapshots') %}
        - name: {{sh.name }}
          date: {{ as_timestamp(sh.date)|timestamp_custom('%d %b: %X') }}
          time: {{ sh.state }}
      {%- endfor %}

  - type: custom:button-card
    template: horizontal-filler

In template editor i get the right response, but using the same card you use i still don’t get the right values…

you might not have my horizontal-filler… only use the - type: markdown bit? Maybe even take out the style section to be sure.

 - type: markdown
    content: >
      Snapshots
      {%- for sh in state_attr('sensor.snapshot_backup','snapshots') %}
        - name: {{sh.name}}
          date: {{as_timestamp(sh.date)|timestamp_custom('%d %b: %X')}}
          time: {{sh.state}}
      {%- endfor %}

My card is:

                  - type: markdown
                    style: |
                      ha-card {
                      font-size: 14px;
                      font-family: 'Times New Roman';
                      font-weight: bold;
                      }                                    
                    content: >
                      {%- for sh in state_attr('sensor.snapshot_backup','snapshots') %}
                        - name: {{sh.name }}
                          date: {{as_timestamp(sh.date)|timestamp_custom('%d %b: %X') }}
                          time: {{sh.state }}
                      {%- endfor %}

But don’t get what you get…

latest version of the card mod?

no errors in the inspector?

copied your code and this it what’s showing:

00

It’s really strange as when reloading the card for a moment i get what i want, but then it comes again like i show you… card-mod is the latest.
In inspector i get these errors but i don’t think they are related

edited it a bit, try this for now without the style:

      - type: markdown
        content: |
          Snapshots
          {%- for sh in state_attr('sensor.snapshot_backup','snapshots') %}
            - name: {{sh.name}}
              date: {{as_timestamp(sh.date)|timestamp_custom('%d %b: %X')}}
              time: {{sh.state}}
          {%- endfor %}

fixed it on this side:

21

with your style:
27

You’ve got to be precise not to leave trailing spaces, and also use the spacing in the stacks/configs themselves. Markdown is really exact in what you feed it.

check this for some old-school Markdown:

No way…

Meaning? It’s ok now?

No, always same look…

bummer., don’t know what to say really, maybe the HA version itself? Do you have other markdown card issues? Markdown has been updated, but I think it has been a while.

Yes, i have other markdown cards that work as expected…
Still having this:

05

just to be sure, create a new tab with only this card. Ruling out any other interference of another card in the same view.

Still seems to be the old Markdown, not recognizing Jinja templates… what HA version are you on? .98 updated the Markdown: 0.98: Improved entity management, options and Home Assistant Alerts

1 Like

It’s what i am doing now… i am running 0.101.3 with hassio.