Is there a way to trigger an automation after the triggered start time?

Is there a way to trigger an automation when the event was entered after the triggered start time?

I’m using @tykeal Rental Control integration as a calendar. The trigger is set to fire at Event Start which is at 4 PM on the event start date, but sometimes I have events that are last minute and are entered after the trigger time of 4 PM. If there a way I can enter at event start and any time after that for that day or something like that?

Here’s the automation:

alias: 4781A Arrival
description: 4781A Arrival
trigger:
  - platform: calendar
    event: start
    offset: "-0:45:0"
    entity_id: calendar.rental_control_4781a
condition: []
action:
  - type: turn_on
    device_id: 3xxxxx9
    entity_id: 3xxxxx1f
    domain: switch
  - type: turn_on
    device_id: axxxxxxxxxx19
    entity_id: cxxxxxxxxxxx4
    domain: switch
mode: single

Currently this automation works perfectly when the event is entered in advance of 4 PM, but on some occasion like last night the event is entered after the start time, last night it was around 10 PM. The trigger didn’t start the automation. I would like to find a way to trigger the automation any time after 4 PM on the same day of the event.

There’s a few things that you could do here.

One, add a toggle helper that latches on the calendar entity state and this automation having run.

Let’s call it Guest Arrival so the entity becomes input_boolean.guest_arrival

I would craft this more like the following:

alias: 4781A Arrival
description: 4781A Arrival
trigger:
  - platform: calendar
    event: start
    offset: "-0:45:0"
    entity_id: calendar.rental_control_4781a
    id: before_arrival
  - platform: state
    entity_id:
      - calendar.rental_control_4781a
    to: "on"
    id: turned_on
  - platform: state
    entity_id:
      - calendar.rental_control_4781a
    to: "off"
    id: turned_off
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - before_event
              - turned_on
          - condition: state
            entity_id: input_boolean.guest_arrival
            state: "off"
        sequence:
          - service: input_boolean.turn_on
            data: {}
            target:
              entity_id: input_boolean.guest_arrival
          - type: turn_on
            device_id: 3xxxxx9
            entity_id: 3xxxxx1f
            domain: switch
          - type: turn_on
            device_id: axxxxxxxxxx19
            entity_id: cxxxxxxxxxxx4
            domain: switch
      - conditions:
          - condition: trigger
            id:
              - turned_off
        sequence:
          - service: input_boolean.turn_off
            data: {}
            target:
              entity_id: input_boolean.guest_arrival
mode: single

What this now does is cause this boolean to latch to an on state if it is currently off and it is triggered by either the early arrival condition you had before or if the calendar entity goes to on when the event actually starts.

It will also reset the boolean to off when the event ends (at checkout time of your guest)

This way even if you restart your HA for some reason while the guest is there it won’t suddenly cause your devices to turn on again if they were turned off while the guest was there

This is great! Thank you so much, I will be able to this test on Monday when the calendar is clear. I will let you know.

There’s no guest today and I’m able to test this. I’m getting this error
Error in describing condition: Cannot read properties of undefined (reading ‘entity_id’)

Here:

condition: state
entity_id: input_boolean.guest_arrival
state: "off"

When I remove

condition: state
entity_id: input_boolean.guest_arrival
state: “off”

The automation works, runs when a reservation is added at 10 PM

Have you created the Guest Arrival toggle helper like I mentioned (though didn’t explicitly state you had to create)?

That’s what that error is telling me is that you haven’t created the needed helper.

To create one, you can click here → Open your Home Assistant instance and show your helper entities.

Press Create Helper and then Toggle and name the entity Guest Arrival

After that you can put the declaration you removed back into the automation

Done! Thanks!

Today it triggered at 3:15 PM but no action:

is it because this “id: before_arrival” and this “- before_event” don’t match?

alias: 4781A Guest Arrival Test
description: 4781A Guest Arrival Test
trigger:
  - platform: calendar
    event: start
    offset: "-0:45:0"
    entity_id: calendar.rental_control_4781a
    id: before_arrival
  - platform: state
    entity_id:
      - calendar.rental_control_4781a
    to: "on"
    id: turned_on
  - platform: state
    entity_id:
      - calendar.rental_control_4781a
    to: "off"
    id: turned_off
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - before_event
              - turned_on
          - condition: state
            entity_id: input_boolean.guest_arrival_4781a
            state: "off"
        sequence:
          - service: input_boolean.turn_on
            data: {}
            target:
              entity_id: input_boolean.guest_arrival_4781a
          - type: turn_on
            device_id: 3xxxxxxxxxxxxxxxxxxx9
            entity_id: 3xxxxxxxxxxxxxxxxxxxf
            domain: switch
          - type: turn_on
            device_id: axxxxxxxxxxxxxxxxxxx9
            entity_id: cxxxxxxxxxxxxxxxxxxx4
            domain: switch
      - conditions:
          - condition: trigger
            id:
              - turned_off
        sequence:
          - service: input_boolean.turn_off
            data: {}
            target:
              entity_id: input_boolean.guest_arrival_4781a
mode: single

Yes… sorry, looks like I had a bug in the code I gave you :frowning:

No problem, thanks! I will fix!