Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't target single bulb to change hue #35

Open
WeeJeWel opened this issue Mar 10, 2015 · 8 comments
Open

Can't target single bulb to change hue #35

WeeJeWel opened this issue Mar 10, 2015 · 8 comments

Comments

@WeeJeWel
Copy link

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.

@MrRacoon
Copy link

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...

@MrEggy
Copy link

MrEggy commented Jul 26, 2015

I have too found the same issue. I can call lightsOn using lightsOn() and individually turn lights on. However if I turn one light on with one set of properties and then turn a second one on using a different set of properties using LightsColour, the first light will change to the second set of properties. It seems that lightsColour works globally and there is no way of have lamps with different levels of luminance.

@abalam666
Copy link

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... :-/

@MariusRumpf
Copy link

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

@abalam666
Copy link

Thank you very much for your answer, i'll try your libs !

@abalam666
Copy link

I confirm : node-lifx is working properly.

@ghost
Copy link

ghost commented Jun 17, 2018

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);	
		}
	}
});

};

@ryanmonro
Copy link

@JungSungHeeK Thank you! That's working for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants