Filtering out Anniversaries in my glance card

Hi, I am currently using @pinkywafer’s anniversaries integration as a glance card. I have 6 anniversaries set, and will likely get more. I was wondering what the best way would be to only show the 3 next upcoming ones?

You could use the excellent lovelace-auto-entities card by @thomasloven https://github.com/thomasloven/lovelace-auto-entities

1 Like

Thanks @pinkywafer, I will check it out :slight_smile:

You can do something like:

type: 'custom:auto-entities'
card:
  type: glance
filter:
  include:
    - entity_id: sensor.anniversary*
sort:
  method: state
  numeric: true
  count: 3

Which will automatically pull all anniversary entities (that have the anniversary prefix) sort them and display the top 3

4 Likes

Perfect @pinkywafer. That works, thanks so much for your time

1 Like

Hello,
is it possible to display more information.
For example : age.

I tried with “secondaryinfo-entity-row” and “multiple-entity-row” but it doesn’t work.
Do you have an idea ?

Thank you

Sure, you just need to know which attribute you want. The ‘current age’ attribute would be current_years I used this as the anniversary may be something other than birthdays, so age wouldn’t seem right if it was years since something happened! There’s also a years_at_next_anniversary attribute!

Anyway, if you’re using multiple-entity-row, your config for the entity should be something like this:

- type: custom:multiple-entity-row
  entity: sensor.anniversary_your_birthday_sensor
  entities:
    - attribute: current_years
      name: age
      unit: years

Hope this helps

3 Likes

Ohh thank you @pinkywafer

you are really too strong.

Here is the result on my dashboard.

image

I love

Thank you

1 Like

Hi Chikite,

Would you mind sharing the yaml of this dashboard result

Thanks!

type: type'custom:auto-entities'
card:
  type: entities
  title: "Anniversaire à venir \U0001F382"
filter:
  include:
    - entity_id: sensor.anniversary*
      options:
        type: 'custom:multiple-entity-row'
        entity: this.entity_id
        entities:
          - attribute: current_years
            name: Age
            unit: ans
sort:
  method: state
  numeric: true
  count: 3

2 Likes

Super Chikite, thanks!

Still learning ;-)… is there way to get a notification on my phone in the morning (let’s say at 8) for an anniversary occurring on that day? I can do this on individual anniversaries but how to run this across all anniversaries (also when I add new), do I need a group of sensors for this?

All, I have tried to write a code to alert me in the morning for any anniversaries. Code is not yet working, anybody able to support? Thanks

alias: Notify anniversary
description: ''
trigger:
  - platform: state
    event_type: state_change
condition:
  - condition: template
    value_template: "{{ trigger.event.data.entity_id.startswith('sensor.anniversary_') }}"
action:
  - delay: '08:00'
  - service: notify.mobile_app_iphone
    data:
      message: '{{ trigger.to_state.name }} has his/her anniversary'
      title: Anniversary!
mode: single

Hi, for remaining days state, how do I display 1 month 5 days instead of 35 days?

Hi,

Did you solve how to present the days in months and days?

Can anyone also tell how to get the columns straighter?
The “age” column isn’t lined up correctly due to the remaining days are one, two or three numbers long.

Anyone managed to get card_mod working for this to remove background and box-shadow?

Hi,

I created a ‘today’ sensor:

template: 
  - sensor:
      - name: "anniversary today"
        unique_id: anniversaries_today
        icon: "{{ iif(states(this.entity_id)|int(0) > 0,'mdi:alert-circle','mdi:check-circle') }}"
        unit_of_measurement: people
        state: >
          {% set entities = state_attr(this.entity_id,'entity_id') %}
          {% if entities != none %} {{ entities|count }} {% endif %}
        attributes:
          entity_id: >
            {% set entities = states.sensor
              | selectattr('entity_id', 'search', 'anniversary')
              | rejectattr('entity_id', 'search', 'today')
              | rejectattr('entity_id', 'search', 'tomorrow')
              | rejectattr('entity_id', 'search', 'fortnight')
              | selectattr('state', 'eq', '0')
            %}
            {{ entities|map(attribute='attributes.friendly_name')|list }}
          current_years: >
            {% set entities = states.sensor
              | selectattr('entity_id', 'search', 'anniversary')
              | rejectattr('entity_id', 'search', 'today')
              | rejectattr('entity_id', 'search', 'tomorrow')
              | rejectattr('entity_id', 'search', 'fortnight')
              | selectattr('state', 'eq', '0')
            %}
            {{ entities|map(attribute='attributes.current_years')|list }}

And then a ‘today’ automation:

automation:
  - alias: "Notify Anniv. today"
    id: 'notify_anniversary_0'
    trigger:
      - platform: time
        at: "10:00:00" 
    condition:
      - condition: template
        value_template: "{{ states('sensor.anniversary_today') != '0' }}"
    action:
      - service: notify.mums_devices
        data:
          title: "{{ states('sensor.anniversary_today') }} event(s) today:"
          message: >
            {{ state_attr('sensor.anniversary_today','entity_id') }}
            {{ state_attr('sensor.anniversary_today','current_years') }}            
          data:
            push:
              thread-id: "Info"
              sound:
                name: "default"
                critical: 1
                volume: 0

and a dashboard view using condition card. I happen to display it as a mushroom-chip-card, but you can do it any way you like.:

- type: custom:mushroom-chips-card
  alignment: center #end
  chips:
    - type: conditional
      conditions:
        - entity: sensor.anniversary_today
          state_not: '0'
      card:
        type: template
        entity: sensor.anniversary_today
        content: "{{ sensor.anniversary_today }} is {{ state_attr('sensor.anniversary_today','current_years'}} "
        icon: mdi:cake-variant
        icon_color: red
        tap_action:
          action: navigate
          navigation_path: /home-dash/dates

I know this is late, but only just saw your post so hope it helps you or anyone else that comes looking.

3 Likes

Wow. thanks Jchh. In the meantime have learned a bit more about jinja and have directly applied it into my automation (without a ‘today’ sensor).

{% set result = namespace(sensors=[]) %}
{% for state in states.sensor if 'sensor.anniversary_' in state.entity_id %}\n  {% if 0 <= state.state | int(-1) < 1 | int %}
{% set result.sensors = result.sensors + [state.name ~ ' (' ~ state_attr(state.entity_id, 'current_years') ~ ' jaar)'] %}
{% endif %}
{% endfor %}
{% if result.sensors[1] is defined %}
  Vandaag zijn jarig: {{result.sensors|join(', ')}}
{% else %}
  Vandaag is jarig: {{result.sensors|join(',')}}
{% endif %}\n"
3 Likes

Yes, useful to learn a little jinja2, isn’t it :smiley:

I’ve put this code in a Markdown card.
My main view starts with a horizontal-grid-card that has a number of sub-cards for “important things” like

  • put trash outside now
  • birthday coming up in X days
  • current power consumption if higher than X
  • wife <30 minutes away from home - clean out the dishwasher
  • and other important messages.

Each of these cards has a custom-state-switch that shows/doesnt_show a markdown-card.

I created a helper sensor.helper_days_until_first_anniversary that shows the lowest number of days until next anniversary.

The custom-state-switch checks if this helper is below 30. Then it can show the markdown card.