Skip to content

Commit

Permalink
Fixes for setting brightness and colour temperature for V3 white bulb…
Browse files Browse the repository at this point in the history
…s. (openhab#2338)

Signed-off-by: Mike Major <[email protected]>
  • Loading branch information
MikeJMajor authored and martinvw committed Jun 6, 2017
1 parent a671f0d commit 7b76fc6
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void setPower(boolean on, MilightThingState state) {
sendQueue.queueRepeatable(uidc(CAT_POWER_SET), new byte[] { command_on[zone], 0x00, 0x55 });
} else {
sendQueue.queueRepeatable(uidc(CAT_POWER_SET), new byte[] { command_off[zone], 0x00, 0x55 });
state.brightness = 0;
}
}

Expand Down Expand Up @@ -104,17 +105,17 @@ public void changeColorTemperature(int color_temp_relative, MilightThingState st
state.colorTemperature = Math.min(100, Math.max(state.colorTemperature + color_temp_relative, 0));
final byte c_on[] = { command_on[zone], 0x00, 0x55 };
final byte c_temp[] = { (byte) (color_temp_relative > 0 ? 0x3E : 0x3F), 0x00, 0x55 };
sendQueue.queue(QueueItem.createRepeatable(uidc(CAT_COLOR_SET), c_on).addNonRepeatable(c_temp));
sendQueue.queue(QueueItem.createRepeatable(c_on).addNonRepeatable(c_temp));
}

// This just emulates an absolute brightness command with the relative commands.
@Override
public void setBrightness(int value, MilightThingState state) {
if (value <= 0) {
sendQueue.queueRepeatable(uidc(CAT_POWER_SET), new byte[] { command_off[zone], 0x00, 0x55 });
setPower(false, state);
return;
} else if (value >= 100) {
sendQueue.queueRepeatable(uidc(CAT_BRIGHTNESS_SET), new byte[] { command_full[zone], 0x00, 0x55 });
setFull(zone, state);
return;
}

Expand Down

0 comments on commit 7b76fc6

Please sign in to comment.