Local Calender: Get yesterdays eventname

Hey guys,

I really struggle with jinja. It won’t get in my head :sweat_smile: I have already a sensor for the name of todays and a separate one for tomorrow’s Calender event. To go full circle, I would love to have a third third one, that’s gives me yesterdays event name.

I want this, because it’s a shift calendar for my wife and depending which shift is today or tomorrow some automations are triggered. But sometimes she have nightshifts and something should happen after 12 am, so that „today“ is not longer „Nightshift“. I hope you get the point :joy:

Thank you in advance!

If you already have a sensor for tomorrow’s event, you should be able to duplicate that and just change the start and end times in the calendar.get_events service call.

1 Like

Yesterday’s events.

service: calendar.get_events
  entity_id: calendar.your_calendar
    hours: 24
  start_date_time: "{{ (today_at() - timedelta(days=1)).strftime('%Y-%m-%d 00:00') }}"
1 Like