Custom Component: Lock Code Manager - an integration to manage lock usercodes (Z-Wave only, for now!)

Introducing a new lock code manager: GitHub - raman325/lock_code_manager: Lock code manager for locks integrated with Home Assistant an integration to manage lock usercodes.

When users are looking for a way to manage their Z-Wave lock usercodes, they are usually told to use keymaster. Keymaster is a great integration, and if it’s works for you and you like it, stick with it because “if it ain’t broke don’t fix it.” The reasons why I chose to make this a separate integration instead of building it into keymaster are listed here: GitHub - raman325/lock_code_manager: Lock code manager for locks integrated with Home Assistant

Like keymaster, the integration allows you to set up schedules for when a code should be active, or limit the number of times a PIN can be used. But it can also be useful if you don’t want to have any complex schedules and instead just want an easy way to manage codes.


Disclaimers:

  • Things may not work perfectly yet, but having more users will help in ironing out the kinks.
  • Because of the way this integration works, it might be subject to race conditions that result in weird behaviors. Not sure if this is an actual problem, but be warned.
  • My bandwidth is currently limited, so if you do run into an issue, log an issue in the repo but please be patient. Keymaster still works perfectly fine if you need something to use while your issue is being sorted out.

Key Features:

  • Manage when user codes should be enabled or disabled using a calendar entity
  • Track when a user code is used using the event entities, or using the lock_code_manager_lock_state_changed event
  • Sync codes across multiple locks (and you can mix and match which codes you are syncing between which locks, see here for more information: Advanced Usage · raman325/lock_code_manager Wiki · GitHub)
  • Extensible to support other integrations that support usercodes
  • Adds support for a dedicated lock code management dashboard OR a view within an existing dashboard

Comparing LCM to Keymaster

If you are trying to evaluate whether to use this or keymaster, here are my opinionated pros and cons:

Advantages of LCM over keymaster:

  • No package files are generated (no files in general)
  • Significantly less entities created (only creates the ones you need, and offloads scheduling to the calendar platform)
  • No automations created
  • Focuses on usercode management and skips features that can be built through automations like auto relock
  • Code is written in a way that makes it much easier to support locks from other integrations in the future (see here for more details: Supporting new lock integrations · raman325/lock_code_manager Wiki · GitHub)
  • UI configuration is simpler

Disavantages of LCM over keymaster:

  • It’s new, so it probably will need some work
  • While keymaster may seem complicated, under the hood it’s actually pretty simple and let’s Home Assistant do a lot of the heavy lifting. LCM looks simpler but the integration handles more things that keymaster offloads to Home Assistant. The end result is that there may be edge cases that LCM doesn’t handle.

If I haven’t scared you away yet, give it a shot! For now, you will need to add the repository as a custom repository to HACS in order to install it, but eventually I hope to get it included in the main list.

9 Likes

That’s an excellent description of how they differ. KeyMaster dips into everything HomeAssistant offers now or in the future. You can use Lovelace, integrations, templates to build some whacked out lock rules. I just copied every rule some other smart home package offfered as a starting point. Then I added some really crazy ones that never made the cut. But to be frank, I’ve never used anything but the simple “on/off” rule. The reason never came up.

Nice work, this seems like a much simpler solution to plug a gap in home assistants base covering for lock controls. With the way this custom component structured, is it going to make it easier to expand to zigbee devices than it has been for for keymaster?

Yup, that’s the idea. I haven’t looked into Zigbee yet though to see how difficult it would be. I imagine someone who knows the zigbee integrations would be able to solve this pretty quickly

oh, yay! I couldn’t get keymaster removed fast enough. Never worked for me no matter how many times I repaired the locks. This loaded right away and is working as expected. Now a scroll through my automations and helpers like a normal person. Thank you!!

Giving this a try now…
Question about how this works “or you can use a single calendar across multiple slots”: How to I pair an event with a specific slot?
ie. Event “A” for slot 1 and event “B” for slot 2 with both events in the same calendar?
Thanks @raman325 for the hard work here!

Sorry @cben0ist, that doesn’t work. If you tied two slots to the same calendar, events would turn both slots on. Feel free to ask for that as a feature request though!

1 Like

I must be missing something. I installed this and set the slots for 4 codes. I put in the code and left the calendar blank since I want them to always work. All of the slots are showing as unavailable and the codes do not work on the lock.

Screenshot 2024-05-28 084803

It would be cool to see this integration support MQTT locks (zigbee2mqtt) zigbee devices never seem to get any support for these cool plugins :frowning:

I figured it out. I had reset the lock and didn’t add any codes before I set this up. I thought it would setup the codes for me not just update and sync them. I setup the codes on the physical lock and they synced now.

Not sure what is missing. I installed via HACS and have setup the integration with 5 codes. All appears to be okay from that perspective. The problem arises when I try to create the dashboard. I have created a new dashboard from scratch and copied in the code from the Wiki.

strategy:
type: custom:lock-code-manager
include_code_slot_sensors: true // If set to true, the code slot sensors will be displayed in the UI, otherwise they will be hidden. This setting is optional and defaults to false

