-
Notifications
You must be signed in to change notification settings - Fork 11
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_schedule- 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
- Tracking lock state change events
- Using Condition Entities
- Unsupported Condition Entities
- Number of Uses
- Notifications
Advanced
Development
FAQ