Python API for Yale Access (formerly August) Smart Lock and Doorbell
Project description
yalexs
Python API for Yale Access (formerly August) Smart Lock and Doorbell. This is used in Home Assistant but should be generic enough that can be used elsewhere.
Yale Access formerly August
This library is a fork of Joe Lu's excellent august library from https://github.com/snjoetw/py-august
Classes
Authenticator
Authenticator is responsible for all authentication related logic, this includes authentication and verifying the account belongs to the user by sending a verification code to email or phone.
Constructor
Argument | Description |
---|---|
api | See Api class. |
login_method | Login method, either "phone" or "email". |
username | If you're login_method is phone, then this is your full phone# including "+" and country code; otherwise enter your email address here. |
password | Password. |
install_id* | ID that's generated when Yale Access app is installed. If not specified, Authenticator will auto-generate one. If an install_id is provisioned, then it's good to provide the provisioned install_id as you'll bypass verification process. |
access_token_cache_file* | Path to access_token cache file. If specified, access_token info will be cached in the file. Subsequent authentication will utilize information in the file to determine correct authentication state. |
* means optional
Methods
authenticate
Authenticates using specified login_method, username and password.
Outcome of this method is an Authentication object. Use Authentication.state figure out authentication state. User is authenticated only if Authentication.state = AuthenticationState.AUTHENTICATED.
If an authenticated access_token is already in the access_token_cache_file, this method will return cached authentication.
send_verification_code
Sends a 6-digits verification code to phone or email depending on login_method.
validate_verification_code
Validates verification code. This method returns ValidationResult. Check the value to see if verification code is valid or not.
Install
pip install yalexs
Usage
from yalexs.api import Api
from yalexs.authenticator import Authenticator, AuthenticationState
api = Api(timeout=20)
authenticator = Authenticator(api, "phone", "YOUR_USERNAME", "YOUR_PASSWORD",
access_token_cache_file="PATH_TO_ACCESS_TOKEN_CACHE_FILE")
authentication = authenticator.authenticate()
# State can be either REQUIRES_VALIDATION, BAD_PASSWORD or AUTHENTICATED
# You'll need to call different methods to finish authentication process, see below
state = authentication.state
# If AuthenticationState is BAD_PASSWORD, that means your login_method, username and password do not match
# If AuthenticationState is AUTHENTICATED, that means you're authenticated already. If you specify "access_token_cache_file", the authentication is cached in a file. Every time you try to authenticate again, it'll read from that file and if you're authenticated already, Authenticator won't call Yale Access again as you have a valid access_token
# If AuthenticationState is REQUIRES_VALIDATION, then you'll need to go through verification process
# send_verification_code() will send a code to either your phone or email depending on login_method
authenticator.send_verification_code()
# Wait for your code and pass it in to validate_verification_code()
validation_result = authenticator.validate_verification_code(123456)
# If ValidationResult is INVALID_VERIFICATION_CODE, then you'll need to either enter correct one or resend by calling send_verification_code() again
# If ValidationResult is VALIDATED, then you'll need to call authenticate() again to finish authentication process
authentication = authenticator.authenticate()
# Once you have authenticated and validated you can use the access token to make API calls
locks = api.get_locks(authentication.access_token)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file yalexs-8.10.0.tar.gz
.
File metadata
- Download URL: yalexs-8.10.0.tar.gz
- Upload date:
- Size: 39.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32281db88d305e057c44737e082d6c99fe24ebcf05b35fe9774d8e2c45ea5809 |
|
MD5 | d5981a621093f83bf5b5696a83e899f3 |
|
BLAKE2b-256 | 93d8cfaf8e428215f0c44af93f82184a501100694d62e68939f9320d493a5a47 |
File details
Details for the file yalexs-8.10.0-py3-none-any.whl
.
File metadata
- Download URL: yalexs-8.10.0-py3-none-any.whl
- Upload date:
- Size: 48.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2e3de8174365b2adc67b4476e55dc280752fc0a06a8d6866208852906810ff2 |
|
MD5 | f9fb87f7ae564518400d3208c67f09dd |
|
BLAKE2b-256 | 287b17e7ee77dde638bb1be3091cc3908b8b0cb8967cf34e176bcb9110cb6e04 |