Skip to content

Commit 5f19a01

Browse files
raman325claude
andcommitted
Improve logging for lock reset silent skip and failure paths
- Raise usercode fetch failure from debug to warning level - Add warning log when lock_config_entry is None - Add warning log when entity missing from registry - Add debug log for unsupported platform (expected skip) - Add warning log when lock instance missing in clear/adopt paths Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 297e64ce4d52
1 parent 0a87a96 commit 5f19a01

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

custom_components/lock_code_manager/config_flow.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,21 +137,37 @@ async def _async_get_unmanaged_codes(
137137
lock_instances: dict[str, Any] = {}
138138
for lock_entity_id in lock_entity_ids:
139139
lock_entry = ent_reg.async_get(lock_entity_id)
140-
if not lock_entry or lock_entry.platform not in INTEGRATIONS_CLASS_MAP:
140+
if not lock_entry:
141+
_LOGGER.warning(
142+
"Entity %s not found in registry; skipping usercode check",
143+
lock_entity_id,
144+
)
145+
continue
146+
if lock_entry.platform not in INTEGRATIONS_CLASS_MAP:
147+
_LOGGER.debug(
148+
"Lock %s uses unsupported platform %s; skipping usercode check",
149+
lock_entity_id,
150+
lock_entry.platform,
151+
)
141152
continue
142153
lock_config_entry = hass.config_entries.async_get_entry(
143154
lock_entry.config_entry_id
144155
)
145156
if lock_config_entry is None:
157+
_LOGGER.warning(
158+
"Config entry for lock %s not found; skipping usercode check",
159+
lock_entity_id,
160+
)
146161
continue
147162
lock_instance = INTEGRATIONS_CLASS_MAP[lock_entry.platform](
148163
hass, dev_reg, ent_reg, lock_config_entry, lock_entry
149164
)
150165
try:
151166
usercodes = await lock_instance.async_internal_get_usercodes()
152167
except Exception: # noqa: BLE001
153-
_LOGGER.debug(
154-
"Failed to get usercodes from %s during lock reset check",
168+
_LOGGER.warning(
169+
"Failed to get usercodes from %s during lock reset check; "
170+
"this lock's codes will not be shown",
155171
lock_entity_id,
156172
exc_info=True,
157173
)
@@ -265,6 +281,10 @@ async def async_step_lock_reset_clear(
265281
for lock_entity_id, codes in self._unmanaged_codes.items():
266282
lock_instance = self._lock_instances.get(lock_entity_id)
267283
if not lock_instance:
284+
_LOGGER.warning(
285+
"No lock instance for %s; cannot clear unmanaged codes",
286+
lock_entity_id,
287+
)
268288
continue
269289
for slot in codes:
270290
try:
@@ -314,6 +334,10 @@ async def async_step_lock_reset_adopt(
314334
continue
315335
lock_instance = self._lock_instances.get(lock_entity_id)
316336
if not lock_instance:
337+
_LOGGER.warning(
338+
"No lock instance for %s; cannot clear masked codes",
339+
lock_entity_id,
340+
)
317341
continue
318342
for slot in masked_slots:
319343
try:

0 commit comments

Comments
 (0)