Skip to content

Add HA blueprints for slot usage limiting and calendar integration#902

Open
raman325 wants to merge 4 commits intomainfrom
add-blueprints
Open

Add HA blueprints for slot usage limiting and calendar integration#902
raman325 wants to merge 4 commits intomainfrom
add-blueprints

Conversation

@raman325
Copy link
Owner

Proposed change

Add three Home Assistant blueprints that externalize slot usage tracking and calendar-based code slot management, keeping LCM lean while giving users more flexibility:

  • Slot Usage Limiter (automation): Decrements a user-created input_number helper each time a code slot PIN is used. Automatically disables the slot when the counter reaches 0. Optionally resets the counter when the slot is re-enabled.
  • Calendar Condition (template): Creates a binary_sensor that turns ON when a calendar event is active and an optional condition template is truthy. Users assign this sensor as the LCM slot's condition entity.
  • Calendar PIN Setter (automation): Extracts PINs from calendar event attributes using a user-provided Jinja2 template and sets them on LCM code slots via text.set_value. Optionally clears the PIN when the event ends.

All blueprints derive LCM entity IDs automatically from a config_entry selector + slot number using integration_entities() and config_entry_attr().

Also excludes blueprints/ from the check-yaml pre-commit hook since HA's !input YAML tag is not recognized by standard YAML loaders.

Type of change

  • New feature (which adds functionality)

Additional information

  • Blueprint files live in blueprints/automation/lock_code_manager/ and blueprints/template/lock_code_manager/
  • The Calendar Condition blueprint's condition_template variable is evaluated at template entity load time (and on HA template reload), not dynamically on each calendar event change. For the default {{ true }}, the sensor dynamically tracks calendar on/off state. This limitation is documented in the blueprint description.

🤖 Generated with Claude Code

Introduce three Home Assistant blueprints that externalize slot usage
tracking and calendar-based code slot management:

- Slot Usage Limiter (automation): Decrements an input_number helper on
  each PIN use and disables the slot at zero. Supports auto-reset on
  re-enable.
- Calendar Condition (template): Creates a binary_sensor that activates
  when a calendar event is active, with optional condition template
  filtering. Assignable as an LCM slot condition entity.
- Calendar PIN Setter (automation): Extracts PINs from calendar event
  attributes via user-provided templates and sets them on LCM slots.
  Optionally clears the PIN when the event ends.

Also excludes blueprints/ from the check-yaml pre-commit hook since
HA's !input YAML tag is not recognized by standard YAML loaders.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: ac889c35c3d6
@github-actions github-actions bot added dependencies Pull requests that update a dependency file pre-commit Pull requests that update pre-commit enhancement New feature or request labels Mar 12, 2026
@raman325 raman325 marked this pull request as ready for review March 12, 2026 05:52
Copilot AI review requested due to automatic review settings March 12, 2026 05:52
Link to the three LCM blueprints (Slot Usage Limiter, Calendar
Condition, Calendar PIN Setter) with My Home Assistant import
badges and a pointer to the wiki for setup details.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 53d0b0eb198b
@raman325 raman325 linked an issue Mar 12, 2026 that may be closed by this pull request
@github-actions github-actions bot added the documentation Documentation changes label Mar 12, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds Home Assistant blueprints to extend Lock Code Manager (LCM) with externalized automations for slot usage limiting and calendar-driven PIN/condition management, and updates pre-commit configuration to accommodate HA blueprint YAML tags.

Changes:

  • Added an automation blueprint to decrement a remaining-uses counter on PIN use and disable the slot at 0.
  • Added a template blueprint that exposes a calendar-driven binary_sensor intended for use as an LCM slot condition entity.
  • Added an automation blueprint to set/clear slot PINs based on active calendar events.
  • Excluded blueprints/ from the check-yaml pre-commit hook due to HA’s !input tag.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.

File Description
blueprints/template/lock_code_manager/calendar_condition.yaml Adds a template blueprint providing a calendar + template-gated binary_sensor for LCM slot conditions.
blueprints/automation/lock_code_manager/slot_usage_limiter.yaml Adds an automation blueprint to track remaining uses and disable the slot when depleted.
blueprints/automation/lock_code_manager/calendar_pin_setter.yaml Adds an automation blueprint to set/clear LCM slot PINs from calendar event attributes.
.pre-commit-config.yaml Excludes HA blueprints from check-yaml to avoid failures on !input.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

raman325 and others added 2 commits March 12, 2026 01:58
…_ids

- slot_usage_limiter: document that code slot event support is required
- calendar_condition: clarify lock_entity_ids only includes event-capable locks

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 80f667d28c48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Documentation changes enhancement New feature or request pre-commit Pull requests that update pre-commit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 calendar entity to rule all the slots

2 participants