-
Notifications
You must be signed in to change notification settings - Fork 529
Delete guest user when SetYearDaySchedule is failed #2876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1550,6 +1550,19 @@ local function clear_user_response_handler(driver, device, ib, response) | |
| delete_aliro_from_table_as_user(device, userIdx) | ||
| delete_week_schedule_from_table_as_user(device, userIdx) | ||
| delete_year_schedule_from_table_as_user(device, userIdx) | ||
| if cmdName == "defaultSchedule" then | ||
| -- Update commandResult | ||
| local command_result_info = { | ||
| commandName = "addCredential", | ||
| userIndex = userIdx, | ||
| statusCode = "failure" | ||
| } | ||
| device:emit_event(capabilities.lockCredentials.commandResult( | ||
| command_result_info, {state_change = true, visibility = {displayed = false}} | ||
| )) | ||
| device:set_field(lock_utils.BUSY_STATE, false, {persist = true}) | ||
| return | ||
| end | ||
| else | ||
| device.log.warn(string.format("Failed to clear user: %s", status)) | ||
| end | ||
|
Comment on lines
1566
to
1568
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the case this fails, what is the expected result? Given the current logic, a failure would mean that
Should we retry the Also, if it fails after some number of retries, I think we should emit a success result for lockCredentials. What do you think? |
||
|
|
@@ -2418,17 +2431,22 @@ local function set_year_day_schedule_handler(driver, device, ib, response) | |
| local cmdName = "addCredential" | ||
| local credIdx = device:get_field(lock_utils.CRED_INDEX) | ||
|
|
||
| -- Update commandResult | ||
| local command_result_info = { | ||
| commandName = cmdName, | ||
| userIndex = userIdx, | ||
| credentialIndex = credIdx, | ||
| statusCode = status | ||
| } | ||
| device:emit_event(capabilities.lockCredentials.commandResult( | ||
| command_result_info, {state_change = true, visibility = {displayed = false}} | ||
| )) | ||
| device:set_field(lock_utils.BUSY_STATE, false, {persist = true}) | ||
| if status == "success" then | ||
| -- Update commandResult | ||
| local command_result_info = { | ||
| commandName = cmdName, | ||
| userIndex = userIdx, | ||
| credentialIndex = credIdx, | ||
| statusCode = status | ||
| } | ||
| device:emit_event(capabilities.lockCredentials.commandResult( | ||
| command_result_info, {state_change = true, visibility = {displayed = false}} | ||
| )) | ||
| device:set_field(lock_utils.BUSY_STATE, false, {persist = true}) | ||
| else | ||
| local ep = find_default_endpoint(device, clusters.DoorLock.ID) | ||
| device:send(DoorLock.server.commands.ClearUser(device, ep, userIdx)) | ||
| end | ||
| return | ||
| end | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this handling that is specific to the
defaultSchedulecommand could benefit from a short comment that explains why this is needed to improve readability.