Search in sources :

Example 86 with DecimalType

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

the class TestSHCMessage method testEnvBrightnessMin.

/**
     * test data is: environment brightness: 0 % (min)
     */
@Test
public void testEnvBrightnessMin() {
    String message = " PKT:SID=10;PC=123;MT=8;MGID=11;MID=1;MD=000000000006;b1c1e93d";
    SHCMessage shcMessage = new SHCMessage(message, packet);
    List<Type> values = shcMessage.getData().getOpenHABTypes();
    assertEquals(0, ((DecimalType) values.get(0)).intValue());
}
Also used : Type(org.openhab.core.types.Type) OnOffType(org.openhab.core.library.types.OnOffType) DecimalType(org.openhab.core.library.types.DecimalType) SHCMessage(org.openhab.binding.smarthomatic.internal.SHCMessage) Test(org.junit.Test)

Example 87 with DecimalType

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

the class TestSHCMessage method testWeatherBaroTempMin.

/**
     * test data is: weather barometric pressure: 0 temp: -32768
     */
@Test
public void testWeatherBaroTempMin() {
    String message = " PKT:SID=11;PC=68029;MT=8;MGID=10;MID=3;MD=000040000000;30bd729d";
    SHCMessage shcMessage = new SHCMessage(message, packet);
    List<Type> values = shcMessage.getData().getOpenHABTypes();
    assertEquals(0, ((DecimalType) values.get(0)).intValue());
    assertEquals(-32768, ((DecimalType) values.get(1)).intValue());
}
Also used : Type(org.openhab.core.types.Type) OnOffType(org.openhab.core.library.types.OnOffType) DecimalType(org.openhab.core.library.types.DecimalType) SHCMessage(org.openhab.binding.smarthomatic.internal.SHCMessage) Test(org.junit.Test)

Example 88 with DecimalType

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

the class TestSHCMessage method testGenericVersionMinMax2.

/**
     * test data for the generic messages version: 255.0.255-0
     */
@Test
public void testGenericVersionMinMax2() {
    String message = " PKT:SID=10;PC=165;MT=8;MGID=0;MID=1;MD=FF00FF00000000;a72a6224";
    SHCMessage shcMessage = new SHCMessage(message, packet);
    List<Type> values = shcMessage.getData().getOpenHABTypes();
    assertEquals("Major", 255, ((DecimalType) values.get(0)).intValue());
    assertEquals("Minor", 0, ((DecimalType) values.get(1)).intValue());
    assertEquals("Patch", 255, ((DecimalType) values.get(2)).intValue());
    assertEquals("Hash", 0, ((DecimalType) values.get(3)).intValue());
}
Also used : Type(org.openhab.core.types.Type) OnOffType(org.openhab.core.library.types.OnOffType) DecimalType(org.openhab.core.library.types.DecimalType) SHCMessage(org.openhab.binding.smarthomatic.internal.SHCMessage) Test(org.junit.Test)

Example 89 with DecimalType

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

the class IntegraStateBindingConfig method convertEventToState.

/**
     * {@inheritDoc}
     */
@Override
public State convertEventToState(Item item, SatelEvent event) {
    if (!(event instanceof IntegraStateEvent) || hasOptionEnabled(Options.COMMANDS_ONLY)) {
        return null;
    }
    IntegraStateEvent stateEvent = (IntegraStateEvent) event;
    if (stateEvent.getStateType() != this.stateType) {
        return null;
    }
    if (this.objectNumbers.length == 1) {
        int bitNbr = this.objectNumbers[0] - 1;
        boolean invertState = hasOptionEnabled(Options.INVERT_STATE) && (this.stateType.getObjectType() == ObjectType.ZONE || this.stateType.getObjectType() == ObjectType.OUTPUT);
        return booleanToState(item, stateEvent.isSet(bitNbr) ^ invertState);
    } else if (this.objectNumbers.length == 0) {
        int statesSet = stateEvent.statesSet();
        if (item instanceof NumberItem) {
            return new DecimalType(statesSet);
        } else {
            return booleanToState(item, statesSet > 0);
        }
    } else if (this.objectNumbers.length == 2 && item instanceof RollershutterItem) {
        // roller shutter support
        int upBitNbr = this.objectNumbers[0] - 1;
        int downBitNbr = this.objectNumbers[1] - 1;
        if (stateEvent.isSet(upBitNbr)) {
            if (!stateEvent.isSet(downBitNbr)) {
                return UpDownType.UP;
            }
        } else if (stateEvent.isSet(downBitNbr)) {
            return UpDownType.DOWN;
        }
    }
    return null;
}
Also used : IntegraStateEvent(org.openhab.binding.satel.internal.event.IntegraStateEvent) NumberItem(org.openhab.core.library.items.NumberItem) RollershutterItem(org.openhab.core.library.items.RollershutterItem) DecimalType(org.openhab.core.library.types.DecimalType)

Example 90 with DecimalType

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

the class TestSHCMessage method testEnvDistanceMax.

/**
     * test data is: enviroment distance: 16383 cm (max)
     */
@Test
public void testEnvDistanceMax() {
    String message = " PKT:SID=11;PC=68047;MT=8;MGID=11;MID=2;MD=FFFC00000000;2a1d0241";
    SHCMessage shcMessage = new SHCMessage(message, packet);
    List<Type> values = shcMessage.getData().getOpenHABTypes();
    assertEquals(16383, ((DecimalType) values.get(0)).intValue());
}
Also used : Type(org.openhab.core.types.Type) OnOffType(org.openhab.core.library.types.OnOffType) DecimalType(org.openhab.core.library.types.DecimalType) SHCMessage(org.openhab.binding.smarthomatic.internal.SHCMessage) Test(org.junit.Test)

Aggregations

DecimalType (org.openhab.core.library.types.DecimalType)222 Test (org.junit.Test)70 StringType (org.openhab.core.library.types.StringType)69 OnOffType (org.openhab.core.library.types.OnOffType)63 PercentType (org.openhab.core.library.types.PercentType)43 State (org.openhab.core.types.State)40 Type (org.openhab.core.types.Type)39 NumberItem (org.openhab.core.library.items.NumberItem)38 SHCMessage (org.openhab.binding.smarthomatic.internal.SHCMessage)37 DateTimeType (org.openhab.core.library.types.DateTimeType)29 BigDecimal (java.math.BigDecimal)23 Calendar (java.util.Calendar)23 HSBType (org.openhab.core.library.types.HSBType)20 SwitchItem (org.openhab.core.library.items.SwitchItem)18 IOException (java.io.IOException)16 StringItem (org.openhab.core.library.items.StringItem)16 ConfigurationException (org.osgi.service.cm.ConfigurationException)16 RollershutterItem (org.openhab.core.library.items.RollershutterItem)15 ContactItem (org.openhab.core.library.items.ContactItem)14 DimmerItem (org.openhab.core.library.items.DimmerItem)14