Help with a birthday shopping reminder automation

I have a HA calendar set up with the birthdays of close family and friends.

I’d like to add a “shop for person X” reminder to my calendar a few weeks before each person’s birthday. I got as far as this:

alias: Birthdays
description: ""
triggers:
  - trigger: calendar
    entity_id: calendar.birthdays_events
    event: start
    offset: "-470:0:0"
conditions: []
actions:
  - action: todo.add_item
    metadata: {}
    data:
      item: Buy a gift for {{ trigger.calendar_event.summary }}
      due_datetime: (trigger.calendar_event.start)|as_datetime - timedelta(days=14)
    target:
      entity_id: todo.shopping_list

But either it’s never triggered, or something fails when it does (several birthdays have come and gone, and nothing has ever appeared on my to-do list).

  1. Is it obvious what I’ve done wrong here?
  2. So I can teach myself to fish… can you bypass the trigger on an automation and force it to run the actions only? How does that work in a situation like this where the action depends on properties from the trigger?

19 days and 14 hours seems oddly specific. I’m not sure if you can offset more than 23:59:59

Ha, I was aiming for “around 3 weeks” but I picked that specific time when I was last mucking about with it because it should have triggered an hour or so after I saved it. Convenient but confusing!

A max offset of 24 hours is really interesting. I guess I would need to have a days remaining helper and try to trigger it off that instead? Is there some other smarter way to do this?

I’m not 100% sure that is the issue.

Is it triggering, can you see an automation trace?

Just checked the code. You need to make it a time period dict.

  - trigger: calendar
    entity_id: calendar.birthdays_events
    event: start
    offset:
      days: -21

EDIT:

Further checked the code. HHMMSS will work, so that’s likely not your issue. The code is quite simple and all offsets go through it.

Are you sure this isn’t triggering with "-470:0:0"

1 Like

That’s not a valid template or datetime string.

Yes, there is a option called “Run Actions” in the automation editor menu and an action automation.trigger to do that…

It will not work, unless you modify your templates to have default values for time the trigger variable doesn’t exist.

1 Like