Lovelace: Home Feed Card

@tc23 A max_height of 80vh means 80% of the viewport (window) height. Try experimenting with different heights using em instead (you could also use px if you want an exact pixel size, but this may make it look different in different browsers).

For example, with my experimenting, to make the feed card the same height as two entities cards each containing three entities I had to set the max_height to 32em

This is very cool. I’ve made a “Last movement” list to see the last twenty PIR movements detected:

movement

type: 'custom:home-feed-card'
title: Last Movement
show_empty: true
id_filter: ^home_feed_.*
max_item_count: 20
entities:
  - entity: binary_sensor.pir_bathroom
    icon: 'mdi:motion-sensor'
    include_history: true
    max_history: 20
    remove_repeats: false
    exclude_states: 'off'
  - entity: binary_sensor.pir_deck_front
    icon: 'mdi:motion-sensor'
    include_history: true
    max_history: 20
    remove_repeats: false
    exclude_states: 'off'
  - entity: binary_sensor.pir_deck_side
    icon: 'mdi:motion-sensor'
    include_history: true
    max_history: 20
    remove_repeats: false
    exclude_states: 'off'
  - entity: binary_sensor.pir_dining
    icon: 'mdi:motion-sensor'
    include_history: true
    max_history: 20
    remove_repeats: false
    exclude_states: 'off'
  - entity: binary_sensor.pir_drive
    icon: 'mdi:motion-sensor'
    include_history: true
    max_history: 20
    remove_repeats: false
    exclude_states: 'off'
  - entity: binary_sensor.pir_ensuite
    icon: 'mdi:motion-sensor'
    include_history: true
    max_history: 20
    remove_repeats: false
    exclude_states: 'off'
  - entity: binary_sensor.pir_entry
    icon: 'mdi:motion-sensor'
    include_history: true
    max_history: 20
    remove_repeats: false
    exclude_states: 'off'
  - entity: binary_sensor.pir_hall
    icon: 'mdi:motion-sensor'
    include_history: true
    max_history: 20
    remove_repeats: false
    exclude_states: 'off'
  - entity: binary_sensor.pir_laundry
    icon: 'mdi:motion-sensor'
    include_history: true
    max_history: 20
    remove_repeats: false
    exclude_states: 'off'
  - entity: binary_sensor.pir_lounge
    icon: 'mdi:motion-sensor'
    include_history: true
    max_history: 20
    remove_repeats: false
    exclude_states: Clear
  - entity: binary_sensor.pir_master_bedroom
    icon: 'mdi:motion-sensor'
    include_history: true
    max_history: 20
    remove_repeats: false
    exclude_states: 'off'
  - entity: binary_sensor.pir_rumpus
    icon: 'mdi:motion-sensor'
    include_history: true
    max_history: 20
    remove_repeats: false
    exclude_states: 'off'
  - entity: binary_sensor.pir_spare_bedroom
    icon: 'mdi:motion-sensor'
    include_history: true
    max_history: 20
    remove_repeats: false
    exclude_states: 'off'
  - entity: binary_sensor.pir_stairs
    icon: 'mdi:motion-sensor'
    include_history: true
    max_history: 20
    remove_repeats: false
    exclude_states: 'off'
  - entity: binary_sensor.pir_study
    icon: 'mdi:motion-sensor'
    include_history: true
    max_history: 20
    remove_repeats: false
    exclude_states: 'off'
  - entity: binary_sensor.pir_wardrobe
    icon: 'mdi:motion-sensor'
    include_history: true
    max_history: 20
    remove_repeats: false
    exclude_states: 'off'
  - entity: binary_sensor.pir_washing_line
    icon: 'mdi:motion-sensor'
    include_history: true
    max_history: 20
    remove_repeats: false
    exclude_states: 'off'
  - entity: binary_sensor.pir_workshop
    icon: 'mdi:motion-sensor'
    include_history: true
    max_history: 20
    remove_repeats: false
    exclude_states: 'off'
style: |
  ha-card {
    border: solid 2px var(--primary-color);
  }

However I only want it to show movement, not the return to clear state. I’ve tried all of these without success:

  - entity: binary_sensor.pir_lounge
    icon: 'mdi:motion-sensor'
    include_history: true
    max_history: 20
    remove_repeats: false
    exclude_states: Clear
  - entity: binary_sensor.pir_lounge
    icon: 'mdi:motion-sensor'
    include_history: true
    max_history: 20
    remove_repeats: false
    exclude_states: clear
  - entity: binary_sensor.pir_lounge
    icon: 'mdi:motion-sensor'
    include_history: true
    max_history: 20
    remove_repeats: false
    exclude_states: 'off'

Am I doing something wrong or is this a bug?

The dev tools states menu reports the PIRs states as off when clear.
The ‘Clear’ state was in quotes but lovelace removed them

Also I dont suppose I can use wildcards like this?

  - entity: binary_sensor.pir_*
    icon: 'mdi:motion-sensor'
    include_history: true
    max_history: 20
    remove_repeats: false
    exclude_states: 'off'

