Automation to keep garage door closed when home

I have created an automation that opens the door when I arrive via device_tracker=home. So now I have created another automation to closed the door when I am away via device_tracker=away. Now here is where the problem is when I arrive home garage door opens like it should and stays open because device_tracker=home. How can I tell HA to add condition if home for xxx amount of time disregard previous automation.

A quick comment upfront:
I would NOT recommend to have the garage door close automatically in many cases, especially if it’s a detached one.
The consequence might be that it closes on you while your house and car keys are still in the car because you have just stepped out of the garage for a moment or - even worse - the garage door hits you or somebody else in the head while your walking out of the garage.

Should this not be a concern, the automation you have created probably uses a state trigger the kicks off when a device changes to: home.

You can set up another trigger that basically detects that the device has been home for a certain period of time, e.g. 5min, before it closes the garage.

Take a look here for details:

And another word of warning because I have seen a few threads about it:
Depending on your phone, it might just drop off the network when it goes to sleep. Should it then reconnect, and therefore be detected as ‘coming home’ again, your garage door might just open in the middle of the night.

Take a look at this solution - I like that it’s independent of one’s device: