Search in sources :

Example 36 with Type

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

the class TestSHCMessage method testDimmerBrightnessMin.

/**
     * test data is: Dimmer Brightness: 0 (min)
     */
@Test
public void testDimmerBrightnessMin() {
    String message = " PKT:SID=13;PC=301;MT=8;MGID=60;MID=1;MD=000000000004;3519983e";
    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 37 with Type

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

the class TestSHCMessage method testDimmerColorMax.

/**
     * test data is: Dimmer Color: 63 (max)
     */
@Test
public void testDimmerColorMax() {
    String message = " PKT:SID=12;PC=203;MT=8;MGID=60;MID=10;MD=FC0000000003;cc022ece";
    SHCMessage shcMessage = new SHCMessage(message, packet);
    List<Type> values = shcMessage.getData().getOpenHABTypes();
    assertEquals(63, ((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 38 with Type

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

the class TestSHCMessage method testGenericBattMax.

/**
     * test data for the generic messages battery: 127
     */
@Test
public void testGenericBattMax() {
    String message = " PKT:SID=10;PC=164;MT=8;MGID=0;MID=5;MD=FE0000000004;60b90a98";
    SHCMessage shcMessage = new SHCMessage(message, packet);
    List<Type> values = shcMessage.getData().getOpenHABTypes();
    assertEquals(127, ((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 39 with Type

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

the class AbstractOneWireDevicePropertyBindingConfig method convertReadValueToType.

/**
     *
     * @param pvReadValue
     * @return the modified and converted given readValue String as a
     *         openHab-Type
     */
public Type convertReadValueToType(String pvReadValue) {
    Type lvType = convertReadValueToUnmodifiedType(pvReadValue);
    for (OneWireTypeModifier lvTypeModifier : getTypeModifieryList()) {
        logger.debug("type of {} before modifier:{} type={}", getDevicePropertyPath(), lvTypeModifier.getModifierName(), lvType);
        lvType = lvTypeModifier.modify4Read(lvType);
        logger.debug("type of {} after modifier:{} type={}", getDevicePropertyPath(), lvTypeModifier.getModifierName(), lvType);
    }
    return lvType;
}
Also used : OneWireTypeModifier(org.openhab.binding.onewire.internal.deviceproperties.modifier.OneWireTypeModifier) Type(org.openhab.core.types.Type)

Example 40 with Type

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

the class KNXCoreTypeMapperTest method testTypeMappingB1U3.

/**
     * Convenience method: testing KNXCoretypeMapper for type “Datapoint Types B1U3 Controlled"
     *
     * @throws KNXFormatException
     */
private void testTypeMappingB1U3(DPT dpt, Class<? extends Type> expectedClass, String valueLow, String valueHigh) throws KNXFormatException {
    testToTypeClass(dpt, expectedClass);
    // Use a too short byte array
    assertNull("KNXCoreTypeMapper.toType() should return null (required data length too short)", testToType(dpt, new byte[] {}, expectedClass));
    // 3 lsb set to 0 indicate a break.
    Type type = testToType(dpt, new byte[] { 0x00 }, expectedClass);
    assertEquals("KNXCoreTypeMapper.toType() should return IncreaseDecreaseType.INCREASE for break messages", IncreaseDecreaseType.INCREASE, type);
    // 3 lsb set to 8 indicate a break.
    type = testToType(dpt, new byte[] { 0x08 }, expectedClass);
    assertEquals("KNXCoreTypeMapper.toType() should return IncreaseDecreaseType.INCREASE for break messages", IncreaseDecreaseType.INCREASE, type);
    type = testToType(dpt, new byte[] { 0x01 }, expectedClass);
    testToDPTValue(dpt, type, valueLow);
    type = testToType(dpt, new byte[] { 0x0F }, expectedClass);
    testToDPTValue(dpt, type, valueHigh);
    // Check that additional bit (4 msb) will be ignored
    type = testToType(dpt, new byte[] { (byte) 0xFF }, expectedClass);
    testToDPTValue(dpt, type, valueHigh);
    // Use a too long byte array expecting that additional bytes will be ignored
    type = testToType(dpt, new byte[] { (byte) 0x0F, 0 }, expectedClass);
    testToDPTValue(dpt, type, valueHigh);
}
Also used : OpenClosedType(org.openhab.core.library.types.OpenClosedType) IncreaseDecreaseType(org.openhab.core.library.types.IncreaseDecreaseType) StringType(org.openhab.core.library.types.StringType) OnOffType(org.openhab.core.library.types.OnOffType) DateTimeType(org.openhab.core.library.types.DateTimeType) Type(org.openhab.core.types.Type) DecimalType(org.openhab.core.library.types.DecimalType) UpDownType(org.openhab.core.library.types.UpDownType) PercentType(org.openhab.core.library.types.PercentType) HSBType(org.openhab.core.library.types.HSBType) StopMoveType(org.openhab.core.library.types.StopMoveType)

Aggregations

Type (org.openhab.core.types.Type)72 DecimalType (org.openhab.core.library.types.DecimalType)69 OnOffType (org.openhab.core.library.types.OnOffType)68 Test (org.junit.Test)60 SHCMessage (org.openhab.binding.smarthomatic.internal.SHCMessage)40 IncreaseDecreaseType (org.openhab.core.library.types.IncreaseDecreaseType)27 StringType (org.openhab.core.library.types.StringType)27 DateTimeType (org.openhab.core.library.types.DateTimeType)26 HSBType (org.openhab.core.library.types.HSBType)26 OpenClosedType (org.openhab.core.library.types.OpenClosedType)26 PercentType (org.openhab.core.library.types.PercentType)26 StopMoveType (org.openhab.core.library.types.StopMoveType)26 UpDownType (org.openhab.core.library.types.UpDownType)26 DPT (tuwien.auto.calimero.dptxlator.DPT)20 Command (org.openhab.core.types.Command)2 UnDefType (org.openhab.core.types.UnDefType)2 Calendar (java.util.Calendar)1 Locale (java.util.Locale)1 StringTokenizer (java.util.StringTokenizer)1 IllegalClassException (org.apache.commons.lang.IllegalClassException)1