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

Commit

Permalink
[Hue] Do not switch the lights on, if the color temperature is changed (
Browse files Browse the repository at this point in the history
#6571)

Signed-off-by: Kai Kreuzer <kai@openhab.org>
  • Loading branch information
kaikreuzer authored and maggu2810 committed Nov 26, 2018
1 parent 259b1c4 commit 010fe61
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Expand Up @@ -216,8 +216,14 @@ public void updateLightState(FullLight light, StateUpdate stateUpdate) {

private void handleException(FullLight light, StateUpdate stateUpdate, Throwable e) {
if (e instanceof DeviceOffException) {
updateLightState(light, LightStateConverter.toOnOffLightState(OnOffType.ON));
updateLightState(light, stateUpdate);
if (stateUpdate.getColorTemperature() != null && stateUpdate.getBrightness() == null) {
// If there is only a change of the color temperature, we do not want the light
// to be turned on (i.e. change its brightness).
return;
} else {
updateLightState(light, LightStateConverter.toOnOffLightState(OnOffType.ON));
updateLightState(light, stateUpdate);
}
} else if (e instanceof IOException) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
} else if (e instanceof ApiException) {
Expand Down
Expand Up @@ -227,6 +227,11 @@ public void handleCommand(ChannelUID channelUID, Command command) {
} else if (command instanceof IncreaseDecreaseType) {
lightState = convertBrightnessChangeToStateUpdate((IncreaseDecreaseType) command, light);
}
if (lightState != null && lastSentColorTemp != null) {
// make sure that the light also has the latest color temp
// this might not have been yet set in the light, if it was off
lightState.setColorTemperature(lastSentColorTemp);
}
break;
case CHANNEL_SWITCH:
logger.trace("CHANNEL_SWITCH handling command {}", command);
Expand All @@ -236,6 +241,11 @@ public void handleCommand(ChannelUID channelUID, Command command) {
lightState = addOsramSpecificCommands(lightState, (OnOffType) command);
}
}
if (lightState != null && lastSentColorTemp != null) {
// make sure that the light also has the latest color temp
// this might not have been yet set in the light, if it was off
lightState.setColorTemperature(lastSentColorTemp);
}
break;
case CHANNEL_COLOR:
if (command instanceof HSBType) {
Expand Down Expand Up @@ -293,8 +303,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
/*
* Applies additional {@link StateUpdate} commands as a workaround for Osram
* Lightify PAR16 TW firmware bug. Also see
* http://www.everyhue.com/vanilla/discussion
* /1756/solved-lightify-turning-off
* http://www.everyhue.com/vanilla/discussion/1756/solved-lightify-turning-off
*/
private StateUpdate addOsramSpecificCommands(StateUpdate lightState, OnOffType actionType) {
if (actionType.equals(OnOffType.ON)) {
Expand Down

0 comments on commit 010fe61

Please sign in to comment.