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

Implemented Color Mode channel for the Extended Color Light. #5762

Merged
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 @@ -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