Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
Implemented Color Mode channel for the Extended Color Light. (#5762)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Kostadinov <alexander.g.kostadinov@gmail.com>
  • Loading branch information
alex-kostadinov authored and kaikreuzer committed Jun 29, 2018
1 parent c25153d commit 0c0de9b
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.eclipse.smarthome.binding.hue.internal.FullLight;
import org.eclipse.smarthome.binding.hue.internal.HueBridge;
import org.eclipse.smarthome.binding.hue.internal.State;
import org.eclipse.smarthome.binding.hue.internal.State.ColorMode;
import org.eclipse.smarthome.binding.hue.internal.StateUpdate;
import org.eclipse.smarthome.core.library.types.HSBType;
import org.eclipse.smarthome.core.library.types.IncreaseDecreaseType;
Expand All @@ -44,6 +45,7 @@
import org.eclipse.smarthome.core.thing.binding.BaseThingHandler;
import org.eclipse.smarthome.core.thing.binding.ThingHandler;
import org.eclipse.smarthome.core.types.Command;
import org.eclipse.smarthome.core.types.UnDefType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -402,14 +404,19 @@ public void onLightStateChanged(@Nullable HueBridge bridge, FullLight fullLight)
}
updateState(CHANNEL_COLOR, hsbType);

PercentType percentType = LightStateConverter.toColorTemperaturePercentType(fullLight.getState());
updateState(CHANNEL_COLORTEMPERATURE, percentType);
ColorMode colorMode = fullLight.getState().getColorMode();
if (colorMode != null && colorMode.equals(ColorMode.CT)) {
PercentType colorTempPercentType = LightStateConverter.toColorTemperaturePercentType(fullLight.getState());
updateState(CHANNEL_COLORTEMPERATURE, colorTempPercentType);
} else {
updateState(CHANNEL_COLORTEMPERATURE, UnDefType.NULL);
}

percentType = LightStateConverter.toBrightnessPercentType(fullLight.getState());
PercentType brightnessPercentType = LightStateConverter.toBrightnessPercentType(fullLight.getState());
if (!fullLight.getState().isOn()) {
percentType = new PercentType(0);
brightnessPercentType = new PercentType(0);
}
updateState(CHANNEL_BRIGHTNESS, percentType);
updateState(CHANNEL_BRIGHTNESS, brightnessPercentType);

if (fullLight.getState().isOn()) {
updateState(CHANNEL_SWITCH, OnOffType.ON);
Expand Down

0 comments on commit 0c0de9b

Please sign in to comment.