You may download or clone the project from https://github.com/FutureTense/lock-manager
I was looking for a bit simpler lock manager, as I only have one Zwave lock. If I add others, setting up a new manager would be simple with a few global replaces. Anyways, let’s take a look at one of the “codes” that I setup (Not every day of the week is displayed)
The top section is somewhat obvious. You can enter a name for the code slot, the PIN for the lock. The
Notifications input_boolean will
notify you when the code is used on the lock. The
Enabled input boolean means the system is allowed to use the PIN with your lock, however it does not mean that your code is “in” your lock. Look at the
Status notification. When that reads
Connected, that means Home Assistant has sent the PIN to the lock. If it reads
Disconnected then the code has been removed from the lock.
In fact, each code has it’s own automation that is triggered whenever it’s status notification changes. That automation adds or removes the PIN from the lock. By using a collection of
binary_sensors it’s possible to add many different options to the lock system. Each option in the GUI has an associated binary_sensor, and those are “added” together (technically using the AND operator), so you can create some complex lock access scenarios.
I’ve added a few of them which I’ll try to describe. By default, when you setup a code, you set the name of the person using the code and the PIN. Whenever you change the PIN text, the system automatically turns of the “Enabled” input boolean. Turn the boolean on and you will have an “always active” code. Use these for your family members. The code I’m showing here is what I use for a neighbor who visits our pets when we go away. I just use the Enabled boolean to turn it on when we leave, and off when we get home.
To let someone access the lock a specifc number of times, I would enable the “Limit Access Control” boolean and use the slider to set the number of times the user can execute an “unlock” command.
Enable the Date Range and specify the Start/End dates, and the system will add the code when the system time falls between those ranges.
Below that are the “days” settings. If you want to let someone access the lock only on Monday-Friday, turn off the Saturday and Sunday booleans. Each day also has time settings. If the start an end values are the same, then the user can access the lock for 24 hours on that day. If you specify a range, the PIN can only be accessed during that time period.
Suggestions are welcome, and thanks again to @ptdalen whose code I borrowed and examined to put this together.
Download the code from github. The files need to be placed in the packages directory. I suggest putting all of these files in a directory called
lockmanager so your directory structure should look something like:
N.B.* This package expects your lock to have the entity_id of
lock.front_door_lock so you can either rename the entity_id of your lock in Home Assistant or do a global replace in the package files.
* For those of you who have ever wondered what N.B. means, it is an abbreviation for the Latin phrase nota bene, which simply means, “observe carefully or take special notice”.
The following files are included:
- lock_manager_1.yaml - lock_manager_6.yaml
Instead of creating six sets of entities, it found it was much easier to create
lock_manager_1.yaml and copy that file to
lock_manager_2.yaml, etc. and modify those files. The script
copy6.sh will do that for you. It simply copies
lock_manager_6.yaml and then uses
sed to replace
lock_manager_1.yaml is modified, run the script to ensure the changes are propagated. The file
lock_manager_common.yaml as you might suspect, is code that is common to every entity in the package. The contents of
lovelace is the yaml code for displaying the six keypad codes. In the lovelace editor UI, use the
raw config editor option to display your entire lovelace yaml. Go to the end of the file and paste the contents of
Adding more user codes
The easiest way to add another user code “slot” is to modify the
copy6.sh script. For example, suppose you wish to add a 7th slot. Open
copy6.sh in your favorite editor and add the following:
cp lock_manager_1.yaml lock_manager_7.yaml sed -i 's/_1/_7/g' lock_manager_7.yaml
Save and then run the script and then restart Home Assistant. Now you will have entities for the 7th slot. To add the UI elements, open the first slot with the UI editor and copy the contents and paste into an editor. Replace
_7. Click the
+ icon in the UI and add a “manual card”. Paste the contents of your code, save and you’re done.