After saving I get the following error.

Error loading the dashboard strategy:

No strategy type found

I suspect something didn’t install with the integration but have been unable to determine what that is. I am using HA 2024.6.1 and Lock Code 0.4.6.
Can someone point me in the right direction to fix the error?

I also get the same error after installing and attempting to create the dashboard.

After digging around found the mushroom strategy frontend in HACS. This is the only reference to strategy I found and looks like it might be the missing piece. I loaded that along with the mini-graph frontend as the install directions found in the Wiki. I now get the following error;
Error loading the view strategy:

TypeError: e.pinActiveEntity is undefined

I think this is gettiing closer and will continue to dig around for a solution.

When I bring up the integration after configuring it, it shows no entities. Is this expected or is there a problem with it not creating the entities thus causing the error above.

I’m seeing the same thing here on both 0.5.0 and 0.5.1! The Lock Code Manager integration no longer seems to create the correct components for adding to the UI.

Can you put the integration into debug mode, reload it, and send me the resulting logs?

@raman325 Oops sorry for the delay, here are the relevant ones from creating a new Lock Code Manager

2024-06-18 09:55:12.896 INFO (MainThread) [custom_components.lock_code_manager] cd9b214b876072fe4afb73f82051eaf5 (House Locks): Creating and/or updating entities
2024-06-18 09:55:12.896 DEBUG (MainThread) [custom_components.lock_code_manager] cd9b214b876072fe4afb73f82051eaf5 (House Locks): Adding following locks: ['lock.u_bolt_pro_z_wave_smart_lock']
2024-06-18 09:55:12.896 DEBUG (MainThread) [custom_components.lock_code_manager.helpers] cd9b214b876072fe4afb73f82051eaf5 (House Locks): Created lock instance ZWaveJSLock(domain=zwave_js, lock=lock.u_bolt_pro_z_wave_smart_lock)
2024-06-18 09:55:12.896 DEBUG (MainThread) [custom_components.lock_code_manager] cd9b214b876072fe4afb73f82051eaf5 (House Locks): Creating lock instance for lock ZWaveJSLock(domain=zwave_js, lock=lock.u_bolt_pro_z_wave_smart_lock)
2024-06-18 09:55:12.896 DEBUG (MainThread) [custom_components.lock_code_manager] cd9b214b876072fe4afb73f82051eaf5 (House Locks): Lock lock.u_bolt_pro_z_wave_smart_lock is not connected to Home Assistant yet, waiting 1 seconds before retrying
2024-06-18 09:55:13.898 DEBUG (MainThread) [custom_components.lock_code_manager] cd9b214b876072fe4afb73f82051eaf5 (House Locks): Lock lock.u_bolt_pro_z_wave_smart_lock is not connected to Home Assistant yet, waiting 2 seconds before retrying
2024-06-18 09:55:15.899 DEBUG (MainThread) [custom_components.lock_code_manager] cd9b214b876072fe4afb73f82051eaf5 (House Locks): Lock lock.u_bolt_pro_z_wave_smart_lock is not connected to Home Assistant yet, waiting 4 seconds before retrying
2024-06-18 09:55:19.686 DEBUG (MainThread) [custom_components.lock_code_manager] 5f819289e1fb7ea3831fdde439ce7477 (House Locks): Lock lock.u_bolt_pro_z_wave_smart_lock is not connected to Home Assistant yet, waiting 180 seconds before retrying
2024-06-18 09:55:19.900 DEBUG (MainThread) [custom_components.lock_code_manager] cd9b214b876072fe4afb73f82051eaf5 (House Locks): Lock lock.u_bolt_pro_z_wave_smart_lock is not connected to Home Assistant yet, waiting 8 seconds before retrying

The lock is definitely connected to Home Assistant, as I can lock and unlock it directly using the lock services. It also used to work on a 0.4.x version of Lock Code Manager.

I just opened the manager for the first time in a month or so and everything is blank and showing unavailable. If I go into the Lock Manager Entity configuration the YAML shows my 6 pins. I’ve updated to the latest version and restarted HA, but still same issue?

Also, trying to figure out how to increase the number of pins to add new ones?

Here is the log file as requested. Sorry for the delay, have been out of town an unable to get access to system. Similar results as @ticknert posted. Lock works from within HA with no problem. Entity is lock.backdoor_deadbolt.

