gadgetchnnel / lovelace-home-feed-card

A custom Lovelace card for displaying a combination of persistent notifications, calendar events, and entities in the style of a feed.
275 stars 24 forks source link

Not extracting attribute values #55

Closed Gamelauncher closed 3 years ago

Gamelauncher commented 3 years ago

I have a sensor with some attributes but whatever I do, I don't get the correct values displayed.

Screen Shot 2020-10-31 at 12 16 55

      - id: alarm_events_feed
        type: "custom:home-feed-card"
        title: Events
        show_header_toggle: false
        compact_mode: true
        entities:
          - entity: sensor.event_c2be08
            name: Events
            content_template: '{{ state }}'
            include_history: true
            max_history: 5
            remove_repeats: false

I've tried setting to the content_template to '{{ states.sensor.event_c2be08.attributes["time"] }}' but it won't display anything, not even with '{{state}}'.

Any idea on how I can extract the attribute values?

GrandadEvans commented 3 years ago

Have you tried

content_template '{{time}}'

I'm having a similar problem, but I haven't worked with just times before, so not sure if it will work or not, but the idea is here for the record. John

gadgetchnnel commented 3 years ago

Full Jinja templating ins't supported in the content_template, but in 0.6.0 I added the attribute option so you can use an attribute instead of the state for an enity. So you would use something like

  - id: alarm_events_feed
    type: "custom:home-feed-card"
    title: Events
    show_header_toggle: false
    compact_mode: true
    entities:
      - entity: sensor.event_c2be08
        name: Events
        attribute: time
        content_template: '{{ state }}'
        include_history: true
        max_history: 5
        remove_repeats: false