NEST Thermostat API

▼魔方 西西 提交于 2019-12-12 01:57:31

问题


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 ..


回答1:


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"
    }
}

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"}'

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

Hope that helps Nagesh



来源:https://stackoverflow.com/questions/24463100/nest-thermostat-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!