Lovelace: Home Feed Card

You are right! Thank you!

I have now released a new Beta version, 0.3.0b1. This is a fairly experimental release with a few new features:

  • A compact_mode option, which displays the time to the right of the feed item instead of underneath. This also removes dismiss button from notifications, so these become clickable (refer to the more_info_on_tap changes).
  • Expand more_info_on_tap to work with calendar events, multi-item entities (requires new detail_template option), and notifications. If compact_mode is enabled this will also make notifications clickable/tappable (regardless of more_info_on_tap setting) to allow them to be dismissed from the feed.
  • A detail_template option for multi-item entities. This uses the built-in Markdown card meaning that full Jinja2 templating can be used. The item properties can be used in the Jinja2 template via the config.item property

Here is an example of a Reddit sensor in the feed, making use of Jinja2 templating with the config.item property:

- entity: sensor.reddit_homeassistant
  content_template: '{{title}}'
  detail_template: >
    {% if config.item.body != "" %}
      {{ config.item.body }}
    {% else %}
      {% if config.item.url.endswith(".jpg") or config.item.url.endswith(".png") %}
        ![{{ config.item.title }}]({{ config.item.url }})
      {% else %}
        [{{ config.item.title }}]({{ config.item.url }})
      {% endif %}
    {% endif %}
    
    
    [View on Reddit](https://www.reddit.com/r/homeassistant/comments/{{config.item.id }})
   
  list_attribute: posts
  max_items: 10
  multiple_items: true
  timestamp_property: created_utc

Here is an example of what the extended more_info_on_tap support looks like with a notification:

and here is an example of a calendar event

This is how it shows with the beta.

Auswahl_214

                      service: browser_mod.command
                      service_data:
                        command: popup
                        title: Persistent Notifications
                        style:
                          border-radius: 15px
                          width: 500px
                          background: rgba(38, 49, 55, 0.8)
                          color: var(--my-orange)
                        card:
                          type: custom:home-feed-card
                          #title: Home Feed
                          show_empty: false
                          show_notification_title: true
                          style: |
                            ha-card {
                              background: transparent;
                            }
                        deviceID:
                          - this

The issue with the <hr> element is fixed now in 0.3.0b2. I’d been doing a lot of testing in compact mode and hadn’t noticed that the changes had broken that in non-compact mode.

The other thing in your screenshot, with the notification title showing null, I assume that this is a notification without a title. Did they show like that in the previous version?

Thanks for the fix. :+1:
The null title is not a problem, only a quick notification without title for testing.

This is a really promising card, great work! I have what seems like a slightly different use case, I wanted to ask if there was any way to achieve this. I’d like to use this as part of my security system to look at the last (let’s say 10) events that have happened around the house, like which motion sensors were triggered, which doors were opened, etc…

But rather than list all my entities and see the last event for each and every one of them, I’d like to tell them to the card, and have the card tell me what the last 10 events were in reverse chronological order, even if 4 of them were from the same entity and 6 were from another entity and the rest of the entities didn’t have any… Like:

11:35 - Front door open
11:33 - Motion in the hallway
11:32 - Motion in the bathroom
11:31 - Motion in the living room
11:30 - Motion in the hallway
11:28 - Motion in the living room
…etc…

Is this at all even theoretically possible?

I think you may be able to do this by using something like this:

type: 'custom:home-feed-card'
id_filter: ^nothing.*
max_item_count: 10
entities:
  - entity: binary_sensor.front_door
    include_history: true
    exclude_duplicates: false
    exclude_states:
      - "off"
  - entity: binary_sensor.hallway
    include_history: true
    exclude_duplicates: false
    exclude_states:
      - "off"

The max_item_count option will make it only include the last 10 items, having exclude_duplicates as false will disable the filtering out of duplicated entries for the same entity, the exclude_states will filter out “no motion” or “door closed” states and the id_filter should mean that it won’t include any persistent notifications (unless one has a notification id starting with “nothing”.

1 Like

Cool, thanks! But wouldn’t it still list everything for the front door first and then everything for the hallway next, like:

Front door:
11:58 open
11:33 closed
11:22 open

Hallway:
11:44 motion
11:30 motion
11:20 motion

Rather than how I want which is:
11:58 Front door open
11:44 Hallway motion
11:33 Front door closed
11:30 Hallway motion
11:22 Front door open
11:20 Hallway motion

Anyhow, I will give it a try and see what happens!

If this card can’t do what you want then this may be a solution…

first you need to create a variable entity using a custom component (https://github.com/rogro82/hass-variables):

variable:
  last_motion:
    value: 'Not set'
    restore: true
    attributes:
      icon: mdi:map-marker
      name: 'Last Motion'

Then create an automation to populate the variable:

- alias: 'Update Last Motion'
    initial_state: 'on'
    trigger:
      - platform: state
        entity_id:
          - binary_sensor.comp_rm_motion_template
        to: 'on'
      - platform: state
        entity_id:
          - sensor.computer_room_camera_motion
          - sensor.livingroom_camera_motion
          - sensor.diningroom_camera_motion
          - sensor.garage_camera_motion
          - sensor.kitchen_camera_motion
          - sensor.deck_camera_motion
        to: 'Detected'
    action:
      service: variable.set_variable
      data:
        variable: last_motion
        attributes_template: >
          {
            "history_1": "{{ variable.state }}",
            "history_2": "{{ variable.attributes.history_1 }}",
            "history_3": "{{ variable.attributes.history_2 }}",
            "history_4": "{{ variable.attributes.history_3 }}",
            "history_5": "{{ variable.attributes.history_4 }}",
            "history_6": "{{ variable.attributes.history_5 }}",
            "history_7": "{{ variable.attributes.history_6 }}",
            "history_8": "{{ variable.attributes.history_7 }}",
            "history_9": "{{ variable.attributes.history_8 }}",
            "history_10": "{{ variable.attributes.history_9 }}"

then use the “attributes-entity-card” to display the desired values:

- type: entities
    title: Sensor History
    show_header_toggle: false
    entities:
      - type: custom:entity-attributes-card
        entity: media_player.bedroom
        filter:
          include:
            - variable.last_motion.history_1
            - variable.last_motion.history_2
            - variable.last_motion.history_3
            - variable.last_motion.history_4
            - variable.last_motion.history_5
            - variable.last_motion.history_6
            - variable.last_motion.history_7
            - variable.last_motion.history_8
            - variable.last_motion.history_9
            - variable.last_motion.history_10
3 Likes

That looks very promising! I will first try the home feed card and see how it goes, and if that doesn’t work, I will try your idea, which indeed seems as though it should work.

The feed should display the events in reverse order of the time of the event, it doesn’t group by entity.

1 Like

Great, that sounds like exactly what I want then! Thanks!

of course it works! :wink:

ex

1 Like

Played a little with your example.
Should be

remove_repeats: false

?

EDIT: And the times showed are in english if less than a minute, in my language if more than a minute.
20191030_11%3A07%3A22_001

1 Like

Oops, getting the config settings of my own card wrong, now that’s embarrassing :grinning:

2 Likes

I’ve looked into implementing translations for these, but I don’t think I can make use of the built-in translations and would need to create translations for the “Less than 1 minute ago” and “In less than 1 minute” phrases.
I’m in the process of implementing an “exact time” option so that you will get the time down to the second for these, and with that option everything will use the built-in translations.

I’ve released 0.3.0b3 this includes a few changes:

  • An attempt at translating the “less than 1 minute” text.
    This now uses "< " instead of “less than” (which I was already using in compact mode anyway), basically using the standard localize function and then replaing the “1” with “<1” which isn’t ideal but it’s better than it being in English. @VDRainer Can you let me know how well this works for you?
  • a new exact_durations option. Setting this to true will eliminate the “<1 minute” entirely and switch to showing the duration in seconds (although this will make the duration refresh once a second until it gets to 1 minute)
  • Notifications without titles will use the notification id for the title (underscores replaced with spaces and converted to title case)

@Steven_Rollason, no worries, that’s ok for me.
Was just playing with it.

Hmm, it gives strange values. See below, it says that the last event was 13 hours ago

image

But if you look at 8 hour state graphs for the same entities, you can see that there were many more events in the last 8 hours (photos taken around 22:40)

image

It’s even more apparent when you look at the motion detectors which have lots and lots of activity over the last 8 hours

image

image

Yep, that fixed it! Thanks!