如何从Nest Firebase API获取更详细的错误消息?

时间:2016-08-23 14:58:11

标签: node.js firebase firebase-realtime-database nest-api

目前我正在使用Node.js连接Nest Thermostat API。目前我的应用程序中的所有内容都有效,除了获取详细的错误消息。

每当我想对结构进行更改时,我都会对Firebase(_sendUpdate)进行_fb调用,定义为:

FireBaseRef.prototype._sendUpdate = function(path, targetValue, callback) {
    log.i('set ' + path + ' (' + targetValue + ')');
    this._fb.child(path).set(targetValue, function(error {
        log.e(JSON.stringify(error));
    });
}

使用Firebase.set()功能。出错时,此回调会传递一个错误对象,否则null将如here所述。

作为示例错误,我们尝试设置Nest恒温器的温度,同时设置为Away。根据{{​​3}},应该看到类似于以下内容的错误消息

{
  "error": "Cannot change target temperature while structure is Away",
  "type": "https://developers.nest.com/documentation/cloud/error-messages#structure-in-away-mode",
  "message": "Cannot change target temperature while structure is Away",
  "instance": "31441a94-ed26-11e4-90ec-1681e6b88ec1",
}

但是,我只是得到了Firebase警告:

FIREBASE WARNING: set at /devices/thermostats/-GEIJToEG3M9p_jic4J9u7vAgh/target_temperature_c failed: Cannot change target temperature while structure is away 

我的日志记录检测到类似的无详细错误:

{
  "code":"CANNOT CHANGE TARGET TEMPERATURE WHILE STRUCTURE IS AWAY"
}  

任何人都可以解释我如何获得更详细的错误消息吗?

注意:我使用的是Firebase API 2.4.2,因为v3会出现身份验证错误,所以我使用了示例代码中使用的版本(Nest API guide < / p>

1 个答案:

答案 0 :(得分:0)

尝试使用此处指定的Firebase客户端库1.1.3。

https://developers.nest.com/documentation/cloud/firebase-client-libraries/

相关问题