2024-06-25 00:16:30.588 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration lock_code_manager which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-06-25 00:16:40.457 DEBUG (MainThread) [custom_components.lock_code_manager] Exposed strategy module at /lock_code_manager_files/lock-code-manager-strategy.js
2024-06-25 00:16:40.457 DEBUG (MainThread) [custom_components.lock_code_manager] Strategy module already registered with resource ID d9a4197ef4ee4b9b81436191b63db45d
2024-06-25 00:16:40.457 DEBUG (MainThread) [custom_components.lock_code_manager] Finished setting up websocket API
2024-06-25 00:16:40.458 INFO (MainThread) [custom_components.lock_code_manager] 060455e6754d66150f203ceeca36c8a8 (Houe Locks): Creating and/or updating entities
2024-06-25 00:16:40.591 DEBUG (MainThread) [custom_components.lock_code_manager] 060455e6754d66150f203ceeca36c8a8 (Houe Locks): Adding following locks: ['lock.backdoor_deadbolt']
2024-06-25 00:16:40.592 DEBUG (MainThread) [custom_components.lock_code_manager.helpers] 060455e6754d66150f203ceeca36c8a8 (Houe Locks): Created lock instance ZWaveJSLock(domain=zwave_js, lock=lock.backdoor_deadbolt)
2024-06-25 00:16:40.592 DEBUG (MainThread) [custom_components.lock_code_manager] 060455e6754d66150f203ceeca36c8a8 (Houe Locks): Creating lock instance for lock ZWaveJSLock(domain=zwave_js, lock=lock.backdoor_deadbolt)
2024-06-25 00:16:40.592 DEBUG (MainThread) [custom_components.lock_code_manager] 060455e6754d66150f203ceeca36c8a8 (Houe Locks): Lock lock.backdoor_deadbolt is not connected to Home Assistant yet, waiting 1 seconds before retrying
2024-06-25 00:16:41.593 DEBUG (MainThread) [custom_components.lock_code_manager] 060455e6754d66150f203ceeca36c8a8 (Houe Locks): Lock lock.backdoor_deadbolt is not connected to Home Assistant yet, waiting 2 seconds before retrying
2024-06-25 00:16:43.594 DEBUG (MainThread) [custom_components.lock_code_manager] 060455e6754d66150f203ceeca36c8a8 (Houe Locks): Lock lock.backdoor_deadbolt is not connected to Home Assistant yet, waiting 4 seconds before retrying
2024-06-25 00:16:47.596 DEBUG (MainThread) [custom_components.lock_code_manager] 060455e6754d66150f203ceeca36c8a8 (Houe Locks): Lock lock.backdoor_deadbolt is not connected to Home Assistant yet, waiting 8 seconds before retrying
2024-06-25 00:16:55.598 DEBUG (MainThread) [custom_components.lock_code_manager] 060455e6754d66150f203ceeca36c8a8 (Houe Locks): Lock lock.backdoor_deadbolt is not connected to Home Assistant yet, waiting 16 seconds before retrying
2024-06-25 00:17:11.600 DEBUG (MainThread) [custom_components.lock_code_manager] 060455e6754d66150f203ceeca36c8a8 (Houe Locks): Lock lock.backdoor_deadbolt is not connected to Home Assistant yet, waiting 32 seconds before retrying
2024-06-25 00:17:43.600 DEBUG (MainThread) [custom_components.lock_code_manager] 060455e6754d66150f203ceeca36c8a8 (Houe Locks): Lock lock.backdoor_deadbolt is not connected to Home Assistant yet, waiting 64 seconds before retrying
2024-06-25 00:18:47.601 DEBUG (MainThread) [custom_components.lock_code_manager] 060455e6754d66150f203ceeca36c8a8 (Houe Locks): Lock lock.backdoor_deadbolt is not connected to Home Assistant yet, waiting 128 seconds before retrying
2024-06-25 00:20:55.602 DEBUG (MainThread) [custom_components.lock_code_manager] 060455e6754d66150f203ceeca36c8a8 (Houe Locks): Lock lock.backdoor_deadbolt is not connected to Home Assistant yet, waiting 180 seconds before retrying
2024-06-25 00:21:45.540 WARNING (MainThread) [homeassistant.bootstrap] Setup timed out for bootstrap waiting on {<Task pending name='Initial setup for entities for 060455e6754d66150f203ceeca36c8a8' coro=<async_update_listener() running at /config/custom_components/lock_code_manager/__init__.py:418> wait_for=<Future pending cb=[Task.task_wakeup()]> cb=[set.remove()]>} - moving forward
2024-06-25 00:23:55.604 DEBUG (MainThread) [custom_components.lock_code_manager] 060455e6754d66150f203ceeca36c8a8 (Houe Locks): Lock lock.backdoor_deadbolt is not connected to Home Assistant yet, waiting 180 seconds before retrying
2024-06-25 00:26:55.605 DEBUG (MainThread) [custom_components.lock_code_manager] 060455e6754d66150f203ceeca36c8a8 (Houe Locks): Lock lock.backdoor_deadbolt is not connected to Home Assistant yet, waiting 180 seconds before retrying
2024-06-25 00:29:55.607 DEBUG (MainThread) [custom_components.lock_code_manager] 060455e6754d66150f203ceeca36c8a8 (Houe Locks): Lock lock.backdoor_deadbolt is not connected to Home Assistant yet, waiting 180 seconds before retrying
2024-06-25 00:32:55.608 DEBUG (MainThread) [custom_components.lock_code_manager] 060455e6754d66150f203ceeca36c8a8 (Houe Locks): Lock lock.backdoor_deadbolt is not connected to Home Assistant yet, waiting 180 seconds before retrying

Same issue here unfortunately