-
-
Notifications
You must be signed in to change notification settings - Fork 14
Using Condition Entities
Condition entities allow you to control when a PIN is active based on the state of another entity in Home Assistant. When a condition entity is configured for a slot, the PIN will only be active when:
- The slot is enabled
- Number of uses is disabled OR > 0
- The condition entity state is
on
Lock Code Manager supports the following entity types as conditions:
| Entity Type | Domain | Use Case |
|---|---|---|
| Calendar | calendar |
Schedule-based access with events (e.g., rental check-in/check-out times) |
| Schedule | schedule |
Simple recurring schedules (e.g., 9 AM - 5 PM weekdays) |
| Input Boolean | input_boolean |
Manual on/off toggle for access control |
| Switch | switch |
Control access via any switch entity |
| Binary Sensor | binary_sensor |
Control access via any binary sensor (great for template sensors!) |
Calendars are ideal for non-recurring or complex schedules. The integration checks if there's an ongoing event at the current time.
1:
pin: "1234"
entity_id: calendar.guest_accessFeatures:
- Shows current event name and end time in the UI
- Shows next upcoming event when no event is active
- Create calendars using integrations like
local_calendar
Tip: You can use a single calendar across multiple slots, or create separate calendars per slot.
Schedule entities are perfect for simple recurring patterns like business hours.
1:
pin: "1234"
entity_id: schedule.business_hoursFeatures:
- Shows when the schedule will next turn on/off in the UI
- Great for "every weekday 9-5" type schedules
For manual control, use an input boolean or switch. Toggle it on to enable access, off to disable.
1:
pin: "1234"
entity_id: input_boolean.guest_modeBinary sensors unlock the most flexibility. Use a template binary sensor to create complex conditions:
# Example: Only allow access when home is in guest mode AND it's daytime
template:
- binary_sensor:
- name: "Guest Access Allowed"
state: >
{{ is_state('input_boolean.guest_mode', 'on')
and is_state('sun.sun', 'above_horizon') }}Then reference it in your slot config:
1:
pin: "1234"
entity_id: binary_sensor.guest_access_allowedUse cases:
- Combine multiple conditions (guest mode + time of day + presence)
- Integrate with alarm systems (only allow access when disarmed)
- Weather-based access (e.g., allow contractor access only on non-rainy days)
These integrations are particularly useful for creating condition entities:
| Integration | Description |
|---|---|
| Template | Create binary sensors or switches with custom logic using Jinja2 templates. Great for combining multiple conditions. |
| MQTT | Create entities controlled by external systems. Useful when access logic is managed outside Home Assistant. |
| Group | Combine multiple binary sensors into one. Access granted when all/any conditions are met. |
| Workday | Binary sensor that's on on workdays (configurable for your country/region). |
| Time of Day | Binary sensor based on time ranges, including sunrise/sunset offsets. |
Know of another useful integration? Please edit this wiki page to add it!
Note: Some integrations create entities that appear compatible but have state semantics that don't work with LCM. See Unsupported Condition Entity Integrations for details.
If you previously used the calendar configuration key, your configuration will be automatically migrated to use entity_id. No action is required.
Before (v0.9.x and earlier):
1:
pin: "1234"
calendar: calendar.my_scheduleAfter (v1.0.0+):
1:
pin: "1234"
entity_id: calendar.my_scheduleWhen using helper entities (such as input_datetime, input_number, or input_boolean) alongside condition entities, you can display those helper controls directly within the LCM slot card using the condition_helpers configuration property. This lets users adjust condition parameters (for example, start/end dates for a date range condition) without navigating away from the LCM dashboard.
The condition_helpers property accepts a list of helper entity IDs to display inline for a given slot. It can be set at three levels:
Dashboard level — applies across all views and cards:
strategy:
type: custom:lock-code-manager
condition_helpers:
config_entry_id_here:
1:
- input_datetime.guest_start
- input_datetime.guest_endView level — applies to all cards in the view:
strategy:
type: custom:lock-code-manager
config_entry_id: abc123
condition_helpers:
1:
- input_datetime.guest_start
- input_datetime.guest_endCard level — applies to a single slot card:
type: custom:lcm-slot
config_entry_id: abc123
slot: 1
condition_helpers:
- input_datetime.guest_start
- input_datetime.guest_end- Create
input_datetime.guest_startandinput_datetime.guest_endhelpers. - Use the Date Range Condition blueprint to create a binary sensor from those helpers.
- Assign the binary sensor as the condition entity for the slot.
- Add
condition_helpersto your dashboard configuration so users can adjust the start/end dates directly from the slot card.
- One condition entity per slot: Each slot can only have one condition entity. For complex logic, use a template binary sensor to combine multiple conditions.
-
State must be
on: Access is granted when the entity state ison(or has an active event for calendars). All other states block access.
Getting Started
Features
- Blueprints
- Tracking lock state change events
- Using Condition Entities
- Unsupported Condition Entities
- Number of Uses (deprecated)
- Notifications
Advanced
Development
Troubleshooting
FAQ
Supported Integrations