feat: add Akuvox lock provider with event routing fixes#578
feat: add Akuvox lock provider with event routing fixes#578tykeal merged 1 commit intoFutureTense:mainfrom
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #578 +/- ##
==========================================
+ Coverage 84.14% 87.06% +2.91%
==========================================
Files 10 26 +16
Lines 801 3038 +2237
==========================================
+ Hits 674 2645 +1971
- Misses 127 393 +266
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds support for the local_akuvox integration as a new Keymaster lock provider, while also hardening coordinator event routing and startup behavior for concurrent config-entry initialization.
Changes:
- Added
AkuvoxLockProviderwith code-slot tagging ([KM:<slot>]) and webhook event translation, backed bylocal_akuvoxservice calls. - Updated coordinator event handling to infer lock/unlock from event labels (to avoid races with stale entity state), and ensured provider creation in an “already exists”
add_lockpath. - Expanded test coverage for the new provider and the concurrency/event-routing fixes.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
custom_components/keymaster/providers/akuvox.py |
New provider implementation for local_akuvox including code CRUD + webhook event subscription/translation. |
custom_components/keymaster/providers/__init__.py |
Registers AkuvoxLockProvider in PROVIDER_MAP. |
custom_components/keymaster/manifest.json |
Adds local_akuvox to after_dependencies for startup ordering. |
custom_components/keymaster/coordinator.py |
Adds label-based lock/unlock inference for provider events; ensures provider creation in add_lock when lock already exists. |
custom_components/keymaster/binary_sensor.py |
Replaces a hard assert on provider existence with a None check before adding the connectivity sensor. |
tests/providers/test_akuvox.py |
Comprehensive unit tests for Akuvox provider behavior (connect, CRUD, tagging, events, diagnostics). |
tests/test_coordinator_events.py |
Tests for label-overrides-stale-state behavior in provider event handling. |
tests/test_coordinator_lifecycle.py |
Tests that add_lock creates a provider when missing in the “already exists” path. |
tests/test_binary_sensor.py |
Tests binary-sensor setup behavior when provider is None / supported / unsupported. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add Local Akuvox (local_akuvox) as a supported lock provider for keymaster, enabling code slot management and event handling for Akuvox door controllers. Akuvox provider (providers/akuvox.py): - Maps keymaster slots to Akuvox users via [KM:<slot>] name tags - Handles webhook events: valid_code_entered, relay triggered/closed, input triggered/closed, invalid_code_entered - CRUD operations for user codes via local_akuvox service calls - Filters cloud-sourced users (source_type '2') from management - Accesses Akuvox coordinator via hass.data (not runtime_data) Provider registration: - Added AkuvoxLockProvider to PROVIDER_MAP in providers/__init__.py - Added local_akuvox to after_dependencies in manifest.json Coordinator event routing fix: - Fixed race condition where provider events arrive before entity state updates (e.g., Akuvox webhooks fire before lock entity shows unlocked) - Event label semantics now take priority: 'unlock' in label -> unlocked, 'lock' in label -> locked, ambiguous labels fall back to entity state - Compatible with existing Z-Wave labels (Manual Unlock, RF Lock, etc.) Binary sensor startup fix: - Replaced hard assert on kmlock.provider with graceful None check - Added provider creation in add_lock 'already exists' path to ensure provider is available before platform setup during concurrent entry init - Fixes AssertionError crash when HA sets up config entries concurrently Tests: - 48 tests for Akuvox provider (connect, codes, events, CRUD, diagnostics) - 3 tests for event label inference (label overrides stale state, fallback) - 3 tests for add_lock provider creation (None, already set, no config) - 3 tests for binary sensor setup (provider None, supported, unsupported) Co-authored-by: Copilot <copilot@github.com> Signed-off-by: Andrew Grimberg <tykeal@bardicgrove.org>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Add Local Akuvox (
local_akuvox) as a supported lock provider for keymaster, enabling code slot management and event handling for Akuvox door controllers.Changes
Akuvox provider (
providers/akuvox.py)[KM:<slot>]name tagshass.data(notruntime_data)Provider registration
AkuvoxLockProvidertoPROVIDER_MAPinproviders/__init__.pylocal_akuvoxtoafter_dependenciesinmanifest.jsonCoordinator event routing fix
Binary sensor startup fix
assertonkmlock.providerwith graceful None checkadd_lock'already exists' path to ensure provider is available before platform setup during concurrent entry initAssertionErrorcrash when HA sets up config entries concurrentlyTests