Nest API Query - Control of system from Intruder Alarm

眉间皱痕 提交于 2019-12-11 04:04:22

问题


I'm considering the purchase of a Nest and have some thoughts in relation to the API capabilities. I have a intruder/security alarm with PIRs around the house. What I intend to do is to develop an interface between this system and Nest via the API.

My reasoning for this is to use the motion detection from the alarms PIR sensors to 'inform' Nest that someone is still on the premises (due to their movement) and hence prevent Nest switching to its Auto-Away state when the house is inhabited.

Also when the house is armed in away-mode I would want Nest to enter Auto-Away state immediately.

So what I'd like to know is whether it's possible to do the following via the API:

1) Keep/switch Nest in/to the Home 2) Place Nest in the Auto-Away state

Cheers Ian


回答1:


You can switch Nest to Away, or to Home, but you cannot control Auto-Away. In my experience Auto-Away is probably not what you want anyway, as Nest seems to drop out of Auto-Away mode every time it crosses a scheduled heating/cooling etc event.

This is exactly how I use the API - to set the Nest to Away whenever the alarm is set, and to Home whenever the alarm is unset.




回答2:


I came across this with the same question about using my security alarm motion detector (which I already have a monitor for) to let the Nest know someone is home. It seems Nest partners with other companies which can feed Nest activity data but there is nothing about this in the API.

I also have a script which sets Nest to away mode as soon as the alarm is armed, it is easily doable with the published API.

Here is my REST JavaScript function to set Nest to home/away mode, excuse my poor JavaScript (I'm a noob).

// Turn on/off away mode based on true/false parameter
function setAway(doAway) {
  var url = "https://developer-api.nest.com/structures/"+myNest.struct+"?auth="+myNest.auth;
  if (doAway) {
    var newState = "away";
  } else {
    var newState = "home";
  }
  var nowAway = isAway();

  var options = {
    method: "put",
    contentType: "application/json",
    accept: "application/json",
    payload: '{"away":"'+newState+'"}'
  };

  // only update if state changed
  if (doAway != nowAway) {
    var response = UrlFetchApp.fetch(url, options);
    var data = JSON.parse(response);
  }
}


来源:https://stackoverflow.com/questions/25617480/nest-api-query-control-of-system-from-intruder-alarm

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