Open zork17 opened 5 years ago
Any help?
I can see in the lines just above the crash:
//We get the last 10 items in case the first one failed.
if (debug) {
console.log("**[Sensibo API Debug] DeviceID :\n", deviceID.trim());
}
GET({ path: 'pods/'+deviceID+'/acStates?fields=status,reason,acState&limit=10&apiKey='+this.apiKey },function(data){
that the number 10 is mentioned. I have 10 Sensibo devices - maybe this causes the problem?
I managed to fix it with the following change in getState: Old:
getState: function(deviceID, callback) {
//We get the last 10 items in case the first one failed.
GET({ path: 'pods/'+deviceID+'/acStates?fields=status,reason,acState&limit=10&apiKey='+this.apiKey },function(data){
if (data && data.status && data.status == 'success' && data.result && data.result instanceof Array) {
var i=0;
for (i=0; i<data.result.length; i++) {
if (data.result[i].status=="Success") break;
}
if (i==data.result.length) i=0;
callback(data.result[i].acState);
} else {
callback();
}
})
},
New
getState: function(deviceID, callback) {
GET({ path: 'pods/'+deviceID+'/acStates?fields=status,reason,acState&limit=20&apiKey='+this.apiKey },function(data){
if (data && data.status && data.status == 'success' && data.result && data.result instanceof Array) {
var i=0;
for (i=0; i<data.result.length; i++) {
if (data.result[i].status=="Success") break;
}
if (i==0 && data.result.length==0)
callback();
else
{
if (i==data.result.length) i=0;
callback(data.result[i].acState);
}
} else {
callback();
}
})
},
So basically adding:
if (i==0 && data.result.length==0)
callback();
I do not know what is the effecting of this, but it works. I found out that in many cases in my system both i and data.result.length are 0 after the loop. Any chance of adding this to the code?
Thank you!
I tried this plugin a year ago and it didn't work. I tried it now (after installing the latest versions of everything) and I get the same error. This is the config file:
This is the error I get:
The only difference I can think of from a simple homebridge system is that I have 2 homebridge services since in total I have more than 100 devices. I tried putting the sensibo-sky platform in each of them and it crashes at the same line.
Is there a way to debug or fix this?