Change switch to push button to open the gate with magnetic contact


To open my gate I currently use a magnetic contact.
Is there a possibility to use the function of a push button in HA instead of a switch? I always have to put the switch back to OFF, otherwise the contact will remain closed.