Skip to content

Commit

Permalink
Merge pull request #43 from BasKiers/fix/connection-errors
Browse files Browse the repository at this point in the history
Fix/connection errors

I accepted the fix for when a device is still connecting and also increased the timeout. But this PR also contained the same changes as in #39 . I did not merge these as I believe they have no effect. If I'm mistaken please let me know.
  • Loading branch information
jghaanstra authored Jun 30, 2018
2 parents c77745f + 3ab3277 commit 39a2878
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/yeelights/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,9 @@ class YeelightDevice extends Homey.Device {

/* send commands to devices using their socket connection */
sendCommand(id, command) {
console.log(command);
if (yeelights[id].connected === false && yeelights[id].socket !== null) {
if(yeelights[id].connecting && yeelights[id].connected === false){
this.log('Unable to send command because socket is still connecting');
} else if (yeelights[id].connected === false && yeelights[id].socket !== null) {
yeelights[id].socket.emit('error', new Error('Connection to device broken'));
} else if (yeelights[id].socket === null) {
this.log('Unable to send command because socket is not available');
Expand All @@ -322,7 +323,7 @@ class YeelightDevice extends Homey.Device {
if (yeelights[id].connected === true && yeelights[id].socket !== null) {
yeelights[id].socket.emit('error', new Error('Error sending command'));
}
}, 3000);
}, 6000);
}
}
}
Expand Down

0 comments on commit 39a2878

Please sign in to comment.