Closed jeanbie0 closed 2 years ago
Hello @jeanbie0,
Good question.
There are two ways to use this library. One is with callbacks and the other is with a listener.
Try the following:
// Get Thermostats Data
// See docs: https://dev.netatmo.com/dev/resources/technical/reference/thermostat/getthermostatsdata
var options = {
device_id: '',
};
api.getThermostatsData(options, function(err, devices){
// You code here.
});
Yes I understood this. But if I want to use options and listeners (so no callback), I'll have
options != null
callback == null
So it'll enter in the condition and options will be set to null. So options are not taken into account.
The example is not working, if I write a device_id, it'll be erased.
@jeanbie0 could you share your code snippet so I can help you?
var netatmo = require('netatmo');
const home_id = "abcdef0123456789";
var auth = {
"client_id": credentials.client_id,
"client_secret": credentials.client_secret,
"username": credentials.username,
"password": credentials.password,
};
var api = new netatmo(auth);
var getHomeStatus = function(err, data) {
console.log("getHomeStatus");
console.log(data.home.rooms[0]);
};
api.on('get-homestatus', getHomeStatus);
var options = {
home_id: home_id,
};
api.getHomeStatus(options);
This return me Netatmo threw a warning: Error: getHomeStatus error: Missing home_id
. If I comment at line 696 from netatmo.js, everything works well.
Thank you
Hello,
I've one question about a part of code in each api function:
What exactly does this? When we use code from example:
This part of code erase "options", so options are not longer take into account. And this part of code create a 'bad' callback with the option parameter. This give this error because callback from
return callback(err, devices);
is not a function, it's option.Thank you.