

Thanks! Both are the same trick: an input_datetime per cat, and a Mushroom template card doing the math inline in Jinja. No custom integration.
The collar card colors off days remaining, and the reset button runs a script that pushes the date out and clears the alert flags.
Want the YAML?


Happy to! I’ll do Lily, since it’s the same block copy pasted five times, once per goblin.
Fair warning: I’m not a developer and there’s almost certainly a tidier way to do all of this. It works though, and good enough is good enough.
The helpers
All of this is built on helpers, the ones under Settings > Devices & services > Helpers. Birthday and gotcha date are each a date/time helper set to date only, no time. I keep mine in
input_datetime.yaml, but making them in the UI gets you the exact same thing:lily_birthday: name: Lily Birthday icon: mdi:cake-variant has_date: true has_time: false lily_gotcha_date: name: Lily Gotcha Date icon: mdi:home-heart has_date: true has_time: falseThe collar needs three more: one date/time helper for the expiration date, plus two toggle helpers that my alert automation flips on and off. I made these ones in the UI so they live in
.storageinstead of a file, but here’s the shape:# input_datetime lily_flea_collar_expiration: name: Lily Flea Collar Expiration has_date: true has_time: false # input_boolean lily_flea_collar_expired: name: Lily Flea Collar Expired dismiss_lily_flea_collar_alert: name: Dismiss Lily Flea Collar AlertI left
initial:off all of them on purpose. If you set it, the next restart resets the helper back to that default and throws away whatever date you actually put in. Took me a restart or two to work that one out.Age and With Us
These two are Mushroom template cards on the dashboard (Mushroom is a HACS install if you don’t already have it). Add a manual card, hit “Show code editor” and paste. It’s the same card twice, just pointed at the other helper:
type: custom:mushroom-template-card primary: Age entity: input_datetime.lily_birthday icon: mdi:cake-variant icon_color: blue secondary: >- {% set b = state_attr('input_datetime.lily_birthday','timestamp') %} {% set by = b | timestamp_custom('%Y', true) | int %} {% set bm = b | timestamp_custom('%m', true) | int %} {% set bd = b | timestamp_custom('%d', true) | int %} {% set months = (now().year - by) * 12 + (now().month - bm) - (1 if now().day < bd else 0) %} {% set y = (months // 12) | int %} {% set mo = (months % 12) | int %} {%- if y > 0 %}{{ y }} yr{{ 's' if y != 1 }}{% endif %} {%- if mo > 0 %}{{ ' ' if y > 0 }}{{ mo }} mo{% endif %} {%- if y == 0 and mo == 0 %}new{% endif %} · {{ b | timestamp_custom('%b %-d, %Y', true) }} tap_action: action: more-infoMine reads
7 yrs 3 mo · Apr 2, 2023.One thing worth calling out: counting whole months first and then dividing by 12 avoids the leap year drift you get from dividing days by 365.
The collar card
Another template card, this one reading the expiration helper. It’s what goes green, orange, red as the days run down:
type: custom:mushroom-template-card primary: Flea Collar entity: input_datetime.lily_flea_collar_expiration icon: >- {% set ts = state_attr(entity,'timestamp') %} {% set days = ((ts - as_timestamp(today_at('00:00'))) / 86400) | round(0) | int %} {% if days < 0 %}mdi:alert{% elif days <= 30 %}mdi:alert-outline {% else %}mdi:shield-check{% endif %} icon_color: >- {% set ts = state_attr(entity,'timestamp') %} {% set days = ((ts - as_timestamp(today_at('00:00'))) / 86400) | round(0) | int %} {% if days < 0 %}red{% elif days <= 30 %}orange{% else %}green{% endif %} secondary: >- {% set ts = state_attr(entity,'timestamp') %} {% set days = ((ts - as_timestamp(today_at('00:00'))) / 86400) | round(0) | int %} {% if days < 0 %}Expired {{ days * -1 }}d ago{% else %}{{ days }}d left{% endif %} · {{ ts | timestamp_custom('%b %-d, %Y', true) }} tap_action: action: more-infoI compare against
today_at('00:00')instead ofnow(). Withnow()the count flips over at whatever time of day I happened to put the collar on, so it’d read a day short all afternoon. Little thing, but it bugged me.The reset script
This part isn’t a card, it’s a script. Settings > Automations & scenes > Scripts, create one, then use the three dot menu to edit it in YAML. Mine lives in
scripts.yaml:reset_lily_flea_collar: alias: Reset Lily Flea Collar description: Sets Lily's flea collar expiration to today + 7 months and clears alerts icon: mdi:cat sequence: - action: input_datetime.set_datetime target: entity_id: input_datetime.lily_flea_collar_expiration data: date: "{{ (now() + timedelta(days=213)).strftime('%Y-%m-%d') }}" - action: input_boolean.turn_off target: entity_id: input_boolean.lily_flea_collar_expired - action: input_boolean.turn_off target: entity_id: input_boolean.dismiss_lily_flea_collar_alertAnd the button that fires it, which is one more template card back on the dashboard:
type: custom:mushroom-template-card primary: Reset Collar secondary: Expiry 7 months out entity: script.reset_lily_flea_collar icon: mdi:restart tap_action: action: perform-action perform_action: script.reset_lily_flea_collar confirmation: text: Reset Lily's flea collar expiration to 7 months from today?The confirmation is in there because I tap this on my phone and I have fat fingers.
Those two
input_booleans are for my alert automation._expiredflips on when the date passes so it gets read out in our good morning announcement, anddismiss_shuts it up once I’ve actually heard it (otherwise it just keeps announcing it, every single morning, forever). If you’re not doing alerts you can drop those steps and the helpers along with them.Hope that helps! Let me know if something doesn’t work, I probably typed something wrong. Are you tracking vaccines too? That’s the one I still need to build.