Java Code Examples for org.eclipse.smarthome.core.library.types.DecimalType#ZERO

The following examples show how to use org.eclipse.smarthome.core.library.types.DecimalType#ZERO . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LightStateConverterTest.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void colorWithBightnessOfZeroIsZero() {
    final State lightState = new State();
    lightState.colormode = ColorMode.CT.toString();
    // 0 percent should not be sent to the Hue interface
    final HSBType hsbType = new HSBType(DecimalType.ZERO, PercentType.ZERO, PercentType.ZERO);
    StateUpdate stateUpdate = LightStateConverter.toColorLightState(hsbType, lightState);
    assertThat(stateUpdate.commands.size(), is(2));
    // a brightness of 0 should result in 0 percent
    lightState.bri = 0;
    assertThat(LightStateConverter.toHSBType(lightState).getBrightness(), is(PercentType.ZERO));
}
 
Example 2
Source File: LightStateConverterTest.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void colorLightStateConverterForBrightnessConversionIsBijective() {
    final State lightState = new State();
    lightState.colormode = ColorMode.CT.toString();
    for (int percent = 1; percent <= 100; ++percent) {
        final HSBType hsbType = new HSBType(DecimalType.ZERO, PercentType.ZERO, new PercentType(percent));
        StateUpdate stateUpdate = LightStateConverter.toColorLightState(hsbType, lightState);
        assertThat(stateUpdate.commands.size(), is(3));
        assertThat(stateUpdate.commands.get(2).key, is("bri"));
        lightState.bri = Integer.parseInt(stateUpdate.commands.get(2).value.toString());
        assertThat(LightStateConverter.toHSBType(lightState).getBrightness().intValue(), is(percent));
    }
}
 
Example 3
Source File: LightStateConverterTest.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void colorLightStateConverterForSaturationConversionIsBijective() {
    final State lightState = new State();
    lightState.colormode = ColorMode.CT.toString();
    for (int percent = 0; percent <= 100; ++percent) {
        final HSBType hsbType = new HSBType(DecimalType.ZERO, new PercentType(percent), PercentType.HUNDRED);
        StateUpdate stateUpdate = LightStateConverter.toColorLightState(hsbType, lightState);
        assertThat(stateUpdate.commands.size(), is(3));
        assertThat(stateUpdate.commands.get(1).key, is("sat"));
        lightState.sat = Integer.parseInt(stateUpdate.commands.get(1).value.toString());
        assertThat(LightStateConverter.toHSBType(lightState).getSaturation().intValue(), is(percent));
    }
}