Closed badstraw360 closed 2 years ago
same here. Two different sets of rgb-values are sent on a single change.
[2017-12-27 15:23:48] [HomeAssistant] Successfully set saturation on the 'testlight' to 98
[2017-12-27 15:23:48] [HomeAssistant] Successfully set rgb on the 'testlight' to 5,255,18
[2017-12-27 15:23:48] [HomeAssistant] Successfully set hue on the 'testlight' to 23
[2017-12-27 15:23:48] [HomeAssistant] Successfully set rgb on the 'testlight' to 255,101,5
I'm experiencing the same issue. After a bit of debug i think i figured out the problem. It seems that saturation and hue have different values in setSaturation and setHue methods. I solved the problem moving the rgb conversion logic to a different method and checking if both values has changed.
setHue(level, callback, context) {
if (context === 'internal') {
callback();
return;
}
this.data.attributes.hue = level;
if (this.cachedColor) {
this._setColor(callback);
} else {
this.cachedColor = true;
callback();
}
},
setSaturation(level, callback, context) {
if (context === 'internal') {
callback();
return;
}
this.data.attributes.saturation = level;
if (this.cachedColor) {
this._setColor(callback);
} else {
this.cachedColor = true;
callback();
}
},
_setColor(callback) {
const that = this;
this.cachedColor = false;
const serviceData = {};
serviceData.entity_id = this.entity_id;
const rgb = LightUtil.hsvToRgb(
(this.data.attributes.hue || 0) / 360,
(this.data.attributes.saturation || 0) / 100,
(this.data.attributes.brightness || 0) / 255
);
if (this.data.attributes.hue !== undefined) {
if (this.is_supported(this.features.XY_COLOR)) {
serviceData.xy_color = LightUtil.rgbToCie(rgb.r, rgb.g, rgb.b);
} else {
serviceData.rgb_color = [rgb.r, rgb.g, rgb.b];
}
}
this.client.callService(this.domain, 'turn_on', serviceData, (data) => {
if (data) {
if (that.is_supported(that.features.XY_COLOR)) {
that.log(`Successfully set xy on the '${that.name}' to ${serviceData.xy_color}`);
} else {
that.log(`Successfully set rgb on the '${that.name}' to ${serviceData.rgb_color}`);
}
callback();
} else {
callback(communicationError);
}
});
I hope this helps. Great work, i love this project!
Great!!! Would you share the file with the new code so that I can replace the old one please?
I'm really glad that you figured it out!! This bug is driving me crazy..
Here it is. Github doesn't accept .js Actually i have no idea why it happens, those methods doesn't look async. I will try to investigate further as soon as I reinstall HA, at the moment i'm using hassio and making live changes is a pain.
Thank you, I appreciate your help! I replaced the old light.js file with the new one, but I'm still having the same problem. Maybe it's because I'm using hassbian. I'm going to try to install hassio... :)
The problem using Hassio is that it uses docker images and the file is restored every time you restart the server. I don’t know how hassbian works. Send me the log, I’ll check ASAP.
Awesome, thank you !! Would you need this log? daemon.log
Im getting tail: cannot open '/var/log/homebridge.log' for reading: No such file or directory
Actually homebridge is set up as a service in systemd and writes its log (together with all other processes) in /var/log/daemon.log
Here's just part of the bigger one... newlog.txt
I have a huge 200 mb log file, if you need it let me know.
Sorry, I don't know why you are still having problems. Maybe we were experiencing different issues. In my case the light color was changing twice (going back to the previous one)
Experiencing the same issues here... Can someone walk me through replacing the light.js file that @battistaar posted above?
Many thanks!
Home Assistant release (hass --version): 0.60.0
Platform: limitlessled
Description of problem: When I'm using any limitlessled light in homeassistant and try to change bulb colors using the color picker in homekit and save them to use later, homeassistant won't update the color and the bulb stops responding. So even If I try to turn it off using homeassistant after the bulb stops responding, I need to reset the pi to make it work again. Here is a video of the problem: https://vimeo.com/248093143
Expected: Change colors accordingly.