[RELEASE] Lockdown


Lockdown for Hubitat

An app for Hubitat (It will probably work with SmartThings too) that will reliably lock all selected locks when a specified switch is triggered.

Reason for using Lockdown

  1. Z-Wave locks usually run in a low-power mode, and that means their z-wave communications are slightly less reliable than powered devices like z-wave switches.
  2. So, sometimes they don't respond to lock commands the first time.
  3. And, sometimes they don't report their status back after locking, which requires a manual refresh command.
  4. And this is made much worse if you have more than one. In my case, I had 5 z-wave locks, and if I tried to lock all of them at once, usually only 2 or 3 would be successful. All the other z-wave messages would get lost or deadlocked.

Therefore, I made an app that could methodically lock/refresh each lock, one-by-one, with retries in case of errors.

Install Instructions

The best way to install this code is by using Hubitat Package Manager.

However, if you need to install manually:

  1. On your Hubitat hub, go to the Apps Code screen
  2. Add a New App
  3. Copy in the contents of lockdown.groovy and Save
  4. Go to the Apps screen and Add User App
  5. Choose Lockdown
  6. Choose a triggering switch. Lockdown will watch this switch and activate when the switch triggers to on.
  7. Choose locks for Lockdown to manage.
  8. Adjust parameters.
  9. Click done

Recommended Integration with Alexa

It's really nice to be able to say "Alexa, lock all the doors". Here's how:

  1. Create a virtual switch in Hubitat. Let's call it "Lock Everything"
  2. Go to the Amazon Echo Skill app in Hubitat, and add the switch to the selected devices. Click done.
  3. Go into your Alexa app and make sure the virtual switch shows up in your devices.
  4. Create a new Routine in the Alexa app. Have it triggered when you say "Lock all the doors". Have it turn on the virtual switch.

Congratulations. You can now activate Lockdown by talking to Alexa.

  1. Add two more Alexa routines for "Lock the doors" and "Lock all doors", because occasionally Alexa will miss a word.

Recommended Scheduling / Rules

I want to make sure all my doors are generally locked at night, even if someone steps outside momentarily in the middle of the night and forgets to lock the door after them. Therefore, in Hubitat I create a scheduled Rule Machine rule that will turn on the Triggering Switch on the hour, each hour, during nighttime hours.

I also create a Rule that is triggered when everyone has left home, that will activate Lockdown, just in case we have forgotten to lock the doors on our way out.


This is a great app.

I had similar issues with any of my apps that control a lot of devices. I only have 2 locks and still find that sometimes they require multiple tries before locking. So I built in similar logic into my apps now that will loop through the devices and verify they have locked and try again for a max number of times.

Sucks that it needs to be done but it is highly successful.

Yeah, my system seems to have no problem changing a ton of lights at once, but door locks are another thing. I don't fully understand how it works, but I've read that the low-power mode of the locks has them wake up less often than other devices, and it relies on nearby powered devices to do "beaming", which mostly seems to be a fancy word for "error correction and retries". My hunch from this is that if you have multiple locks trying to go at once, the multiple beaming requirements end up saturating the network, and eventually either the locks or the beaming devices give up. I don't know that for certain, but it's a theory that fits my experience. /shrug

Cool app, really like how you provided the how to in the post and all.

Just published an update that provides more control over timing. Also fixes a reliability issue if locks reported 'unknown' status.


Update published: Now it keeps track of a "max number of retries" on a per-lock basis, rather than only tracking one retry count for ALL locks.

1 Like


I have been using your app pretty much since release, and finally had some time to deal with an incredibly odd behaviour (and in my case, undesired behaviour), which I eventually tracked down to your app. The behaviour is not strictly speaking wrong, but it wasn't noted/documented anywhere specifically...


  • I have a group of 3 virtual switches
  • Only 1 can be on at any given time
  • One of these 3 virtual switches was used as the TRIGGER switch in Lockdown

I initially created the desired switch behaviour, using the ON event for each switch, by RM manipulation. I eventually removed all my RM rules to do so, and now use the app "One At A Time" (OAAT) for a faster result.

The issue was present with both the RM setup & subsequent OAAT setup.

The behaviour manifested itself so that when the trigger switch was switched on, it would almost immediately switch off again... This didn't cause an issue per se with any other action relying on this switch to turn on, but visually it was inaccurate as it showed OFF when it should have been ON. The logs would also show that the switch would be turned off 3 times, which, as fluke would have it, and what started to get me thinking your app is the errant one, happens to correspond to the number of locks I have! Which of course got me reading your code, and voila!

I rectified my copy of Lockdown by commenting out the following line. Perhaps you should give an behaviour option in the app UI...

// Turn off the triggering switch once execution completes.
def doneHandler() {
log.debug "Lockdown: DONE"

// Commented out 2019/03/01
// False assumption made that the trigger switch has to be turned off after the lock cycle...

Just food for thought, and a note for others that follow down this path.


Ah, interesting. Yes, having the trigger be bound/intertwined to other switch states could cause unforeseen consequences, and it looks like you found the correct solution for your use case in commenting out that line.

For my use case, the reason that it turns off the virtual trigger when done is so that HomeKit and other dashboards can give an indication that Lockdown has finished its work. Also, if I remember correctly, it was so that Alexa could be used to trigger it repeatedly, though I'm not 100% certain that this was necessary for that.

Thanks for this @jwetzel1492! This resolves my concern about locks not getting the lock commands. I could care less if it doesn't always unlock, but having a lock not actually lock is a showstopper that this app resolves.

One thing that I found out was that the virtual switch that is needs to be created for this app needs to be left alone since Lockdown will power it off when it's done. I created a switch with auto-off setting of 5ms, so of course this didn't work well. Maybe this is documented, but if it isn't, it might be good to mention that your app will power the virtual switch off once the lockdown process is complete.


@jwetzel1492 App works great, but was not able to install on most up to date hub FW. I proposed a change in your github that was able to solve it for me.


1 Like

Pull Request accepted. Thank you!

Joel, any reason why this virtual switch has to be different than the triggering switch from step 6 of your install instructions? (great app btw)

Hi mluck, you are correct. They are the same switch.

1 Like

Any chance you would be interested in adding the option to unlock all locks the same way? I have a rule machine automation that unlocks all the doors if the smoke detectors trigger and the mode is not away. It would be handy to have your app handle the unlocking of all my locks as well!

Would also really be nice to have the ability to use contact sensors to check if doors are closed first before they lock!


Great idea @cj_rezz.

1 Like

IMPORTANT UPDATE: Lockdown can now be installed from Hubitat Package Manager. This is the best way to make sure you keep up-to-date with bug fixes and new features.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.

Download the Hubitat app