Skip to content

Commit

Permalink
Accept decimal, percent and on off on color channel. Accept on/off on…
Browse files Browse the repository at this point in the history
… brightness channel (#18343)

Signed-off-by: Arne Seime <[email protected]>
  • Loading branch information
seime authored Mar 2, 2025
1 parent 8b1e6f2 commit 2155b66
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,20 @@ private void handleBrightnessCommand(Command command) {
setBrightness(percent.intValue()); // 0..100% = 0..100
} else if (command instanceof DecimalType decimalCommand) {
setBrightness(decimalCommand.intValue());
} else if (command instanceof OnOffType onOffCommand) {
handleOnOffCommand(onOffCommand);
}
}

private void handleColorCommand(Command command) {
if (command instanceof HSBType hsbCommand) {
setColor(hsbCommand);
} else if (command instanceof OnOffType onOffCommand) {
handleOnOffCommand(onOffCommand);
} else if (command instanceof DecimalType decimalCommand) {
handleBrightnessCommand(decimalCommand);
} else if (command instanceof PercentType percentCommand) {
handleBrightnessCommand(percentCommand);
}
}

Expand Down Expand Up @@ -201,10 +209,14 @@ protected void setBrightness(Integer newBrightness) {
* @param command HSBType
*/
protected void setColor(HSBType command) {
lightStripData.switchOn();
lightStripData.setHue(command.getHue().intValue());
lightStripData.setSaturation(command.getSaturation().intValue());
lightStripData.setBrightness(command.getBrightness().intValue());
if (PercentType.ZERO.equals(command.getBrightness())) {
lightStripData.switchOff();
} else {
lightStripData.switchOn();
lightStripData.setHue(command.getHue().intValue());
lightStripData.setSaturation(command.getSaturation().intValue());
lightStripData.setBrightness(command.getBrightness().intValue());
}
connector.sendCommandAndQuery(lightStripData, true);
}

Expand Down

0 comments on commit 2155b66

Please sign in to comment.