Skip to content

feat: add a Yale Access Bluetooth (yalexs_ble) provider - #1855

Open
drgreenbaum wants to merge 3 commits into
raman325:mainfrom
drgreenbaum:yalexs-ble-provider
Open

drgreenbaum wants to merge 3 commits into
raman325:mainfrom
drgreenbaum:yalexs-ble-provider

Conversation

@drgreenbaum

Copy link
Copy Markdown

Proposed change

Adds a provider for Yale Access Bluetooth (yalexs_ble), so Lock Code Manager can manage keypad PINs on Yale/August locks over local Bluetooth, without the Yale cloud or a bridge.

It uses the keypad credential actions proposed in home-assistant/core#185596 (named and shaped like the Matter lock credential actions):

LCM operation yalexs_ble action
set a PIN set_lock_credential (credential_type: pin, credential_data, credential_index, name)
clear a slot clear_lock_credential (after get_lock_credential_status shows it occupied)
read occupancy get_lock_credential_status → credential_exists
  • PINs are write-only through those actions (the status never returns the PIN), so occupied slots read as SlotCredential.unreadable() and empty ones as empty(), the same model as Schlage.
  • Code events: the integration fires yalexs_ble_lock_activity when the lock's activity log shows an operation. A keypad unlock with a slot (source: pin, slot: N) is recorded through async_fire_code_slot_event. Manual operations, the keypad's lock button (slot: None) and the master code record nothing.
  • Capabilities: PIN only, slots 1–250, 4–8 digits (what the integration validates).
  • Availability follows the lock entity (each slot read is a Bluetooth round trip), and the usercode scan interval is 15 minutes.
  • Registered in INTEGRATIONS_CLASS_MAP, yalexs_ble is added to after_dependencies, and there is a README row with a footnote pointing at the core PR.

Status of the dependency: home-assistant/core#185596 is not merged yet, so on a stock Home Assistant release the actions don't exist and the provider can't do anything. I'm opening this as a draft so it is ready when the core PR lands. It is happy to wait.

