Skip to content
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

Fix adding/updating access codes. #203

Merged
merged 3 commits into from
Nov 24, 2024

Conversation

rockymountainnative
Copy link

Add accessCodeLength and notificationEnabled. accesscodeId is the only value returned when updating/adding code.

…y value returned when updating/adding code.
@dknowles2
Copy link
Owner

Can you update the tests?

@rockymountainnative
Copy link
Author

rockymountainnative commented Nov 20, 2024

Unit tests have been updated. I removed one assertion. I was unable to test the api being able to pick up any out-of-band updates. The response from the api was returning either { "accesscodeId": "XXX" } or {}. No other fields have been returned which leads me to believe the API isn't intended to return the full object fields or updated fields.

A couple other call outs:

I am unclear as to what "notification" even represents. In all of my codes, both configured to notify and not notify, all responses from the getaccesscodes has been 0. It appears when adding/updating an access code, it is under notificationEnabled reflected in this PR.

I am not fully up to speed on notifications within the API and left it untouched. In some cases in the app, the notificationId was included in the update/add POST command, but other times it was not. I am leaving this detail out of scope for this PR.

I have tested this on my two locks which are be489wifi and be489wifi2.

@@ -194,14 +194,14 @@ def from_json(cls, auth: Auth, device: Device, json: dict[str, Any]) -> AccessCo
else:
schedule = TemporarySchedule.from_json(json)

access_code_length = json.get("accessCodeLength") or 4
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can just be

json.get("accessCodeLength", 4)

(The second argument to get() is the default value if the key is not in the dictionary)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

pyschlage/code.py Outdated Show resolved Hide resolved
pyschlage/code.py Show resolved Hide resolved
tests/test_code.py Outdated Show resolved Hide resolved
@dknowles2
Copy link
Owner

Thanks!

@dknowles2 dknowles2 merged commit b4b529d into dknowles2:main Nov 24, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants