"delay" in automations

Hi, now that you revampt a lot of automatisation stuff, please change the behaviour of the delay function when calling something triggered by the calendar.
If I have a meeting, I want to heat the room 1 hr before start. Until now it only is possible to make it with a delay. So in my case the automatisation starts 2hrs before the appointment and then dealys it by 1hr, so i have 1 hr left. If i change the meeting in the meantime, it will not respond to the change an more. I hope you understand my problem, it would be very nice to have a real “before” option, that does not need the delay workaround. If I want to heat the room 2,5hrs before an apoointment I would need to chabge the whole delay script and also would make the “unresponsive” time longer.

This can be accomplished with the standard calendar trigger:

https://www.home-assistant.io/docs/automation/trigger/#calendar-trigger

automation:
  trigger:
    - platform: calendar
      event: start
      entity_id: calendar.meeting_schedule
      offset: "-01:00:00"
  action:
    - service: switch.turn_on
      target:
        entity_id:
          - switch.heater

This is not a feature request. It is configuration help so I have moved it. Please ask in a Configuration category topic for things like this in future, then only if what you want is not available create a feature request.

Its not so simlpe, I need the offset to be a variable and this makes it impossible. This is the real problem I see, that offset can only be a “string?” . I need an variable offset. Is this possible ? Hope you can make this work somehow, it would make my life a lot easier.

This is what I need :

alias: Appointment Start in Room1
description: “”
trigger:

  • platform: calendar
    event: start
    offset: “-3:0:0”
    entity_id: calendar.sitr
    condition:
    action:
  • delay: >-
    {{ ((10800 - ((states(‘input_number.var_delay_time’)) | multiply(60)
    | int(0)))) }}
  • service: climate.set_temperature
    data:
    temperature: “{{ states(‘input_number.var_activity_temp’)| float(0) }}”
    target_temp_high: “{{ states(‘input_number.var_activity_temp’)| float(0) +5}}”
    target_temp_low: “{{ states(‘input_number.var_activity_temp’)| float(0) -5 }}”
    hvac_mode: auto
    target:
    device_id:
    - ad0522e8c643732ac6feff0448ab0972
    - b737de5a1e0b38d46c3ee1877893f57d
    mode: single

How can I do it without the delay workaround ?

Please format your posts correctly. https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

OK, so your feature request was actually for the “calendar trigger offset option to support templates”. Nothing to do with “delays in automations”.

Try making a new FR using that wording, use your (correctly formatted) config as an example of what could be simplified in the FR.

Yes, its exactly what I mean. I will create a request next day, today its getting too late. Thank you for the help.

Tom

Would it be possible to read a variable from the calendar event and then use that as an offset?

Like if you had the text Notify: -01:00 in the event, then it could be read as a sensor and used as a {{ states(’ …}} value in the automation.

No, this is not possible. The offset can not be variable. You cant template it.

You’re miss understanding his question and proposition. And yes it is possible.

Create a template sensor that uses the calendars start time with a variable offset. The sensors state will be a datetime object. You can then use that sensor in a time trigger.

Ok, I see. Still a workaround, would be great if the offset itself could be a template.