Skip to content

Commit

Permalink
Add support for IKEA CWS bulb
Browse files Browse the repository at this point in the history
  • Loading branch information
HahnBenjamin committed Jun 12, 2020
1 parent 150611d commit 46c4f34
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ private void addLight(String lightID, LightMessage light) {
case COLOR_DIMMABLE_LIGHT:
thingTypeUID = THING_TYPE_COLOR_LIGHT;
break;
case COLOR_LIGHT:
thingTypeUID = (light.ctmin != null) ?THING_TYPE_EXTENDED_COLOR_LIGHT :THING_TYPE_COLOR_LIGHT;
break;
case EXTENDED_COLOR_LIGHT:
thingTypeUID = THING_TYPE_EXTENDED_COLOR_LIGHT;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,16 @@ private void valueUpdated(String channelId, LightState newState) {
case CHANNEL_COLOR:
if (on != null && on == false) {
updateState(channelId, OnOffType.OFF);
} else {
double @Nullable [] xy = newState.xy;
Integer hue = newState.hue;
Integer sat = newState.sat;
if (hue != null && sat != null && bri != null) {
updateState(channelId,
new HSBType(new DecimalType(hue / HUE_FACTOR), toPercentType(sat), toPercentType(bri)));
} else if (xy != null && xy.length == 2) {
updateState(channelId, HSBType.fromXY((float) xy[0], (float) xy[1]));
} else if (bri != null && newState.colormode != null && newState.colormode.equals("xy")) {
final double @Nullable [] xy = newState.xy;
if (xy != null && xy.length == 2) {
HSBType color = HSBType.fromXY((float) xy[0], (float) xy[1]);
updateState(channelId, new HSBType(color.getHue(), color.getSaturation(), toPercentType(bri)));
}
} else if (bri != null && newState.hue != null && newState.sat != null) {
final Integer hue = newState.hue;
final Integer sat = newState.sat;
updateState(channelId, new HSBType(new DecimalType(hue / HUE_FACTOR), toPercentType(sat), toPercentType(bri)));
}
break;
case CHANNEL_BRIGHTNESS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public enum LightType {
ON_OFF_LIGHT("On/Off light"),
ON_OFF_PLUGIN_UNIT("On/Off plug-in unit"),
EXTENDED_COLOR_LIGHT("Extended color light"),
COLOR_LIGHT("Color light"),
COLOR_DIMMABLE_LIGHT("Color dimmable light"),
COLOR_TEMPERATURE_LIGHT("Color temperature light"),
DIMMABLE_LIGHT("Dimmable light"),
Expand Down

0 comments on commit 46c4f34

Please sign in to comment.