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

[homekit] Add workaround for color picker #7491

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
class HomekitColorfulLightbulbImpl extends AbstractHomekitLightbulbImpl<ColorItem>
implements ColorfulLightbulb, DimmableLightbulb {

private PercentType saturationValue;

public HomekitColorfulLightbulbImpl(HomekitTaggedItem taggedItem, ItemRegistry itemRegistry,
HomekitAccessoryUpdater updater) {
super(taggedItem, itemRegistry, updater, ColorItem.class);
Expand Down Expand Up @@ -79,7 +81,7 @@ public CompletableFuture<Void> setHue(Double value) throws Exception {
State state = getItem().getStateAs(HSBType.class);
if (state instanceof HSBType) {
HSBType hsb = (HSBType) state;
HSBType newState = new HSBType(new DecimalType(hue), hsb.getSaturation(), hsb.getBrightness());
HSBType newState = new HSBType(new DecimalType(hue), saturationValue, hsb.getBrightness());
((ColorItem) getItem()).send(newState);
return CompletableFuture.completedFuture(null);
} else {
Expand All @@ -91,16 +93,9 @@ public CompletableFuture<Void> setHue(Double value) throws Exception {
@Override
public CompletableFuture<Void> setSaturation(Double value) throws Exception {
final int saturation = value == null ? 0 : value.intValue();
State state = getItem().getStateAs(HSBType.class);
if (state instanceof HSBType) {
HSBType hsb = (HSBType) state;
HSBType newState = new HSBType(hsb.getHue(), new PercentType(saturation), hsb.getBrightness());
((ColorItem) getItem()).send(newState);
return CompletableFuture.completedFuture(null);
} else {
// state is undefined (light is not connected)
return CompletableFuture.completedFuture(null);
}
saturationValue = new PercentType(saturation);

return CompletableFuture.completedFuture(null);
}

@Override
Expand Down