Nest ETA更新无效:没有字段的写入权限:eta

时间:2015-05-08 15:17:35

标签: android firebase nest-api

我正在构建一个与Nest设备集成的应用程序(恒温器和Nest Protect,但这个问题与恒温器有关)。

我尝试做的是将恒温器的ETA设置为x分钟(例如2小时120分钟)。

这是我执行的代码:

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
final String path = buildStructureFieldPath(structureID, Keys.STRUCTURE.ETA);
Structure.ETA eta = new Structure.ETA.Builder()
        .setTripID(tripId)
        .setEstimatedArrivalWindowBegin(sdf.format(estimatedArrivalBegin))
        .setEstimatedArrivalWindowEnd(sdf.format(estimatedArrivalEnd))
        .build();
sendRequest(path, eta.toJSON().toString(), listener);

路径为/structures/MY_STRUCTURE_ID/eta

不幸的是,这不起作用。我总是收到错误代码-2和错误消息:No write permission(s) for field(s): eta

那是奇怪的。没有权限,但我确实请求了权限,并且在启动更新调用之前我做了一个成功的身份验证。

在两个附带的屏幕截图中,您可以看到我的Nest开发者帐户,您可以在其中找到ETA写入权限,在第二个中您可以看到我的应用程序内的日志记录(使用NestitI,可以在GitHub上找到,只需添加我自己的ETA功能。)

Nest Developer Account

App logging

任何人都知道如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

你能打印出你发送的确切JSON blob并在此发布吗? (eta.toJSON().toString())的值

最好的猜测是它没有完全正确地格式化,因此可能试图以不遵守api-reference的方式编写。

这是它需要匹配的格式:

"eta": {
    "trip_id": "myTripHome1024" ,
    "estimated_arrival_window_begin": "2015-10-31T22:42:59.000Z" ,
    "estimated_arrival_window_end": "2015-10-31T23:59:59.000Z"
}

单行:

{"eta":{"trip_id":"myTripHome1024","estimated_arrival_window_begin":"2015-10-31T22:42:59.000Z","estimated_arrival_window_end": "2015-10-31T23:59:59.000Z"}}

要确切地指出哪个字段可能是错误的,请尝试每次只发送一个更改,即:structures/ID/eta/trip_id等等。

有用的JSON验证器:http://jsonlint.com/

您也可以尝试将其发送到/structures/MY_STRUCTURE_ID.json?auth=[TOKEN]而不是/structures/MY_STRUCTURE_ID/eta