From 04d72134c386b2310dca8b53925e4b7b2e2193f3 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 2 Feb 2023 10:34:01 -0500 Subject: [PATCH] Don't try to relock the lock if it's locked when the auto-relock timer fires. (#24769) Fixes https://github.com/project-chip/connectedhomeip/issues/24766 --- .../door-lock-server/door-lock-server.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/app/clusters/door-lock-server/door-lock-server.cpp b/src/app/clusters/door-lock-server/door-lock-server.cpp index a08abd8ac3f20f..6fb25e34e3d02c 100644 --- a/src/app/clusters/door-lock-server/door-lock-server.cpp +++ b/src/app/clusters/door-lock-server/door-lock-server.cpp @@ -3801,8 +3801,19 @@ void MatterDoorLockClusterServerAttributeChangedCallback(const app::ConcreteAttr void DoorLockServer::DoorLockOnAutoRelockCallback(chip::EndpointId endpointId) { - emberAfDoorLockClusterPrintln("Door Auto relock timer expired. Locking..."); emberEventControlSetInactive(&DoorLockServer::Instance().AutolockEvent); - DoorLockServer::Instance().SetLockState(endpointId, DlLockState::kLocked, OperationSourceEnum::kAuto); - emberAfPluginDoorLockOnAutoRelock(endpointId); + + Nullable lockState; + if (Attributes::LockState::Get(endpointId, lockState) != EMBER_ZCL_STATUS_SUCCESS || lockState.IsNull() || + lockState.Value() != DlLockState::kLocked) + { + emberAfDoorLockClusterPrintln("Door Auto relock timer expired. %s", "Locking..."); + + DoorLockServer::Instance().SetLockState(endpointId, DlLockState::kLocked, OperationSourceEnum::kAuto); + emberAfPluginDoorLockOnAutoRelock(endpointId); + } + else + { + emberAfDoorLockClusterPrintln("Door Auto relock timer expired. %s", "Already locked."); + } }