Remy Kabel
Remy Kabel

Reputation: 1017

How can I obtain more detailed error messages from the Nest Firebase API?

Currently I'm connecting to the Nest Thermostat API using Node.js. Currently everything in my application works except for obtaining detailed error messages.

Whenever I want to make a change in the structure I do a _sendUpdate call on the Firebase (_fb) defined as:

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));
    });
}

Which uses the Firebase.set() function. Upon error, this callback passes an error object and otherwise null as described here.

As an example error, we try to set the temperature of the Nest thermostat while it is set to Away. According to the Nest API guide, an error message akin to the following should be seen

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

However, instead I just get a Firebase Warning :

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

and my logging detects a similar detailless error:

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

Can anyone explain how I can attain the more detailed error messages?

Note: I'm using Firebase API 2.4.2 since v3 presented errors with authentication, so I resorted to the version as used in the example code (here)

Upvotes: 0

Views: 185

Answers (1)

Lionel Iorgulescu
Lionel Iorgulescu

Reputation: 286

Try using the Firebase client library 1.1.3 as specified here.

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

Upvotes: 0

Related Questions