This is a simple Zwave Lock and Door Manager for Home Assistant.
When I first migrated from Smartthings to Home Assistant, one of the very first things I needed to do was to figure out how to manage the lock codes on my Zwave (Kwikset) locks and have them auto lock.
I discovered the KeyMaster integration and went with it. However, it was more complex than I needed and most of all it made my install messy with the hundreds of helpers it created that HA would report as broken and were unfixable.
There had to be a simpler way, and this is what I developed using a handful of helpers and a few automations with very little customization needed. The key difference is that it doesn't support scheduling (although you could easily write a distinct automation to enable disable the appropriate booleans at certain times) and most importantly it doesn't make a distinction between various locks you might have. Basically, if you can get in the house via one lock, you can get in the house via all the locks.
The automations support up to 8 distinct codes that can be selectively enabled/disabled and be set to provide a notification if the lock code is used.
I've also included an example auto-lock automation which uses various custom sensors.
I suspect that all of this could be converted to blueprints, but I don't have time for that right now. Volunteers welcome! :-)
- Add the sensors from the configuration.yaml file in this repo to your configuration.yaml file (hint use File Editor add-in if possible)
- Reload the input_boolean and input_text helpers via Developer Tools/YAML
- Create new automations for each of the 'set codes' and 'notify' yaml files (create new automation and edit in YAML, and then paste the code). Note there are some modifications you will need to make to use your door lock entities and notification service, but that's it
- Create the front end YAML by creating a new dashboard in Settings/Dashboards, and editing the page in YAML via raw configuration editor (it is multiple cards) and pasting the code from the lovelace yaml file.
- For auto-lock, you can use the auto-lock yaml and replace your lock and door contact sensor entities, but note that it has some custom logic around sensors that prevent the door from auto-locking if it detects activity outside. You can either replace this with your own sensors or remove these conditions.
- For getting notifications for doors that are open for more than a certain amount of time, create an automation using the doors_open_notify_automation.yaml file. Update the binary_sensors (contact sensors) that you want notifications about. Note that the notification uses a specific service (UserNotify) that is custom to my automation, so there are a couple of disabled actions in the file which you can use to notify using regular mobile push notifications. The conditions in the first part of the automation allow for customization per door - namely the length of time a door needs to be open before you start receiving notifications, and motion sensors that need to be idle for a period of time before a door will get notifications. I use this for areas like the deck and garage where the doors are often open for long periods when we are outside.
- The code is set up to support 8 distinct lock codes. The current code could support 9. However, it can't support more than that due to the janky ninja template code which assumes that the code slots are only single digits. If you want more than 9 slots, you will need to fix the template code with something more durable and clever than I am. By all means feel free to share your code or do Pull Request if you do come up with something better!