Can Homeassistant do something different if an automation is restarted?

I’m sure this could be put together with existing various features, but this could be made into something more straightforward and easy to understand. Perhaps as a condition that would be used in a choose action.

Example: An automation sends a notification on button press, then has a delay of 5 minutes.

First press: Trigger automation - Send a notification that says, “can you help me out?”

Second press: Automation is triggered and restart count is 1 - Send a notification: “I need your help!”

Third press: Automation is triggered and restart count is 2 - Send a notification as a critical alert: “SOS EMERGENCY!” Blink all lights, play a sound.

You are looking for the Wait For Trigger action.

First press triggers the automation, which then waits in the actions for the second (or subsequent) press(es).

It has a timeout too.