It would considerable shorten that card config.

1 Like

That should be like this:

- entity: binary_sensor.pir_lounge
    icon: 'mdi:motion-sensor'
    include_history: true
    max_history: 20
    remove_repeats: false
    exclude_states:
      - 'off'

If you want to use wildcards it’s best to use something like auto-entities around my card. Then you can do something like this:

type: 'custom:auto-entities'
card:
  type: 'custom:home-feed-card'
  title: Last Movement
  show_empty: true
  id_filter: ^home_feed_.*
  max_item_count: 20
filter:
  include:
   - entity_id: binary_sensor.pir_*
     options:
       icon: 'mdi:motion-sensor'
       include_history: true
       max_history: 20
       remove_repeats: false
       exclude_states:
         - 'off'

I have auto entities. Why didn’t I think of that? Thanks.

Unfortunately this config:

  - entity: binary_sensor.pir_lounge
    content_template: '{{display_name}} Movement {{state}}'
    icon: 'mdi:motion-sensor'
    include_history: true
    max_history: 20
    remove_repeats: false
    exclude_states:
      - 'off'

Still results in:
Annotation%202019-08-16%20223409

Can you confirm what version you are using?
The exclude_states option was added in the 0.2.9b1 beta version. If you use HACS you will need to select “Show beta” on the “hamburger” menu on the card details to see the beta versions. Otherwise you can download the betas from the releases page page on the repository.

Yep that’s the issue. I’m not on the beta version, apologies.

Thanks. I’ll upgrade now.

Yikes! I upgraded to the beta version and did a force refresh of the page and got a nasty red Custom element doesn't exist: home-feed-card.

I didn’t notice that the resource had changed.

Fixed that and it is working as expected. Thank you.

Now for auto-entity-ing it…

EDIT: well that was painless thanks to your example. It was pretty much done.

type: 'custom:auto-entities'
card:
  type: 'custom:home-feed-card'
  title: Last Movement
  show_empty: true
  id_filter: ^home_feed_.*
  max_item_count: 20
filter:
  include:
    - entity_id: binary_sensor.pir_*
      options:
        content_template: '{{display_name}} Movement {{state}}'
        icon: 'mdi:motion-sensor'
        include_history: true
        max_history: 20
        remove_repeats: false
        exclude_states:
          - 'off'

Thanks again.

The filename has always been “lovelace-home-feed-card.js” but HACS used to strip the “lovelace-” from the filename when it downloaded it but it seems something changed in a recent update to HACS and it stopped doing this and downloads the file as is.

Glad you got it working :smile:

1 Like

I have now published two releases:

0.2.9 has been released as a non-Beta release

0.2.10b1 has been released to Beta. This includes a change to how icons are displayed. This was previously using ha-icon to display these, which made it difficult to use the default icon for an entity. It would only pick up entities defined in the card config or in the attributes of the entity (e.g. through customize).

It now uses state-badge, which is the same as is used by the entities card. This means two things will change:

  1. Unless the icons are overridden the icon may change based on the state (e.g. an door sensor which is open will display a different icon from one which is closed)
  2. The colour of the icon will also change based on the state, whether or not the icon is overridden. The colours will depend on your theme (I have the default theme and the icon is blue if the sensor is off and yellow if it is on).
1 Like

Is it possible to align the icons?
0.2.9b3
20190816_20%3A45%3A51_001
0.2.10b1
20190816_20%3A47%3A05_001

@VDRainer I’ve just made a tweak to the styling of this, can you try with 0.2.10b2?

Yeah! Perfect aligned :slightly_smiling_face:

On the latest beta ( 0.2.10b2) if I enable remove_repeats for an entity it also removes the most recent entry as well. i.e. if there are more than two identical states for an entity, nothing shows for that entity. Is that the way it is supposed to work?

card:
  id_filter: ^home_feed_.*
  max_item_count: 20
  show_empty: true
  style: |
    ha-card {
      border: solid 2px var(--primary-color);
    }
  title: Last Movement
  type: 'custom:home-feed-card'
filter:
  include:
    - entity_id: binary_sensor.pir_*
      options:
        content_template: '{{display_name}} Movement {{state}}'
        exclude_states:
          - 'off'
        include_history: true
        max_history: 20
        remove_repeats: false
type: 'custom:auto-entities'

gives:
Annotation%202019-08-17%20215606

Where as

card:
  id_filter: ^home_feed_.*
  max_item_count: 20
  show_empty: true
  style: |
    ha-card {
      border: solid 2px var(--primary-color);
    }
  title: Last Movement
  type: 'custom:home-feed-card'
filter:
  include:
    - entity_id: binary_sensor.pir_*
      options:
        content_template: '{{display_name}} Movement {{state}}'
        exclude_states:
          - 'off'
        include_history: true
        max_history: 20
        remove_repeats: true
type: 'custom:auto-entities'

