Netatmo的客户端库

netatmo-client的Python项目详细描述


Netatmo Python客户端

https://img.shields.io/pypi/v/netatmo-client.svghttps://img.shields.io/github/license/antechrestos/python-netatmo-client.svg

python netatmo客户端repo包含一个用于netatmo的python客户端库。

安装

到目前为止,唯一的来源是安装它的方式:

来源

构建库运行:

$ python setup.py install

如何使用

首先,您必须声明自己的own应用程序,并获取client idclient secret

构建实例

fromnetatmo_client.clientimportNetatmoClientscopes=('read_station','read_thermostat','write_thermostat','read_camera')client_id='client id'client_secret='client secret'client=NetatmoClient(client_id,client_secret)

获取代币

库提供了两种记录客户机的方法

授权代码处理

假设您在netatmo站点上将http://somewhere.org/callback/grant/code声明为重定向uri, 您可以使用下面这样的代码使用授权代码方式获取令牌。

client=NetatmoClient('client-id','client-secret')scopes=('read_station','read_thermostat','write_thermostat','read_camera')redirect_uri='http://somewhere.org/callback/grant/code'grant_url=client.generate_auth_url(redirect_uri,'state-test',*scopes)sys.stdout\
    .write("Open the following url ( %s ), follow the steps and enter the code you will see in the navigation bar: "%grant_url)code=sys.stdin.readline()code=code.rstrip('\r\n')client.request_token_with_code(code,redirect_uri,*scopes)# use the apiprintjson.dumps(client.station.get_station_data())

用户将进入授权代码流程并返回到您的站点 一个url,如http://somewhere.org/callback/grant/code?code=<yourcode>&state=state-test。 然后,您的web服务器通常处理get请求,并使用与上面相同的redirect uri交换代码。

客户端凭据

您也可以按如下方式选择此过程:

client=NetatmoClient('client-id','client-secret')scopes=('read_station','read_thermostat','write_thermostat','read_camera')client.request_token_with_client_credentials('username','password',*scopes)# use the apiprintjson.dumps(client.thermostat.get_thermostat_data())

api调用

客户定义了三个部分:

  • common
    • get_measure
  • public
    • get_public_data
  • station
    • get_station_data
  • thermostat
    • get_thermostat_data
    • create_new_schedule
    • set_therm_point
    • switch_schedule
    • sync_schedule
  • welcome
    • get_camera_picture
    • get_events_until
    • get_next_events
    • get_home_data
    • get_last_event_of
    • add_webhook
    • drop_webhook
    • ping

问题和贡献

请提交问题/请求。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
JavaPax考试:从非标准Maven存储库解析Karaf特性存储库(XML文件)   java Spring启动Bean创建异常   java中将ArrayList转换为数组的方法   Android Studio的java Unity插件。   java在CheckStyle中从方法计数中排除getter和setter   HibernateJava。sql。SQLSyntaxErrorException:表/视图“序列”不存在   与命令行程序Java vs C通信   java WebView膨胀异常   java在O(n)java8流中寻找两个列表的交集   java使用Gradle运行单元测试时,最大堆大小在哪里设置?   ssl加载java应用程序(CXF)内的jks文件   CI:Jenkins Git:Simple Java项目:希望在特定时间在脚本上发送消息   java根据位置更改数字   java按数值排序字符串数组   macos java版本“1.6.0_65”是否与java 6模棱两可?   Cassandra中的java时间戳