Tested on hardware (HA 2026.11.3 with #185596 installed as a custom integration): a Yale Doorman L3 (Yale Access module MD-02) and a Yale Smart Code Handle (CERES), both always connected. I created users from the config flow and the dashboard strategy, sync went green, the codes work at the keypads, and credential_used events fire with the right user. (The handle additionally needs Yale-Libs/yalexs-ble#448 for its keypad credential type.)

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (which adds functionality)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Tests: tests/providers/yalexs_ble/ (26 tests: shared connection and native-transport mixins, occupancy, set/clear, refusal → CodeRejectedError, malformed status, activity-event attribution and listener lifecycle). The full suite passes locally: 3668 passed, 2 skipped, 2 xfailed. ruff check / ruff format --check are clean.

🤖 Generated with Claude Code

Manages keypad PINs on Yale and August locks through the Yale Access
Bluetooth integration's keypad credential actions
(home-assistant/core#185596): set_lock_credential, clear_lock_credential and
get_lock_credential_status.

PINs are write-only through those actions, so occupied slots read as
unreadable and empty slots as empty, as for Schlage. Code uses come from the
yalexs_ble_lock_activity bus event: a keypad unlock with a slot is recorded
as that slot's PIN being used; manual operations, the keypad's lock button
and the master code record nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KQD9t6v8C3VpjfDu7jZNKN
@github-actions github-actions Bot added python Pull requests that update Python code documentation Documentation changes enhancement New feature or request labels Nov 25, 2026
@drgreenbaum
drgreenbaum marked this pull request as ready for review November 25, 2026 20:13

@raman325 raman325 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for this — a Yale Access Bluetooth provider is a welcome addition. Inline comments below; the first three are behavior bugs worth fixing before merge (missing per_exchange_budget, activity events dropped for the secure-mode lock entity, stale names on nameless sets), the rest are nits.

One more nit that has no line to anchor to: per AGENTS.md, please add yalexs_ble.py to the Providers System list there, and add tests/providers/yalexs_ble/test_e2e.py (step 8 lists conftest.py, test_provider.py, test_e2e.py for every provider — Schlage's fake service is a good model).

🤖 Generated with Claude Code

- Declare per_exchange_budget (300 s): the provider reads one slot per
  Bluetooth keycode exchange, and yalexs-ble retries an operation up to four
  times, each a connect plus up to three 10 s response waits.
- Clear the slot before a nameless set, so the integration forgets the
  previous holder's name (set_lock_credential stores a name only when given).
- Hard refresh reads the managed slots plus the slots asked for.
- Match activity events on the lock's device, not the entity id: the
  integration fires them for its main lock entity, also when the provider
  manages the secure-mode lock entity of the same lock.
- Tests: core's real errors (pin_already_in_use, communication_error), the
  nameless set, device matching, hard refresh, budget; a stateful fake of the
  credential actions and test_e2e.py (setup writes and sync, a PIN change, a
  refusal that disables the slot once, a keypad unlock recorded as the user's).
- AGENTS.md: list yalexs_ble.py among the providers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KQD9t6v8C3VpjfDu7jZNKN
@drgreenbaum

Copy link
Copy Markdown
Author

Thanks for the thorough review. Everything is addressed in f7598b5, committed forward:

  • Behavior fixes: per_exchange_budget (300 s), clearing the slot before a nameless set so the old holder's name is dropped, and matching activity events on the lock's device (the secure-mode entity now hears them).
  • Nits: the hard refresh honours slots; tests use core's real pin_already_in_use / communication_error; yalexs_ble.py is listed in AGENTS.md.
  • test_e2e.py with a stateful fake of the three credential actions (fake_service.py, modelled on Schlage's). It covers setup writing named PINs and reporting in sync, a PIN change, a refusal from a code LCM doesn't manage disabling the slot once without a retry loop, and a keypad unlock firing lock_code_manager_credential_used for the user.

Tests: tests/providers/yalexs_ble/ has 36 passing tests. The full suite gives 3677 passed, 2 skipped, 2 xfailed, plus one failure in tests/providers/zwave_js/test_e2e.py::TestPacing::test_writes_at_startup_are_spaced under full-suite load; it passes 3/3 on its own and touches nothing here. ruff check / ruff format --check are clean.

🤖 Generated with Claude Code

The Smart Code Handle (model CERES) keeps user PINs in slots 1-99 (its
master code is slot 0) and refuses KEYCODE_COMMIT for slot 100 and up with
NACK 0x3B, found by writing slots on the device. Report that capacity for
the model, read from the device registry, so slot allocation never picks a
slot the handle refuses; other models keep the 250 the integration validates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KQD9t6v8C3VpjfDu7jZNKN
@drgreenbaum

Copy link
Copy Markdown
Author

One more forward commit, 5d3d1a2: the Yale Smart Code Handle (CERES) refuses KEYCODE_COMMIT for slot 100 and up (NACK 0x3B, measured on the device: slots 1–99 accepted, 0 is its master code), so the provider now reports 99 PIN slots for that model, read from the device registry, and 250 otherwise. Test: test_smart_code_handle_has_99_pin_slots.

@raman325 raman325 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for the quick and thorough follow-up. I checked every fix against core#185596 and they all hold up: the event does carry ATTR_DEVICE_ID, _clear_credential drops the stored name, and two 300 s exchanges still fit the flat 600 s write timeout. Keeping TestNativeTransportContract is fine.

One question inline about the clear-first path. Otherwise this looks ready.

🤖 Generated with Claude Code

if name:
data["name"] = name
async with self._serialize_sequence():
if not name:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Question: this now runs clear_keycode on slots that may already be empty, e.g. the first write to a fresh slot. Does a Yale lock accept clearing an empty slot? If it NACKs that (the way the Smart Code Handle NACKs slot 100+), core raises communication_error and every nameless set to an unused slot fails before the set runs. If you can try a nameless set on an empty slot on your hardware, that settles it. If it does reject, catching that specific refusal and going on to the set would keep the fix.

@codecov

codecov Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.10714% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 98.90%. Comparing base (726290b) to head (5d3d1a2).
⚠️ Report is 20 commits behind head on main.

Files with missing lines Patch % Lines
...mponents/lock_code_manager/providers/yalexs_ble.py 99.09% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1855      +/-   ##
==========================================
- Coverage   98.91%   98.90%   -0.02%     
==========================================
  Files          73       74       +1     
  Lines       10357    10469     +112     
  Branches      599      599              
==========================================
+ Hits        10245    10354     +109     
- Misses        112      115       +3     
Flag Coverage Δ
python 99.41% <99.10%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...components/lock_code_manager/providers/__init__.py 100.00% <100.00%> (ø)
...mponents/lock_code_manager/providers/yalexs_ble.py 99.09% <99.09%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@raman325 raman325 added the lcm-minor Minor version bump label Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Documentation changes enhancement New feature or request lcm-minor Minor version bump python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants