Yale Access(原名August)智能锁和门铃的Python API
项目描述
Yalexs

耶鲁访问(原名August)智能锁和门铃的Python API。此API用于Home Assistant,但应该足够通用,可以在其他地方使用。
耶鲁访问(原名August)
此库是来自https://github.com/snjoetw/py-august的Joe Lu的优秀august库的分支。
类
认证器
认证器负责所有认证相关逻辑,包括通过发送验证码到电子邮件或手机来认证以及验证账户是否属于用户。
构造函数
参数 | 描述 |
---|---|
api | 参见Api类。 |
login_method | 登录方法,可以是"phone"或"email"。 |
username | 如果您的login_method是phone,则这是包括"+"和国家代码在内的完整电话号码;否则在此处输入您的电子邮件地址。 |
password | 密码。 |
install_id* | 当安装Yale Access应用时生成的ID。如果没有指定,认证器将自动生成一个。如果已提供install_id,则请提供已提供的install_id,因为您将绕过验证过程。 |
access_token_cache_file* | 访问令牌缓存文件的路径。如果指定,访问令牌信息将缓存在该文件中。后续认证将利用文件中的信息来确定正确的认证状态。 |
*表示可选
方法
authenticate
使用指定的login_method、用户名和密码进行认证。
此方法的结果是认证对象。使用Authentication.state确定认证状态。只有当Authentication.state = AuthenticationState.AUTHENTICATED时,用户才已认证。
如果已认证的access_token已存储在access_token_cache_file中,则此方法将返回缓存的认证。
send_verification_code
根据login_method将6位数的验证码发送到手机或电子邮件。
validate_verification_code
验证验证码。此方法返回ValidationResult。检查值以确定验证码是否有效。
安装
pip install yalexs
用法
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)
项目详情
下载文件
下载您平台对应的文件。如果您不确定该选择哪个,请了解有关 安装包 的更多信息。
源分发
yalexs-8.9.0.tar.gz (39.0 kB 查看哈希值)
构建分发
yalexs-8.9.0-py3-none-any.whl (47.7 kB 查看哈希值)
关闭
yalexs-8.9.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | f42f20a699cda7018551d4835a6ffd1a0ea5ac3474195e4a6ab3117bd95d11e2 |
|
MD5 | d7d88b68d07e3a961a1ba992e72d5054 |
|
BLAKE2b-256 | b77a333b5d8c4df0d5b3176220121f843b42ce650b606467c8ef11466658ca06 |
关闭
yalexs-8.9.0-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | eca640a3ac3823a689774cd70ab984f8ad308f482e481fce4a8f091095b07816 |
|
MD5 | 5de80d41a7c3312af765a4bf3ea23839 |
|
BLAKE2b-256 | ab09a0c4bde14ae50afb2a62d2b2877180f77dbc45c3218ee77533272edd4e2c |