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.
266 stars 23 forks source link

timestamp_property for single-item entities #67

Open Syntoxr opened 3 years ago

Syntoxr commented 3 years ago

Hi, I think it would be handy to be able to use the timestamp_property in single-item entities because:

I already achieved this by using the multi-item entity with only one entry and a sensor which attributes are formatted correctly, but this is a rather complicated way.

So, if you have a bit of spare time and want to add this, I would be happy. Thank you for your work so far :+1:

kiloptero commented 1 month ago

I already achieved this by using the multi-item entity with only one entry and a sensor which attributes are formatted correctly, but this is a rather complicated way. // HOW?

Syntoxr commented 1 month ago

@kiloptero

card config:

  - entity: sensor.notify_window
    multiple_items: true
    list_attribute: attributes
    timestamp_property: created
    max_items: 5
    content_template: '{{message}}'

Sensor attributes:

attributes:
  - message: The upstairs bathroom window is closed again
    created: "2024-05-14T01:06:00"
icon: mdi:border-all
friendly_name: notify-window

The sensor is created and updated via Node-Red:

function node for formatting:

const message = "The upstairs bathroom window is closed again";

msg = {
  "message":message,
  "payload":{
    "attributes":{
      "attributes": [
        {
          "message": message,
          "created": global.get("time_iso")
        }
      ]
    }
  }
}

return msg;