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

Debounce setToCurrentColor to avoid random/unexpected final color #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cheung31
Copy link

@cheung31 cheung31 commented Jan 16, 2021

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

…ce receives possibly 3 set events in succession (hue, saturation, brightness). I found this would clobber the device with too many flux_led.py command invocations. Debouncing addresses this.
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

Successfully merging this pull request may close these issues.

1 participant