Open WeeJeWel opened 9 years ago
Yeah, I too have seemed to have a hard time targeting on bulb for specific changes. What am I missing? bulbs gives me an object:
obj = {"aaabbbcccddd":{
"addr":[111,222,333,4,555,6],
"name":"Desk",
"state":{
"hue":29,
"saturation":65535,
"brightness":65535,
"kelvin":2500,
"dim":0,
"power":65535
}
}}
I imagined that passing the key "aaabbbcccddd"
would be the correct parameter for changing the values of a single bulb but I get no feedback. I've tried the name and even the entire obj.aaabbbcccddd
object. to no avail.
EDIT: Awe. So then I read the code, and learned that you can dump in all of the above. herm... still having troubles targeting a single bulb though...
I have too found the same issue. I can call lightsOn using lightsOn(
Does anyone found a solution on that ? I'm using ruby official code only because of this problem... and i don't like to code with ruby... :-/
The problem is that the packet headers are not implemented completely, they use some generic values that work in most cases. The problem is that a targeting of a single bulb is not possible with this generic values. You should consider searching for a library that supports the v2 protocol. https://www.npmjs.com/search?q=lifx
These to seem to work for me: https://www.npmjs.com/package/node-lifx https://www.npmjs.com/package/lifx-api
Thank you very much for your answer, i'll try your libs !
I confirm : node-lifx is working properly.
Modify the function as shown below. (lifx.js) Single bulb are controlled. (LightOn/LightOff/LightsColour) I hope this helps. .... Lifx.prototype._sendToOneOrAll = function(command, bulb) { var self = this; var bulbAddress = null; if (typeof bulb != 'undefined') { // Overwrite the bulb address here if (Buffer.isBuffer(bulb)) { bulbAddress = bulb; } else if (typeof bulb.addr != 'undefined') { bulbAddress = bulb.addr; } else { // Check if it's a hex string of a known bulb addr var b = self.bulbs[bulb] if (b) { bulbAddress = b.addr; } else { throw "Unknown bulb: " + bulb; } } // 2018.06.17 // bulbAddress.copy(command, 8); }
_(this.gateways).each(function(gw, ip) {
var siteAddress = gw.site;
siteAddress.copy(command, 16);
// 2018.06.17
if ( bulbAddress == null ) {
self._sendPacket(gw.ip, gw.port, command);
}
else {
if ( Buffer.isBuffer(bulbAddress) )
bulbAddress = bulbAddress.toString('hex');
if ( gw.bulbAddress == bulbAddress ) {
self._sendPacket(gw.ip, gw.port, command);
}
}
});
};
@JungSungHeeK Thank you! That's working for me.
Using lightsColour to set a bulb on or off works, when the last parameter is a bulb object. However, when changing the hue, it does not change. Omitting the bulb parameter (thus targeting all), the color changes.