if(currentState instanceof HSBType) {
DecimalType hue = ((HSBType) currentState).getHue();
PercentType saturation = ((HSBType) currentState).getSaturation();
// we map ON/OFF values to dark/bright, so that the hue and saturation values are not changed
if(state==OnOffType.OFF) {
super.setState(new HSBType(hue, saturation, PercentType.ZERO));
} else if(state==OnOffType.ON) {
super.setState(new HSBType(hue, saturation, PercentType.HUNDRED));
} else if(state instanceof PercentType && !(state instanceof HSBType)) {
super.setState(new HSBType(hue, saturation, (PercentType) state));
} else {
super.setState(state);
}
} else {
// we map ON/OFF values to black/white and percentage values to grey scale
if(state==OnOffType.OFF) {
super.setState(HSBType.BLACK);
} else if(state==OnOffType.ON) {
super.setState(HSBType.WHITE);
} else if(state instanceof PercentType && !(state instanceof HSBType)) {
super.setState(new HSBType(DecimalType.ZERO, PercentType.ZERO, (PercentType) state));
} else {
super.setState(state);
}
}
}