Add LightBulb#debouncedSetToCurrentColor method on 250ms delay as the light bulb service receives possibly 3 set events in succession (hue, saturation, brightness). LightBulb#setHue, LightBulb#setSaturation, and LightBulb#setBrightness now call LightBulb#debouncedSetToCurrentColor. Prior to this change, I found the service would clobber the device with flux_led.py command invocations. What we want is the 1-3 successive set* events to update LightBulb#color, and a single LightBulb#sendCommand invocation. Debouncing addresses this.
In my specific case, this fixed a scene that changed the light's brightness/color. I observed 3 flux_led.py commands with the same timestamp, and after looking through source code, realized it's probably 3-successive calls to setToCurrentColor caused by hue, saturation, brightness changes. We still want those 3 methods to mutate the LightBulb#color state. But want to debounce the actual LightBulb#sendCommand/LightBulb#executeCommand invocation as to not clobber the device, resulting in a random color depending on which of the 3 successive events wins the race condition.
Issue
Should address:
Overview
@sahilchaddha @sahilchaddha93
Add
LightBulb#debouncedSetToCurrentColor
method on 250ms delay as the light bulb service receives possibly 3 set events in succession (hue, saturation, brightness).LightBulb#setHue
,LightBulb#setSaturation
, andLightBulb#setBrightness
now callLightBulb#debouncedSetToCurrentColor
. Prior to this change, I found the service would clobber the device with flux_led.py command invocations. What we want is the 1-3 successiveset*
events to updateLightBulb#color
, and a singleLightBulb#sendCommand
invocation. Debouncing addresses this.In my specific case, this fixed a scene that changed the light's brightness/color. I observed 3
flux_led.py
commands with the same timestamp, and after looking through source code, realized it's probably 3-successive calls tosetToCurrentColor
caused by hue, saturation, brightness changes. We still want those 3 methods to mutate theLightBulb#color
state. But want to debounce the actualLightBulb#sendCommand
/LightBulb#executeCommand
invocation as to not clobber the device, resulting in a random color depending on which of the 3 successive events wins the race condition.