One of the very first pieces of Smart Tech I added to my new house was a Smart Door Lock, this was essential as we had workers coming and going for weeks before we moved in, and we weren't on-site to let them in.
Now that we don't have people in and out all day, I have a Contact Sensor on the door that will automatically lock it every time the door closes — this avoids the issue of family members forgetting to secure the door. This particular lock also has an auto-timeout, set to the maximum of four minutes, as a backup.
Automatically Locking the Door
To automatically lock the door based on the sensor, you will set up the following automation:
When Front Door Contact Sensor Closes
Lock Front Door Lock
This automation will lock the door when the contact sensor closes. And it works very well… except when I don't want to lock the door.
When I have workers here, or if I were having a gathering, or when I just want to grab the mail, I can't leave the door open because our kittens might get out. The contact sensor is sensitive enough that even if I leave the door closed to, it will often trigger the lock, which causes it to register as stuck and causes even more hassle.
So let's try to make this automation smarter — when I tell Siri to leave the door unlocked, it should do so for at least 30 minutes, even if the locks built-in auto-lock kicks in.
Bring In The Dummy
To achieve this automation, we need a way to maintain the state of our decision to keep the door unlocked. For HomeKit, the best way is to have a device turned on or off, depending on what we want. You can do this with almost any HomeKit device — smart outlets are common, even if they have nothing plugged into them. However, if you want to build many complex automations, it will start to get expensive fast, so many people choose to go with Homebridge and its Dummy Switch plugin instead.
The Dummy Switch plugin creates fake switches within Homebridge that you can automate in HomeKit, that can be stateful (stay on or off indefinitely), or that will automatically switch back off when turned on — optionally, after a delay.
So, let's create a Dummy Switch:
Assuming you have Homebridge installed, you must also have the Homebridge Dummy plugin. If you already have the plugin installed, open the Settings, or you will be asked to create your first dummy switch after installation:

Then choose the " Add Accessory" button:

And finally, set the switch up as follows and choose "Save":

For the Dummy Switch Settings, we have chosen not to make it stateful as we want to have a fallback of 30 minutes instead. To allow for those times when people are in and out constantly, we will set it to Resettable, so the 30-minute timeout resets every time the switch is turned on.
Now that we have a switch to maintain state let's update our automation to use it.
Hey Siri, Keep the Door Unlocked
The first thing we need to do is create a new Scene. This will allow us to create a custom Siri command; in our case, we will call it "Keep the Door Unlocked." This scene will do one thing, which is to turn on our new dummy switch:

The name of this scene is the command you will give Siri: Keep the Door Unlocked.
Now that we have the switch in place, we can use it in our automations, so let's update that next:
When Front Door Contact Sensor Closes
If Keep Front Door Unlocked Switch is Off
Lock Front Door Lock
As you can see, we now only lock the front door lock if the switch is off, and thanks to the dummy switch settings, this will automatically reset after 30 minutes — but we can make this better.
Party Mode
Next up, we want to ensure that the door stays open longer when people are in and out a lot by adding another automation:
When Front Door Contact Sensor Opens
If Keep Front Door Unlocked Switch is On
Turn On Keep Front Door Unlocked Switch
This might seem a little counter-intuitive: if the switch is turned on… then turn it on? However, if we don't put this condition in place, the Keep Front Door Unlocked switch will turn on every time you open the door, and we want to turn it on again because this resets the timer on the switch for another 30 minutes.
No Auto-Lock For You!
The last improvement we can make is to override the built-in four-minute auto-lock. For this one, we're going to detect when the door locks, and when it does, we'll unlock it again:
When Front Door Lock Locks
If Keep Front Door Unlocked Switch is On
Lock Front Door Lock
Wrapping Up
And there we have it, one dummy switch, and a few automations, and now when you go to grab the mail, you can just tell Siri to Keep the Door Unlocked, and they will!