|
|
@@ -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)
|