Search in sources :

Example 51 with PercentType

use of org.openhab.core.library.types.PercentType in project openhab1-addons by openhab.

the class AbstractDynamoDBItemSerializationTest method testPercentTypeWithColorItem.

@Test
public void testPercentTypeWithColorItem() throws IOException {
    DynamoDBItem<?> dbitem = testStateGeneric(new PercentType(new BigDecimal(3.2)), new BigDecimal(3.2));
    testAsHistoricGeneric(dbitem, new ColorItem("foo"), new PercentType(new BigDecimal(3.2)));
}
Also used : ColorItem(org.openhab.core.library.items.ColorItem) PercentType(org.openhab.core.library.types.PercentType) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 52 with PercentType

use of org.openhab.core.library.types.PercentType in project openhab1-addons by openhab.

the class AbstractDynamoDBItemSerializationTest method testPercentTypeWithNumberItem.

@Test
public void testPercentTypeWithNumberItem() throws IOException {
    DynamoDBItem<?> dbitem = testStateGeneric(new PercentType(new BigDecimal(3.2)), new BigDecimal(3.2));
    // note: comes back as DecimalType instead of the original PercentType
    testAsHistoricGeneric(dbitem, new NumberItem("foo"), new DecimalType(new BigDecimal(3.2)));
}
Also used : NumberItem(org.openhab.core.library.items.NumberItem) DecimalType(org.openhab.core.library.types.DecimalType) PercentType(org.openhab.core.library.types.PercentType) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 53 with PercentType

use of org.openhab.core.library.types.PercentType in project openhab1-addons by openhab.

the class AbstractDynamoDBItemSerializationTest method testOnOffTypeWithColorItem.

@Test
public void testOnOffTypeWithColorItem() throws IOException {
    DynamoDBItem<?> dbitemOff = testStateGeneric(OnOffType.OFF, BigDecimal.ZERO);
    testAsHistoricGeneric(dbitemOff, new ColorItem("foo"), new PercentType(BigDecimal.ZERO));
    DynamoDBItem<?> dbitemOn = testStateGeneric(OnOffType.ON, BigDecimal.ONE);
    testAsHistoricGeneric(dbitemOn, new ColorItem("foo"), new PercentType(BigDecimal.ONE));
}
Also used : ColorItem(org.openhab.core.library.items.ColorItem) PercentType(org.openhab.core.library.types.PercentType) Test(org.junit.Test)

Example 54 with PercentType

use of org.openhab.core.library.types.PercentType in project openhab1-addons by openhab.

the class LightwaveRfHeatingInfoResponse method getState.

@Override
public State getState(LightwaveRfType type) {
    switch(type) {
        case HEATING_BATTERY:
            return new DecimalType(getBatteryLevel());
        case SIGNAL:
            return new DecimalType(getSignal());
        case HEATING_CURRENT_TEMP:
            return new DecimalType(getCurrentTemperature());
        case HEATING_SET_TEMP:
            return new DecimalType(getCurrentTargetTemperature());
        case HEATING_MODE:
            return new StringType(getState());
        case HEATING_OUTPUT:
            return new PercentType(getOutput());
        case UPDATETIME:
            Calendar cal = Calendar.getInstance();
            cal.setTime(getTime());
            return new DateTimeType(cal);
        case VERSION:
            return new StringType(getVersion());
        default:
            return null;
    }
}
Also used : DateTimeType(org.openhab.core.library.types.DateTimeType) StringType(org.openhab.core.library.types.StringType) Calendar(java.util.Calendar) DecimalType(org.openhab.core.library.types.DecimalType) PercentType(org.openhab.core.library.types.PercentType)

Example 55 with PercentType

use of org.openhab.core.library.types.PercentType in project openhab1-addons by openhab.

the class OpenhabHSBData method getCommandValue.

@Override
public HSBType getCommandValue() {
    DecimalType h = new DecimalType(data.getHue());
    PercentType s = new PercentType((int) data.getSaturation());
    PercentType b = new PercentType((int) data.getBrightness());
    return new HSBType(h, s, b);
}
Also used : DecimalType(org.openhab.core.library.types.DecimalType) PercentType(org.openhab.core.library.types.PercentType) HSBType(org.openhab.core.library.types.HSBType)

Aggregations

PercentType (org.openhab.core.library.types.PercentType)105 DecimalType (org.openhab.core.library.types.DecimalType)43 State (org.openhab.core.types.State)29 StringType (org.openhab.core.library.types.StringType)27 DimmerItem (org.openhab.core.library.items.DimmerItem)22 Test (org.junit.Test)21 HSBType (org.openhab.core.library.types.HSBType)19 OnOffType (org.openhab.core.library.types.OnOffType)19 RollershutterItem (org.openhab.core.library.items.RollershutterItem)17 NumberItem (org.openhab.core.library.items.NumberItem)16 BigDecimal (java.math.BigDecimal)14 SwitchItem (org.openhab.core.library.items.SwitchItem)13 IncreaseDecreaseType (org.openhab.core.library.types.IncreaseDecreaseType)13 ColorItem (org.openhab.core.library.items.ColorItem)11 DateTimeType (org.openhab.core.library.types.DateTimeType)11 Calendar (java.util.Calendar)9 ContactItem (org.openhab.core.library.items.ContactItem)9 UpDownType (org.openhab.core.library.types.UpDownType)9 StopMoveType (org.openhab.core.library.types.StopMoveType)7 DateTimeItem (org.openhab.core.library.items.DateTimeItem)6