-
-
Notifications
You must be signed in to change notification settings - Fork 18
Blueprints
The Condition Linker takes a name in 6.0. It used to take a slot number, and it called an action that 6.0 removed. An automation already created from it has to be reconfigured with the person's Name — or simply recreated, since it is a one-shot. See Upgrading to 6.0.
Entity IDs changed in 5.0. Blueprints take entity IDs as inputs, and every Lock Code Manager entity was renamed from its slot number onto its user's name when you upgraded —
..._code_slot_1_pinbecame..._raman_pin. Home Assistant does not rewrite IDs stored inside an automation, so automations built from these blueprints before 5.0 need their inputs repointed. The upgrade leaves a notification listing every rename. See Upgrading to 5.0.
Lock Code Manager provides Home Assistant blueprints for advanced automation use cases. These blueprints let you build custom workflows on top of LCM without modifying the integration itself.
Import them using the buttons below, or copy the YAML files from the blueprints/ directory in the repository.
Type: Automation
Decrements an input_number helper each time a user's credential is used. When the counter reaches 0, the user is automatically disabled. Optionally resets the counter when the user is enabled again.
- Create an
input_numberhelper (Settings → Devices & Services → Helpers) with min=0, max=your desired limit, and step=1. - Import this blueprint using the button above.
- Create a new automation from the blueprint and pick the user's credential used event entity, their enabled switch, and the helper you created.
| Input | Description | Default |
|---|---|---|
| Credential used event entity | The user's credential_used event entity. |
(required) |
| Slot enabled switch | The user's enabled switch, turned off when the counter hits 0. |
(required) |
| Uses counter | An input_number helper that tracks remaining uses. |
(required) |
| Operations that spend a use | Which uses decrement the counter, by what the device did — unlock, lock, unknown. |
unlock, unknown
|
| Locks (optional) | Restrict to a specific lock or set of locks. Empty counts every use. | (all) |
| Initial uses on re-enable | When > 0, the counter resets to this value each time the user is enabled again. Set to 0 to disable auto-reset. | 0 |
| Notification service (optional) | A notify entity messaged when uses are exhausted and the user is disabled. | (none) |
Why
lockis off by default. Since 5.3.0 a credential that locks a door is recorded too. A guest who unlocks with their PIN and locks up behind them with the same PIN would otherwise spend two uses — locking themselves out of a one-use code for being polite. Uses reported throughlock_code_manager.use_credentialare alwaysunknown, since nothing told Lock Code Manager what happened next.
Note: This blueprint replaces the built-in Number of Uses feature (removed in 2.0) with an
input_number-based approach. It provides external visibility into the remaining count and allows programmatic reset via automations or the UI.
Type: Template (binary sensor)
Creates a binary sensor that turns ON when a calendar event is active and an optional condition template is truthy. Assign the resulting binary sensor as the condition entity for a Lock Code Manager user.
- Import this blueprint using the button above.
- Configure it with your LCM config entry, slot number, calendar entity, and optionally a condition template.
- The blueprint creates a binary sensor — assign it as that user's condition entity.
| Input | Description | Default |
|---|---|---|
| Lock Code Manager config entry | The LCM config entry that manages your lock(s). | (required) |
| Slot number | The code slot number. Can be a static number or a Jinja2 template using calendar event attributes. | (required) |
| Calendar entity | The calendar entity whose events control this condition. | (required) |
| Condition template | A Jinja2 template that must evaluate to truthy for the sensor to turn ON (in addition to the calendar being active). | {{ true }} |
Your condition template can use these variables:
| Variable | Description |
|---|---|
message |
Calendar event summary/title |
description |
Calendar event description |
location |
Calendar event location |
start_time |
Event start time |
end_time |
Event end time |
all_day |
Whether the event is an all-day event |
slot_number |
The resolved slot number |
config_entry_title |
The LCM config entry title |
name_state |
The current name of the code slot |
- Allow when event title contains "Guest":
{{ 'Guest' in message }} - Allow only during business hours:
{{ 8 <= now().hour < 18 }}
lock_entity_idswas removed in 5.3.0 — check your logs after upgrading.A condition template still referencing it fails quietly: Home Assistant treats an undefined variable as empty rather than an error, so the binary sensor stays available, reads
off, and the PIN never activates. The only signal is a log line —Template variable warning: 'lock_entity_ids' is undefined when rendering .... Nothing else will tell you. Remove the reference to fix the sensor.There is no replacement, and it was not worth keeping: the list was the same for every slot in the config entry, so
{{ 'lock.front_door' in lock_entity_ids }}could only ever be constantly true or constantly false. A condition entity gates a user across every lock in the entry; it cannot gate one lock.
Note: The condition template and calendar attributes are evaluated when the sensor is first loaded and when Home Assistant reloads template entities. For the default
{{ true }}, the sensor dynamically tracks the calendar on/off state. For conditions that reference event attributes, reload template entities after calendar event changes to re-evaluate.
Type: Template (binary sensor)
Creates a binary sensor that turns ON when the current time is between two input_datetime helper entities. Assign the resulting binary sensor as the condition entity for a Lock Code Manager user.
- Create two
input_datetimehelpers (Settings → Devices & Services → Helpers) — one for the start date/time and one for the end date/time. Enable both "Date" and "Time" on each helper. - Import this blueprint using the button above.
- Configure it with your start and end date/time helpers.
- The blueprint creates a binary sensor — assign it as that user's condition entity.
| Input | Description | Default |
|---|---|---|
| Start date/time | An input_datetime helper that defines when the access window begins. |
(required) |
| End date/time | An input_datetime helper that defines when the access window ends. |
(required) |
Give a guest temporary access for a specific date range:
- Create
input_datetime.guest_startandinput_datetime.guest_endhelpers. - Set the start to your guest's arrival date/time and end to their departure.
- Import this blueprint and select both helpers.
- Assign the resulting binary sensor as the guest's condition entity.
Tip: You can display the
input_datetimehelpers inline in the LCM dashboard using thecondition_helpersconfiguration property. See Using Condition Entities for details.
Type: Automation (one-shot)
Calls lock_code_manager.set_condition to wire a condition entity to one person. This provides a UI-friendly way to assign condition entities without editing YAML.
- Import this blueprint using the button above.
- Create a new automation from the blueprint and configure it with your LCM config entry, the person's name, and the condition entity you want to assign.
- Manually run the automation once from the Automations page (three-dot menu → Run).
- The condition entity is now assigned to that person. You can delete the automation afterward or keep it for reference.
| Input | Description | Default |
|---|---|---|
| Lock Code Manager config entry | The LCM config entry that manages your lock(s). | (required) |
| Name | The name of the person to assign the condition entity to, as it appears in Lock Code Manager. Matched ignoring case and surrounding spaces. | (required) |
| Condition entity | The entity to use as the condition. Supports binary_sensor, calendar, input_boolean, schedule, and switch domains. |
(required) |
Note: This automation uses a synthetic event trigger that never fires on its own. You must manually run it from the UI.
Type: Automation
Extracts a PIN from calendar event attributes using a user-provided template and sets it on a Lock Code Manager code slot. Optionally clears the PIN when the calendar event ends.
- Import this blueprint using the button above.
- Create a new automation from the blueprint and configure it with your LCM config entry, calendar entity, slot number, and a PIN template.
- When a calendar event starts, the PIN is extracted and set on the slot. When it ends (if enabled), the PIN is cleared.
| Input | Description | Default |
|---|---|---|
| Lock Code Manager config entry | The LCM config entry that manages your lock(s). | (required) |
| Slot number | The code slot number. Can be a static number or a Jinja2 template using calendar event attributes. | (required) |
| Calendar entity | The calendar entity whose events provide PIN codes. | (required) |
| PIN template | A Jinja2 template that extracts a PIN from calendar event attributes. Must evaluate to a non-empty string. | (required) |
| Clear PIN when event ends | When enabled, the PIN is cleared when the calendar event ends. | true |
| Notification service (optional) | A notify entity messaged when PINs are set or cleared. | (none) |
Your PIN and slot number templates can use these variables:
| Variable | Description |
|---|---|
message |
Calendar event summary/title |
description |
Calendar event description |
location |
Calendar event location |
start_time |
Event start time |
end_time |
Event end time |
all_day |
Whether the event is an all-day event |
- Extract a 4-digit PIN from description:
{{ description | regex_findall('\b\d{4}\b') | first | default('') }} - Use the first 4 characters of the event title:
{{ message[:4] if message | length >= 4 else '' }}
The Calendar Condition and Calendar PIN Setter blueprints ask for a slot number, and nothing in the user interface shows you one — Lock Code Manager assigns each user a slot and manages it for you, so the configuration dialogs and the dashboard cards deliberately never mention it. Those two still take one because the number can come from a template over the calendar event. Every action, and every other blueprint, addresses the person instead.
To find the number for a user, open any of that user's entities and look at
its code_slot attribute. In a template:
{{ state_attr('text.all_locks_raman_pin', 'code_slot') }}The number is stable: renaming a user does not change it, which is why renaming is free. It only changes if you remove the user and add them again.
These blueprints can be combined with each other and with Home Assistant's built-in features for more advanced workflows. Each blueprint controls a different aspect of the same slot independently.
Give a cleaning crew a code that's only active during scheduled times and expires after a set number of uses:
- Calendar Condition — Create a binary sensor from your cleaning schedule calendar. Assign it as the condition entity of the Cleaners user (slot 3 in the blueprint). The code is only active during scheduled cleaning events.
- Slot Usage Limiter — Set up a usage counter for Cleaners with a limit of 5 uses and auto-reset on re-enable.
How it works:
- When a cleaning event starts, the calendar condition turns ON → LCM activates the code on the lock
- Each time the code is used, the usage limiter decrements the counter
- If the crew uses the code 5 times, Cleaners is disabled (even during an active event)
- When the event ends, the calendar condition turns OFF → LCM clears the code
- Next event: Cleaners is enabled again → counter resets to 5
Combine all three blueprints for a fully automated guest access system:
- Calendar Condition for the Guest user (slot 3) → code only active during the booking
- Calendar PIN Setter for Guest (slot 3) → PIN extracted from the booking description (e.g. "Check-in code: 5678")
- Slot Usage Limiter for Guest → max 10 uses during the stay
LCM's condition entity accepts any binary_sensor. Use Home Assistant's Group integration to combine multiple conditions into one:
- Create a group of binary sensors (e.g. calendar condition + presence sensor)
- The group turns ON when all members are ON (default) or any member is ON
- Assign the group entity as the user's condition entity
Example: Code active only during a calendar event AND when the home is in "away" mode:
- Calendar Condition →
binary_sensor.guest_calendar_active - Template sensor →
binary_sensor.home_is_away(based on alarm state) - Group →
binary_sensor.guest_access_conditions(all must be ON) - Assign the group as the user's condition entity
For logic that doesn't fit neatly into blueprints or groups, create a Template binary sensor and assign it as the condition entity:
template:
- binary_sensor:
- name: "Slot 3 Active"
state: >
{{ is_state('calendar.guest_bookings', 'on')
and states('input_number.guest_uses') | int > 0
and is_state('alarm_control_panel.home', 'armed_away') }}This gives full Jinja2 flexibility for combining any Home Assistant states into a single condition.
Type: Automation
Automatically re-locks a lock after it has been unlocked for a configurable amount of time. Supports separate day and night delays based on the sun entity's state (sunrise/sunset).
- Import this blueprint using the button above.
- Select the lock entity to auto-relock.
- Set the day delay (in minutes). Default: 5 minutes.
- Optionally set a night delay. Set to 0 to use the day delay for both day and night.
| Input | Description | Default |
|---|---|---|
| Lock | The lock entity to auto-relock. | (required) |
| Day delay (minutes) | How long to wait before auto-relocking during the day. | 5 |
| Night delay (minutes) | How long to wait at night (between sunset and sunrise). Set to 0 to use the day delay for both. | 0 |
Note: Uses
mode: restart— if the lock is unlocked again while the timer is running, the timer resets. If the lock is locked before the timer expires, the lock command is skipped.
Note: Night detection uses the
sun.sunentity (Home Assistant Sun integration). If the Sun integration is not enabled, the night delay will never apply.
Type: Automation
Automatically locks a lock when a door sensor detects the door has closed while the lock is unlocked. Useful for ensuring the door is always locked when closed.
- Import this blueprint using the button above.
- Select the lock entity to control.
- Select the door sensor (binary_sensor with door device class).
- Optionally set a delay before locking. Default: 5 seconds.
| Input | Description | Default |
|---|---|---|
| Lock | The lock entity to control. | (required) |
| Door sensor | A binary sensor that detects open/closed state (on = open, off = closed). | (required) |
| Lock delay (seconds) | How long to wait after the door closes before locking. Set to 0 to lock immediately. | 5 |
Note: Uses
mode: singleto prevent duplicate lock commands. Only locks if the lock is currently unlocked when the door closes.
Type: Automation
Runs one or more actions every time a credential is used — whether Lock Code Manager saw a lock report it, or was told through lock_code_manager.use_credential.
All three see the same uses. The difference is what they trigger on:
-
Slot Usage Notifier and Slot Usage Limiter trigger on one user's
credential_usedentity, so each automation covers the users you point it at. Reach for these when you want the focused, per-user recipe. -
Credential Used triggers on the
lock_code_manager_credential_usedevent, so one automation covers every user in every configuration, and its filters narrow from there. Reach for this when you want the whole picture.
| Input | Description | Default |
|---|---|---|
| Actions | HA actions to run when a credential is used. | (required) |
| Lock Code Manager config entry (optional) | Only act on uses from this configuration. | (all) |
| Users (optional) | Only act on these users, by name. | (all) |
| Sources (optional) | Only act on uses entered at these entities. | (all) |
| Targets (optional) | Only act on uses against these entities. | (all) |
| Variable | Description |
|---|---|
name |
The user whose credential was used |
source |
The entity ID where the credential was entered |
target |
The entity ID it was used against |
This is the blueprint to use for an external keypad opening something Lock Code Manager doesn't manage — a cover, a relay, an alarm panel. See External Keypads.
Type: Automation
Runs actions when a user's credential is used on a lock. Use it to send notifications, trigger scripts, or run any HA action. Uses the HA action selector for full flexibility.
- Import this blueprint using the button above.
- Select the credential used event entity of each user to watch (e.g., "Raman Credential used").
- Configure the actions to run when the PIN is used (notifications, scripts, etc.).
| Input | Description | Default |
|---|---|---|
| Credential used event entities | One or more users' credential_used event entities. |
(required) |
| Locks (optional) | Restrict to a specific lock or set of locks. Empty runs for any lock the event entity reports. | (all) |
| Actions | HA actions to run when a credential is used (notifications, scripts, etc.). | (required) |
Your actions can reference these variables in templates:
| Variable | Description |
|---|---|
slot_name |
The name of the user whose credential was used |
slot_num |
The user's slot number |
lock_name |
Friendly name of the lock where the credential was used |
timestamp |
Date and time the event occurred (YYYY-MM-DD HH:MM:SS) |
operation |
What the device did with the credential: unlock, lock, or unknown
|
Note: Requires a lock that reports credential use (produces
*_credential_usedevents;*_code_slot_*_pin_usedbefore 5.0). Usesmode: queuedwith max 10 to handle rapid successive uses.
Getting Started
- Upgrading to 6.0
- Upgrading to 5.0
- Configuration Structure
- Adding and Removing Locks
- Migrating from keymaster
UI
Features
- Managing Guests and Rentals
- Services and Actions
- Blueprints
- Tracking lock state change events
- Using Condition Entities
- Unsupported Condition Entities
Advanced
Development
Troubleshooting
FAQ
Supported Integrations