Automation to run after calendar event but wait till someone is home

I am trying to have a trash bin reminder that runs when the event is triggered in the calendar. I want it to run if I am home but if I am not home I would like it to wait till I return home. I think it would be some if phrase but I cannot get it to work.

alias: Trash day
description: “”
triggers:

  • trigger: calendar
    entity_id: calendar.calendar
    event: start
    offset: “0:0:0”
    conditions:
  • condition: state
    entity_id: person.sam
    state: home
    actions:
  • action: media_player.play_media
    metadata: {}
    data:
    media_content_type: “type: tts”
    media_content_id: Did you take out the trash
    target:
    device_id: 0668af9e721edb51536e84dea4f4c8e5
  • action: notify.mobile_app_iphone_2
    metadata: {}
    data:
    message: Did you take out the trash?
    title: Trash
    mode: single

The first issue with the current automation is that there is only one trigger that will trigger once only at the exact time of the calendar event and if you are home it will execute. Fine if you are already home.

Like most things in home assistant there are normally 101 ways to achieve what you want.

We leave our bins out the night before due to early collections so ended up making a binary template sensor ( bin collection tomorrow) the sensor is on if the bin collection calendar event is tomorrow (based on an all day event).

Therefore the trigger for our automation is us coming home and the condition is if the bin collection tomorrow is on the announce message.

If you want to avoid templates you could maybe have 2 triggers, the original Calendar trigger and a coming home trigger and then use the same 2 triggers as conditions, that way either trigger can occur to start the automation but both states have to be true for the automation to occur.

You could use the calendar trigger as the only trigger like above but would have to use a wait for you to be home condition but that could involve the automation being in the waiting stage for a long time and that should be avoided if possible.

If using the two trigger and two condition method it may be advisable to then use a wait for motion in the room you are planning to announce to depending on how quickly it registers you are home as otherwise the tts message make occur before you have even had a chance to hit in the door.

Hopefully that gives you some ideas, if not come back and I am sure I or someone else can assist further with some sample yaml etc.

1 Like

For these type of notifications, I use boolean helper:

Washing machine finishes, it turns on the helper. Calendar or any other event I want to be announced when I’m home, another helper turned on.

Then there is an automation which has all these helpers set as triggers. And one more trigger - mode is Home. And a single condition - mode is Home.
This way the automation triggers when I get home, and also when I’m already home and some of those event happens (washing machine finishes).

Actions are simple. For each helper, there is a condition and announcement. If washing machine helper is finished, announce to hang dry it. If roborock is stuck, announce it’s stuck…

And last action - turn off all those helpers.

1 Like