Open RobinBol opened 7 years ago
I just tried and I got the same error. I then tried running the script with the call to getHardwareVersion
commented out which seemed to help. Curiously I then tried once more with `getHardwareVersion´ call included and this time there were no issues. All lights returned the hardware info also.
I haven't experienced this earlier either so it's likely related to some of the recent firmware updates. One reason could be that the lights aren't responding as fast. Could you try a longer response timeout setting on the client if you still get the same error? Just change line 44 of interactive-cli.js
to for example:
client.init({ messageHandlerTimeout: 90000 });
If this doesn't help then it could help wrapping the getHardwareVersion
to a try catch block and retry a few times.
I changed the interative-cli.js
to this (using the messageHandlerTimeout
of 90000):
client.on('light-new', function(light) {
console.log('New light found.');
console.log('ID: ' + light.id);
console.log('IP: ' + light.address + ':' + light.port);
light.getState( (err, info) => { // or light.getHardwareVersion
if (err) {
console.log('1', err);
light.getState( (err, info) => { // or light.getHardwareVersion
if (err) {
console.log('2', err);
light.getState( (err, info) => { // or light.getHardwareVersion
if (err) {
console.log('3', err);
throw err;
} else {
console.log('Label: ' + info.label);
console.log('Power:', (info.power === 1) ? 'on' : 'off');
console.log('Color:', info.color);
}
});
} else {
console.log('Label: ' + info.label);
console.log('Power:', (info.power === 1) ? 'on' : 'off');
console.log('Color:', info.color);
}
});
} else {
console.log('Label: ' + info.label);
console.log('Power:', (info.power === 1) ? 'on' : 'off');
console.log('Color:', info.color);
}
});
});
Which results in this:
Keys:
Press 1 to turn the lights on
Press 2 to turn the lights off
Press 3 to turn the lights red
Press 4 to turn the lights green
Press 5 to turn the lights blue
Press 6 to turn the lights a bright bluish white
Press 7 to turn the lights a bright reddish white
Press 8 to show debug messages including network traffic
Press 9 to hide debug messages including network traffic
Press 0 to exit
Started LIFX listening on 0.0.0.0:56700
DEBUG - 24000034f471ca5100000000000000000000000000000000000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000000000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000000000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000000000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000000000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000000000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000000000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000000000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000000000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000000000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000000000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000000000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000000000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000000000000000000000002000000 to 255.255.255.255
DEBUG - 29000054f471ca51d073d501c21b00004c49465856320000848098952762ce1403000000017cdd0000 from 192.168.1.16
New light found.
ID: d073d501c21b
IP: 192.168.1.16:56700
DEBUG - 29000054f471ca51d073d501c21b00004c49465856320000446bba962762ce1403000000057cdd0000 from 192.168.1.16
DEBUG - 24000014f471ca51d073d501c21b00000000000000000001000000000000000017000000 to 192.168.1.16
DEBUG - 24000014f471ca51d073d501c21b00000000000000000002000000000000000065000000 to 192.168.1.16
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000002000000000000000002000000 to 255.255.255.255
DEBUG - 24000034f471ca5100000000000000000000000000000002000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000002000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
Light offline. ID:d073d501c21b, IP:192.168.1.16:56700
DEBUG - 24000034f471ca5100000000000000000000000000000002000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000002000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000002000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000002000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000002000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000002000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000002000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000002000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000002000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000002000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000002000000000000000002000000 to 255.255.255.255
DEBUG - 29000054f471ca51d073d501c21b00004c49465856320002448de4b23762ce1403000000057cdd0000 from 192.168.1.16
1 [Error: No LIFX response in time]
DEBUG - 24000014f471ca51d073d501c21b00000000000000000003000000000000000065000000 to 192.168.1.16
DEBUG - 24000034f471ca5100000000000000000000000000000003000000000000000002000000 to 255.255.255.255
DEBUG - 29000054f471ca51d073d501c21b00004c49465856320003043ddbdc3862ce1403000000017cdd0000 from 192.168.1.16
Light back online. ID:d073d501c21b, IP:192.168.1.16:56700
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000003000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000003000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000003000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
Light offline. ID:d073d501c21b, IP:192.168.1.16:56700
DEBUG - 24000034f471ca5100000000000000000000000000000003000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000003000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000003000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000003000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000003000000000000000002000000 to 255.255.255.255
DEBUG - 24000034f471ca5100000000000000000000000000000003000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000003000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000003000000000000000002000000 to 255.255.255.255
DEBUG - 24000034f471ca5100000000000000000000000000000003000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000003000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000003000000000000000002000000 to 255.255.255.255
DEBUG - 24000034f471ca5100000000000000000000000000000003000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000003000000000000000002000000 to 255.255.255.255
DEBUG - 29000054f471ca51d073d501c21b00004c494658563200030408c2814b62ce1403000000017cdd0000 from 192.168.1.16
Light back online. ID:d073d501c21b, IP:192.168.1.16:56700
2 [Error: No LIFX response in time]
DEBUG - 24000014f471ca51d073d501c21b00000000000000000004000000000000000065000000 to 192.168.1.16
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000004000000000000000002000000 to 255.255.255.255
DEBUG - 29000054f471ca51d073d501c21b00004c4946585632000484a2daac4c62ce1403000000017cdd0000 from 192.168.1.16
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000004000000000000000002000000 to 255.255.255.255
DEBUG - 29000054f471ca51d073d501c21b00004c49465856320004446d88d74d62ce1403000000017cdd0000 from 192.168.1.16
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000004000000000000000002000000 to 255.255.255.255
DEBUG - 29000054f471ca51d073d501c21b00004c49465856320004448cbf024f62ce1403000000017cdd0000 from 192.168.1.16
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000004000000000000000002000000 to 255.255.255.255
DEBUG - 29000054f471ca51d073d501c21b00004c4946585632000484e4c82d5062ce1403000000017cdd0000 from 192.168.1.16
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000004000000000000000002000000 to 255.255.255.255
DEBUG - 29000054f471ca51d073d501c21b00004c49465856320004840c3d595162ce1403000000017cdd0000 from 192.168.1.16
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000004000000000000000002000000 to 255.255.255.255
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000004000000000000000002000000 to 255.255.255.255
DEBUG - 29000054f471ca51d073d501c21b00004c49465856320004440cefa85362ce1403000000017cdd0000 from 192.168.1.16
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000004000000000000000002000000 to 255.255.255.255
DEBUG - 29000054f471ca51d073d501c21b00004c49465856320004846d35d45462ce1403000000017cdd0000 from 192.168.1.16
DEBUG - 2400003443c4a68600000000000000000000000000000002000000000000000002000000 from 192.168.1.39
DEBUG - 24000034f471ca5100000000000000000000000000000004000000000000000002000000 to 255.255.255.255
DEBUG - 29000054f471ca51d073d501c21b00004c49465856320004c4ce7bff5562ce1403000000017cdd0000 from 192.168.1.16
3 [Error: No LIFX response in time]
/Users/robinbolscher/Development/apps/com.lifx/node_modules/node-lifx/example/example.js:20
throw err;
^
Error: No LIFX response in time
at Client.<anonymous> (/Users/robinbolscher/Development/apps/com.lifx/node_modules/node-lifx/lib/lifx/client.js:368:19)
at Array.forEach (native)
at Client.processMessageHandlers (/Users/robinbolscher/Development/apps/com.lifx/node_modules/node-lifx/lib/lifx/client.js:340:24)
at Client.<anonymous> (/Users/robinbolscher/Development/apps/com.lifx/node_modules/node-lifx/lib/lifx/client.js:177:12)
at emitTwo (events.js:87:13)
at Socket.emit (events.js:172:7)
at UDP.onMessage (dgram.js:480:8)
Strange thing is, I noticed it did succeed one time to fetch the state form the bulb, but about 9/10 times it fails.
I would say there might be something wrong with your network if 9/10 times it fails. Are you running node-lifx off WiFi?
For me, it's more like 1/100 times it fails, but I'm running off Ethernet.
Using the example, the getState() and getHardwareVersion() time out, this used to work. Am I the only one experiencing this issue? Bulb is on firmware 2.1 according to the LIFX desktop firmware updater.