Skip to content

Commit

Permalink
[homekit] fix 100% brightness for dimmer (openhab#7932)
Browse files Browse the repository at this point in the history
* homekit dimmer. fix 100% brightness

Signed-off-by: Eugen Freiter <[email protected]>
  • Loading branch information
yfre authored and andrewfg committed Aug 31, 2020
1 parent e01515d commit ba1af7a
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ private void sendCommand() {
final PercentType brightness = (PercentType) commandCache.remove(BRIGHTNESS_COMMAND);
final DecimalType hue = (DecimalType) commandCache.remove(HUE_COMMAND);
final PercentType saturation = (PercentType) commandCache.remove(SATURATION_COMMAND);
final @Nullable OnOffType currentOnState = ((DimmerItem) item).getStateAs(OnOffType.class);
if (on != null) {
// always sends OFF.
// sends ON only if
Expand All @@ -93,7 +94,7 @@ private void sendCommand() {
// - DIMMER_MODE_FILTER_ON_EXCEPT100 is not enabled and brightness is null or below 100
if ((on == OnOffType.OFF) || (dimmerMode == DIMMER_MODE_NORMAL)
|| (dimmerMode == DIMMER_MODE_FILTER_BRIGHTNESS_100)
|| ((dimmerMode == DIMMER_MODE_FILTER_ON_EXCEPT_BRIGHTNESS_100)
|| ((dimmerMode == DIMMER_MODE_FILTER_ON_EXCEPT_BRIGHTNESS_100) && (currentOnState != OnOffType.ON)
&& ((brightness == null) || (brightness.intValue() == 100)))) {
logger.trace("send OnOff command for item {} with value {}", item, on);
((DimmerItem) item).send(on);
Expand All @@ -119,7 +120,7 @@ private void sendCommand() {
// - other modes (DIMMER_MODE_FILTER_BRIGHTNESS_100 or DIMMER_MODE_FILTER_ON_EXCEPT_BRIGHTNESS_100) and
// <100%.
if ((dimmerMode == DIMMER_MODE_NORMAL) || (dimmerMode == DIMMER_MODE_FILTER_ON)
|| (brightness.intValue() < 100)) {
|| (brightness.intValue() < 100) || (currentOnState == OnOffType.ON)) {
logger.trace("send Brightness command for item {} with value {}", item, brightness);
((DimmerItem) item).send(brightness);
}
Expand Down

0 comments on commit ba1af7a

Please sign in to comment.