NEST恒温器API [英] NEST Thermostat API

查看:90
本文介绍了NEST恒温器API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用新发布的NEST api开发ios应用,但由于其本机文档而有些失落.

I am trying to develop an ios app using the newly published NEST api but bit lost with their native documentation.

问题:我可以获取访问令牌,但不知道恒温器端点是否可以查询和更新离开"状态

Question:I could get an access token but do not know the thermostat endpoint to query and update "Away" state

任何指针将不胜感激..

Any pointers will be greatly appreciated ..

推荐答案

我假设您打算使用REST来查询和更新离开状态,因为您提到了端点"?如果不是,另一种选择是使用firebase API. 简介部分

I'm presuming you intend to use REST to query and update the away state since you mentioned "endpoint"? If not the other alternative is to use the firebase API. This is documented in the introduction section

要获取离开状态,您需要查询建筑物

To get the away status you'll need to query the structure/s

curl -v -L https://developer-api.nest.com/structures?auth=<AUTH_TOKEN>

除了该结构中的恒温器/烟雾协同警报之外,响应还显示离开状态.

The response shows the away state in addition to the thermostats/smoke co alarms in that structure.

{
    "g-9y-2xkHpBh1MGkVaqXOGJiKOB9MkoW1hhYyQk2vAunCK8a731jbg": {
        "away": "home",
        "country_code": "US",
        "name": "Home",
        "smoke_co_alarms": [
            "0NBM7-QfoLwhMldZ2CoIkQ7hRJoe1Jye"
        ],
        "structure_id": "g-9y-2xkHpBh1MGkVaqXOGJiKOB9MkoW1hhYyQk2vAunCK8a731jbg",
        "thermostats": [
            "GM6Z9JpSKU6_ua8AfD6WRA"
        ],
        "time_zone": "America/Los_Angeles"
    }
}

要更新离开状态,您需要使用PUT http动词:

To update the away state you would need to use the PUT http verb:

curl -v -L -X PUT "https://developer-api.nest.com/structures/g-9y-2xkHpBh1MGkVaqXOGJiKOB9MkoW1hhYyQk2vAunCK8a731jbg?auth=<AUTH_TOKEN>" -H "Content-Type: application/json" -d '{"away":"away"}'

请注意,path参数中使用的ID是get响应中返回的结构ID.

Note that the ID used in the path parameter is the structure ID returned in the get response.

希望有帮助 纳吉什(Nagesh)

Hope that helps Nagesh

这篇关于NEST恒温器API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