How to notify people at home or the first person to arrive home

I’m currently using an action (script) from a state machine to notify anyone at home when an appliance is finished.

If no one is home Is there a way to save the notification and send it to the first person to arrive back home?

You could set a flag somehow (ie, with a helper) indicating that the notification is pending and reset it after firing the notification at the first arrival in the home.