فهرست منبع

Log copy_slots progress per slot for migration sanity-checking

Info-level logs at start (slots found on source/target), per copied
slot (code/name status), per deleted target-only slot, and completion.
Should also help diagnose why one lock's slot 250 wasn't copied on a
recent run — the source-slot listing at start will show whether it was
even present in get_users().
ZiB 3 ماه پیش
والد
کامیت
b8ae243951
1فایلهای تغییر یافته به همراه20 افزوده شده و 0 حذف شده
  1. 20 0
      custom_components/zlock_slots/services.py

+ 20 - 0
custom_components/zlock_slots/services.py

@@ -203,10 +203,20 @@ def register_services(hass: HomeAssistant) -> None:
       u.user_id for u in await target_node.access_control.get_users() if u.user_id != 0
     }
 
+    _LOGGER.info(
+      "zlock_slots: copy_slots %s -> %s: %d slot(s) on source (%s), %d slot(s) on target",
+      source_lock_entity_id, target_lock_entity_id, len(source_users),
+      sorted(u.user_id for u in source_users), len(target_slot_ids),
+    )
+
     source_slots = {u.user_id for u in source_users}
     for slot in target_slot_ids - source_slots:
       await target_node.access_control.delete_user(slot)
       await coordinator.async_set_name(target_lock_entity_id, slot, "")
+      _LOGGER.info(
+        "zlock_slots: copy_slots removed slot %d from %s (not present on source)",
+        slot, target_lock_entity_id,
+      )
 
     for user in source_users:
       slot = user.user_id
@@ -230,7 +240,17 @@ def register_services(hass: HomeAssistant) -> None:
       name = coordinator.get_name(source_lock_entity_id, slot)
       await coordinator.async_set_name(target_lock_entity_id, slot, name or "")
 
+      _LOGGER.info(
+        "zlock_slots: copy_slots copied slot %d to %s (%s, %s)",
+        slot, target_lock_entity_id,
+        "code set" if pin is not None else "no code found on source",
+        f"name={name!r}" if name else "no name",
+      )
+
     await coordinator.async_refresh_lock(target_lock_entity_id)
+    _LOGGER.info(
+      "zlock_slots: copy_slots %s -> %s complete", source_lock_entity_id, target_lock_entity_id,
+    )
 
   hass.services.async_register(DOMAIN, SERVICE_SET_CODE, handle_set_code, SET_CODE_SCHEMA)
   hass.services.async_register(DOMAIN, SERVICE_CLEAR_CODE, handle_clear_code, CLEAR_CODE_SCHEMA)