Skip to content

Using Condition Entities

raman325 edited this page Jan 15, 2026 · 1 revision

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:

  1. The slot is enabled
  2. Number of uses is disabled OR > 0
  3. The condition entity state is on

Supported Entity Types

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!)

Calendar Entities

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_access

Features:

  • 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

Schedule entities are perfect for simple recurring patterns like business hours.

1:
  pin: "1234"
  entity_id: schedule.business_hours

Features:

  • Shows when the schedule will next turn on/off in the UI
  • Great for "every weekday 9-5" type schedules

Input Boolean / Switch Entities

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_mode

Binary Sensor Entities (Template Sensors)

Binary 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_allowed

Use 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)

Migration from calendar (v1.0.0+)

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_schedule

After (v1.0.0+):

1:
  pin: "1234"
  entity_id: calendar.my_schedule

Limitations

  • 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 is on (or has an active event for calendars). All other states block access.

Clone this wiki locally