Skip to content

Commit

Permalink
Merge pull request #1645 from SmartThingsCommunity/bugfix/yale_master…
Browse files Browse the repository at this point in the history
…_code

Yale Zigbee Locks: Use MASTER_CODE user type
  • Loading branch information
greens authored Sep 24, 2024
2 parents 89daa30 + f60a867 commit bf93ca2
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
47 changes: 47 additions & 0 deletions drivers/SmartThings/zigbee-lock/src/test/test_zigbee_yale.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,53 @@ test.register_coroutine_test(
end
)

test.register_coroutine_test(
"Setting the master code should result in the correct user type being used",
function()
test.timer.__create_and_queue_test_time_advance_timer(4, "oneshot")
test.socket.capability:__queue_receive({ mock_device.id, { capability = capabilities.lockCodes.ID, command = "setCode", args = { 0, "1234", "test" } } })
test.socket.zigbee:__expect_send(
{
mock_device.id,
DoorLock.server.commands.SetPINCode(mock_device,
0,
DoorLockUserStatus.OCCUPIED_ENABLED,
DoorLockUserType.MASTER_USER,
"1234"
)
}
)
test.wait_for_events()

test.mock_time.advance_time(4)
test.socket.zigbee:__expect_send(
{
mock_device.id,
DoorLock.server.commands.GetPINCode(mock_device, 0)
}
)
test.wait_for_events()

test.socket.zigbee:__queue_receive(
{
mock_device.id,
DoorLock.client.commands.GetPINCodeResponse.build_test_rx(
mock_device,
0x00,
DoorLockUserStatus.OCCUPIED_ENABLED,
DoorLockUserType.MASTER_USER,
"1234"
)
}
)
test.socket.capability:__expect_send(mock_device:generate_test_message("main",
capabilities.lockCodes.codeChanged("0 set", { data = { codeName = "test"}, state_change = true }))
)
test.socket.capability:__expect_send(mock_device:generate_test_message("main",
capabilities.lockCodes.lockCodes(json.encode({["0"] = "test"}), { visibility = { displayed = false }})))
end
)


test.register_message_test(
"Pin response reporting should be handled when the Lock User status is disabled",
Expand Down
3 changes: 2 additions & 1 deletion drivers/SmartThings/zigbee-lock/src/yale/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ local set_code = function(driver, device, command)
args = {command.args.codeSlot, command.args.codeName}
})
else
local user_type = command.args.codeSlot == 0 and UserTypeEnum.MASTER_USER or UserTypeEnum.UNRESTRICTED
device:send(LockCluster.server.commands.SetPINCode(device,
command.args.codeSlot,
UserStatusEnum.OCCUPIED_ENABLED,
UserTypeEnum.UNRESTRICTED,
user_type,
command.args.codePIN)
)
if (command.args.codeName ~= nil) then
Expand Down

0 comments on commit bf93ca2

Please sign in to comment.