Calendar trigger with negative offset not firing - known workaround?

Hi there, I want to create an automation that runs based on a calendar. I want to turn on the heating 15 minutes before an event in the calendar starts.

To be sure, HomeAssistant knows of the events, I create them via the Calendar of HomeAssistant.

This the the yaml for the above (manually updated the offset to be ISO compabible):

trigger:
  - platform: calendar
    entity_id: calendar.kriekzaal
    event: start
    offset: "-00:15:00"

This is how it looks in the automation editor:

This is the yaml after editing via the automation editor (notice the -0:15:0):

trigger:
  - platform: calendar
    entity_id: calendar.kriekzaal
    event: start
    offset: "-0:15:0"

This is the calendar event:
image

Here I can see that the event is known by HA and that we’re just after the 15 min offset:

Yet, for some reason the automation does not trigger (no trace). Logs don’t show an error. I first noticed the issue in HA 2023.7.1 and after upgrading to 2023.11.3 it still is present. Am I doing something wrong?

I also tried with a template trigger but also that didn’t work.

trigger:
    - platform: template
      value_template: "{{ 890 < ((as_timestamp(state_attr('calendar.kriekzaal','start_time')) | float() | round(0)) - (as_timestamp(now())| float() | round (0))) < 900 }}"

Other attempt (created via automation editor and copied from yml file on disk):

trigger:
  - platform: template
    value_template: '{% if (890 < ((as_timestamp(state_attr(''calendar.kriekzaal'',''start_time''))
      | float() | round(0)) - (as_timestamp(now())| float() | round (0))) < 900) %}true{%
      endif %}'

I created a Github issue but I’m desperately looking for a workaround.

Hi @123 - as I think you know a lot of the calendar integration, you don’t have an idea by any chance?

I wouldn’t use a Template Trigger (for reasons explained here).

The Calendar Trigger you created should work. However, your testing procedure might be influenced by how newly created calendar events are loaded (approximately every 15 minutes). If your tests are using events that are scheduled a half-hour or more in the future and the Calendar Trigger is still failing to detect them 15 minutes before their scheduled time, then that’s abnormal.

Ok, I’ll see whether that’s the cause! Thanks for the feedback!