feat: add keymaster/list_locks websocket command for dashboard strategy#543
Conversation
The config_entries/get WebSocket API does not return the 'data' field (it's excluded for security reasons). Use 'title' instead, which contains the lock name set during config flow. Fixes dashboard strategy showing "No Keymaster configurations found!" for fully managed dashboards. Introduced in FutureTense#536. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where the dashboard strategy was attempting to access entry.data.lockname, which is not available because Home Assistant's config_entries/get WebSocket API intentionally excludes the data field for security reasons. The fix uses entry.title instead, which contains the lock name.
Changes:
- Removed the
datafield from theKeymasterConfigEntryinterface - Updated all references from
entry.data.locknametoentry.titlein the dashboard strategy - Updated tests to reflect the new structure and validation logic
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lovelace_strategy/types.ts | Removed data field from KeymasterConfigEntry interface and added documentation explaining the API behavior |
| lovelace_strategy/dashboard-strategy.ts | Updated filtering, sorting, and title assignment to use entry.title instead of entry.data.lockname |
| lovelace_strategy/dashboard-strategy.test.ts | Updated mock factory and test cases to remove data field and validate title filtering |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## beta #543 +/- ##
==========================================
+ Coverage 80.86% 81.86% +0.99%
==========================================
Files 19 28 +9
Lines 2341 2569 +228
Branches 0 24 +24
==========================================
+ Hits 1893 2103 +210
- Misses 448 466 +18
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:
|
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace config_entries/get with a custom keymaster/list_locks command that returns entry_id and lock_name directly. This avoids issues with HA's config_entries/get API not exposing the 'data' field. Changes: - Add ws_list_locks to websocket.py - Update dashboard-strategy.ts to use keymaster/list_locks - Simplify types.ts with KeymasterLockEntry - Update tests Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update test_async_setup_registers_commands for 3 commands - Add test_ws_list_locks_returns_all_locks - Add test_ws_list_locks_empty_when_no_entries Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Only return enabled config entries from the keymaster/list_locks WebSocket command. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
Add a new
keymaster/list_locksWebSocket command that returnsentry_idandlock_namefor all configured locks. This replaces the use of Home Assistant's genericconfig_entries/getAPI which excludes thedatafield for security reasons.Proposed change
ws_list_locksWebSocket command towebsocket.pythat returns a list of locks withentry_idandlock_namedashboard-strategy.tsto usekeymaster/list_locksinstead ofconfig_entries/gettypes.tswith newKeymasterLockEntryinterfaceType of change
Additional information
🤖 Generated with Claude Code