Action based on button press sequence

I have an idea to make a switch a little bit more secure. I’d like to use a button (can be zigbee or wifi) which has 3 states (single, double, long) in the following way:
a. one short press does an action (it is simple)
b. a combination makes another action

I’m looking for a solution for the b.
E.g. when i press the button twice and the one long press makes an action. So after a double press it waits a short time (e.g. 5 secs) and if I make a long press during this time, it activates the secure action. If instead of a long press I do anything else or I wait more than 5 seconds, it clears the process.
Is there any template or any HACS solution for this?

Changed the topic name because it was not so perfect…