Search in sources :

Example 21 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 22 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)

Example 23 with PercentType

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

the class ItemStateRequestProcessor method getState.

private StateTransformable getState(Item item) {
    StateTransformable state = null;
    if (item.getState() instanceof HSBType) {
        HSBType hsb = (HSBType) item.getState();
        state = new HSBData(hsb.getHue().longValue(), hsb.getHue().longValue(), hsb.getHue().longValue());
    } else if (item.getState() instanceof DateTimeType) {
        DateTimeType dt = (DateTimeType) item.getState();
        DateTimeDataType data = new DateTimeDataType(dt.toString());
        state = new DateTimeData(data);
    } else if (item.getState() instanceof DecimalType) {
    } else if (item.getState() instanceof OnOffType) {
    } else if (item.getState() instanceof OpenClosedType) {
    } else if (item.getState() instanceof PercentType) {
    } else if (item.getState() instanceof UpDownType) {
    }
    return state;
}
Also used : DateTimeType(org.openhab.core.library.types.DateTimeType) DateTimeDataType(org.creek.mailcontrol.model.types.DateTimeDataType) StateTransformable(org.creek.mailcontrol.model.data.StateTransformable) HSBData(org.creek.mailcontrol.model.data.HSBData) OnOffType(org.openhab.core.library.types.OnOffType) OpenClosedType(org.openhab.core.library.types.OpenClosedType) DecimalType(org.openhab.core.library.types.DecimalType) DateTimeData(org.creek.mailcontrol.model.data.DateTimeData) UpDownType(org.openhab.core.library.types.UpDownType) PercentType(org.openhab.core.library.types.PercentType) HSBType(org.openhab.core.library.types.HSBType)

Example 24 with PercentType

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

the class OutputVisualize method visualizationHandleOutputStatus.

/** {@inheritDoc} */
@Override
public boolean visualizationHandleOutputStatus(ModStatusOutput pchkInput, Command cmd, Item item, EventPublisher eventPublisher) {
    if (pchkInput.getLogicalSourceAddr().equals(this.addr) && pchkInput.getOutputId() == this.outputId) {
        if (item.getAcceptedDataTypes().contains(StringType.class)) {
            String value = new DecimalFormat("0.#").format(pchkInput.getPercent());
            eventPublisher.postUpdate(item.getName(), new StringType(value));
            return true;
        } else if (item.getAcceptedDataTypes().contains(PercentType.class)) {
            eventPublisher.postUpdate(item.getName(), new PercentType((int) Math.round(pchkInput.getPercent())));
            return true;
        } else if (item.getAcceptedDataTypes().contains(DecimalType.class)) {
            eventPublisher.postUpdate(item.getName(), new DecimalType(pchkInput.getPercent()));
            return true;
        } else if (item.getAcceptedDataTypes().contains(OnOffType.class)) {
            eventPublisher.postUpdate(item.getName(), pchkInput.getPercent() != 0 ? OnOffType.ON : OnOffType.OFF);
            return true;
        }
    }
    return false;
}
Also used : StringType(org.openhab.core.library.types.StringType) OnOffType(org.openhab.core.library.types.OnOffType) DecimalFormat(java.text.DecimalFormat) DecimalType(org.openhab.core.library.types.DecimalType) PercentType(org.openhab.core.library.types.PercentType)

Example 25 with PercentType

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

the class LightwaveRfBindingFunctionalTest method testInOnlyMessageReceived.

@Test
public void testInOnlyMessageReceived() throws Exception {
    String message = "030271,101,!R3D2FdP13|Living Room|Side Light 2 40%";
    testReceivingACommandAndVerify(new DimmerItem("LivingRoom"), "<room=3,device=2,type=DIMMER", message, new PercentType("41"));
}
Also used : DimmerItem(org.openhab.core.library.items.DimmerItem) PercentType(org.openhab.core.library.types.PercentType) Test(org.junit.Test)

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