gives:
Annotation%202019-08-17%20215806

I think the issue is with the combination of exclude_states and remove_repeats. The states are excluded before the repeats are filtered out. This means thatif you exclude “off” and the state changes from “on” to “off” and back to “on”, you will lose the second “on” state. Is this what you are seeing? I may be able to avoid this by changing the order of processing to this:

  1. Exclude unknown states
  2. Remove duplicates if option set
  3. Exclude states defined in exclude_states

Unfortunately this will mean that “unknown” will always be filtered out, regardless of the exclude_states option.

Yep that’s it. Except I don’t just lose the second ‘on’ I lose both. I only want to see one.

e.g. someone moving around in a room will cause many PIR ‘on’ / ‘off’ states, I only want to see the latest ‘on’. Then if they move to another room and move around there the top of the feed should be a single ‘on’ for that room.

As a test I tried removing exclude_sates and enabling remove_repeats and all I see now is repeats due to the show_history (as expected). This is exactly what I want - but without the ‘clear’ states.

card:
  id_filter: ^home_feed_.*
  max_item_count: 20
  scrollbars_enabled: false
  show_empty: true
  style: |
    ha-card {
      border: solid 2px var(--primary-color);
    }
  title: Last Movement
  type: 'custom:home-feed-card'
filter:
  include:
    - entity_id: binary_sensor.pir_*
      options:
        content_template: '{{display_name}} Movement {{state}}'
        include_history: true
        max_history: 20
        remove_repeats: true
type: 'custom:auto-entities'

It definitely has something to do with the interaction you are talking about. It’s just that it’s being a bit overzealous and not just removing the second ‘on’ state but both ‘on’ states.

Can you try this with the new beta version, 0.2.10b3, and let me know if it is now working for you?

You may need to wait a short time or do a hard refresh of the page after updating to the new version for the updated logic to take effect due to caching.

Upgraded to 0.2.10b3

Changed config to remove repeats:

card:
  id_filter: ^home_feed_.*
  max_item_count: 20
  show_empty: true
  style: |
    ha-card {
      border: solid 2px var(--primary-color);
    }
  title: Last Movement
  type: 'custom:home-feed-card'
filter:
  include:
    - entity_id: binary_sensor.pir_*
      options:
        content_template: '{{display_name}} Movement {{state}}'
        exclude_states:
          - 'off'
        include_history: true
        max_history: 20
        remove_repeats: true
type: 'custom:auto-entities'

Did a force refresh (Ctrl + F5) and now the duplicates aren’t being removed completely, but unfortunately they aren’t being removed at all :slight_smile:

Annotation%202019-08-18%20000400

What does it look like without the exclude_states? Does it show Clear states between the Detected states? In that case, I think the change in the order of processing so that the states are filtered after repeats are excluded means that the states aren’t being treated as repeats.

I notice that in your original comment you said:

if I enable remove_repeats for an entity it also removes the most recent entry as well.

The remove_repeats logic actually keeps the earliest entry (over the previous day) rather than the latest. If you try rolling back to the previous beta version, do you see the missing entries if you scroll down to the bottom of the feed? If so, I may be able to add an option to change this so it keeps the latest instead if this would help.

It also looks like the issue is partly related to the the sensitivity of the specific sensors and how often they are switching between Detected and Clear. Could these be smoothed out it any way, such as using a template binary sensor?
It may be possible to have an option in the card which filters out states which repeat within a period of time (e.g. if it changes to Detected, then Clear, then Detected within a 5 minute period) but this would be quite complicated to implement.

Yes it does:

Annotation%202019-08-18%20004612

card:
  id_filter: ^home_feed_.*
  max_item_count: 20
  show_empty: true
  style: |
    ha-card {
      border: solid 2px var(--primary-color);
    }
  title: Last Movement
  type: 'custom:home-feed-card'
filter:
  include:
    - entity_id: binary_sensor.pir_*
      options:
        content_template: '{{display_name}} Movement {{state}}'
        include_history: true
        max_history: 20
        remove_repeats: true
type: 'custom:auto-entities'

That’s the problem. It wasnt. It was removing every trace of an entity that had a duplicate entry in the feed. Now it’s not removing anything though.

They are wired PIRs. They come on for 3sec. minimum. Pretty smooth. No bouncing contacts, that’s just me waving my arms in front of the sensor repeatedly to test for duplicates.

That’s the problem. It wasnt. It was removing every trace of an entity that had a duplicate entry in the feed. Now it’s not removing anything though.

I think max_item_count (which you have set to 20) may be the cause of this issue. Since the processing of remove_repeats happens before applying the max_item_count (which was a newer feature) the earliest Detected event for that entity may have not have been one of the 20 most recent events and been cut off. Can you try with the previous beta, but without that option set (or with it set to a higher value) and see if that is the cause of your issue?

If it is, I don’t know the best way to deal with that (other than potentially an option to control how much of the history to use, so you could just display the last 6 or 12 hourse, for example).