It should be made possible to use a switch only for a certain period of time

Is there a way to save a state for five minutes via a script? The state should provide information about whether a switch can be pressed or not. Specifically, control of a gate should only be possible for five minutes after release by admins. I am absolutely new in this topic and thankful for any help from you.

Timer helper? Then a condition in the script so that it will only run if the helper is “on”?