Search in sources :

Example 21 with HSBType

use of org.eclipse.smarthome.core.library.types.HSBType in project smarthome by eclipse.

the class ColorItemTest method testSetStateWithPercentType.

@Test
public void testSetStateWithPercentType() {
    ColorItem item = new ColorItem("test");
    item.setState(new PercentType(50));
    assertEquals(new HSBType(new DecimalType(0), new PercentType(0), new PercentType(50)), item.getState());
}
Also used : DecimalType(org.eclipse.smarthome.core.library.types.DecimalType) PercentType(org.eclipse.smarthome.core.library.types.PercentType) HSBType(org.eclipse.smarthome.core.library.types.HSBType) Test(org.junit.Test)

Example 22 with HSBType

use of org.eclipse.smarthome.core.library.types.HSBType in project smarthome by eclipse.

the class NumberItemTest method setHSBType.

@Test
public void setHSBType() {
    NumberItem item = new NumberItem("test");
    State hsb = new HSBType("5,23,42");
    item.setState(hsb);
    assertEquals(hsb, item.getState());
}
Also used : State(org.eclipse.smarthome.core.types.State) HSBType(org.eclipse.smarthome.core.library.types.HSBType) Test(org.junit.Test)

Example 23 with HSBType

use of org.eclipse.smarthome.core.library.types.HSBType in project smarthome by eclipse.

the class RollershutterItemTest method setState_stateHSB50_returnPercent50.

@Test
public void setState_stateHSB50_returnPercent50() {
    // HSB supported because it is a sub-type of PercentType
    RollershutterItem sut = new RollershutterItem("Test");
    State state = new HSBType("5,23,42");
    sut.setState(state);
    assertEquals(new PercentType(42), sut.getState());
}
Also used : State(org.eclipse.smarthome.core.types.State) PercentType(org.eclipse.smarthome.core.library.types.PercentType) HSBType(org.eclipse.smarthome.core.library.types.HSBType) Test(org.junit.Test)

Example 24 with HSBType

use of org.eclipse.smarthome.core.library.types.HSBType in project smarthome by eclipse.

the class SwitchItemTest method getAsHSBFromSwitch.

@Test
public void getAsHSBFromSwitch() {
    SwitchItem item = new SwitchItem("Test");
    item.setState(OnOffType.ON);
    assertEquals(new HSBType("0,0,100"), item.getStateAs(HSBType.class));
    item.setState(OnOffType.OFF);
    assertEquals(new HSBType("0,0,0"), item.getStateAs(HSBType.class));
}
Also used : HSBType(org.eclipse.smarthome.core.library.types.HSBType) Test(org.junit.Test)

Example 25 with HSBType

use of org.eclipse.smarthome.core.library.types.HSBType in project smarthome by eclipse.

the class TradfriColorTest method testFromCieKnownGood4.

@Test
public void testFromCieKnownGood4() {
    TradfriColor color = new TradfriColor(11413, 31334, 181);
    assertEquals(11413, (int) color.xyX);
    assertEquals(31334, (int) color.xyY);
    assertEquals(181, (int) color.brightness);
    HSBType hsbType = color.getHSB();
    assertNotNull(hsbType);
    assertEquals(158, hsbType.getHue().intValue());
    assertEquals(100, hsbType.getSaturation().intValue());
    assertEquals(72, hsbType.getBrightness().intValue());
}
Also used : HSBType(org.eclipse.smarthome.core.library.types.HSBType) Test(org.junit.Test)

Aggregations

HSBType (org.eclipse.smarthome.core.library.types.HSBType)34 Test (org.junit.Test)19 PercentType (org.eclipse.smarthome.core.library.types.PercentType)16 State (org.eclipse.smarthome.core.types.State)10 DecimalType (org.eclipse.smarthome.core.library.types.DecimalType)9 ColorItem (org.eclipse.smarthome.core.library.items.ColorItem)4 IncreaseDecreaseType (org.eclipse.smarthome.core.library.types.IncreaseDecreaseType)3 OnOffType (org.eclipse.smarthome.core.library.types.OnOffType)3 StringType (org.eclipse.smarthome.core.library.types.StringType)3 ChannelUID (org.eclipse.smarthome.core.thing.ChannelUID)2 RefreshType (org.eclipse.smarthome.core.types.RefreshType)2 Colorpicker (org.eclipse.smarthome.model.sitemap.Colorpicker)2 Mapping (org.eclipse.smarthome.model.sitemap.Mapping)2 Switch (org.eclipse.smarthome.model.sitemap.Switch)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 BigDecimal (java.math.BigDecimal)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Locale (java.util.Locale)1 MissingResourceException (java.util.MissingResourceException)1