Search in sources :

Example 21 with SHCMessage

use of org.openhab.binding.smarthomatic.internal.SHCMessage 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 22 with SHCMessage

use of org.openhab.binding.smarthomatic.internal.SHCMessage 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 23 with SHCMessage

use of org.openhab.binding.smarthomatic.internal.SHCMessage in project openhab1-addons by openhab.

the class TestSHCMessage method testGPIODigitalPortAllMixed.

/**
     * test data is: GPIO DigitalPort: 10100101b
     */
@Test
public void testGPIODigitalPortAllMixed() {
    String message = " PKT:SID=150;PC=1688;MT=8;MGID=1;MID=1;MD=a50000000004;584ea808";
    SHCMessage shcMessage = new SHCMessage(message, packet);
    List<Type> values = shcMessage.getData().getOpenHABTypes();
    assertEquals(8, values.size());
    assertEquals(OnOffType.ON, values.get(0));
    assertEquals(OnOffType.OFF, values.get(1));
    assertEquals(OnOffType.ON, values.get(2));
    assertEquals(OnOffType.OFF, values.get(3));
    assertEquals(OnOffType.OFF, values.get(4));
    assertEquals(OnOffType.ON, values.get(5));
    assertEquals(OnOffType.OFF, values.get(6));
    assertEquals(OnOffType.ON, values.get(7));
}
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 24 with SHCMessage

use of org.openhab.binding.smarthomatic.internal.SHCMessage in project openhab1-addons by openhab.

the class TestSHCMessage method testGenericVersionMinMax1.

/**
     * test data for the generic messages version: 0.255.0-255 TODO: Hash
     * parsing isn't working with the max hast value of 4294967295
     */
@Test
public void testGenericVersionMinMax1() {
    String message = " PKT:SID=10;PC=165;MT=8;MGID=0;MID=1;MD=00FF00000000FF;849eb439";
    SHCMessage shcMessage = new SHCMessage(message, packet);
    List<Type> values = shcMessage.getData().getOpenHABTypes();
    assertEquals("Major", 0, ((DecimalType) values.get(0)).intValue());
    assertEquals("Minor", 255, ((DecimalType) values.get(1)).intValue());
    assertEquals("Patch", 0, ((DecimalType) values.get(2)).intValue());
    assertEquals("Hash", 255, ((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 25 with SHCMessage

use of org.openhab.binding.smarthomatic.internal.SHCMessage in project openhab1-addons by openhab.

the class TestSHCMessage method testGPIODigitalPortAllOn.

/**
     * test data is: GPIO DigitalPort: 11111111b
     */
@Test
public void testGPIODigitalPortAllOn() {
    String message = " PKT:SID=150;PC=1688;MT=8;MGID=1;MID=1;MD=ff0000000004;6ed826ac";
    SHCMessage shcMessage = new SHCMessage(message, packet);
    List<Type> values = shcMessage.getData().getOpenHABTypes();
    assertEquals(8, values.size());
    for (Type type : values) {
        assertEquals(OnOffType.ON, type);
    }
}
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

Test (org.junit.Test)40 SHCMessage (org.openhab.binding.smarthomatic.internal.SHCMessage)40 DecimalType (org.openhab.core.library.types.DecimalType)40 OnOffType (org.openhab.core.library.types.OnOffType)40 Type (org.openhab.core.types.Type)40