I will give it a try, thanks!

I assume in place of a DoorSensor I should define the sensor I use (Fibaro universal binary, if it does mater)?

[update]:

After second thought, it is not exactly the solution. each trigger even can have different length, i.e. 1min., 2min, 30sec., 15sec., and so on.

Counting number of events doesn't take this into consideration, 5 events 1min. each give the same result as 5 events 10sec. each, while in second case the total time is less than one event from the first case.

In the meantime I took another approach, which is maybe easier - to count total triggering time regardless of time period, i.e. turn off device each case the total time of triggering events reaches 5 minutes.