Search in sources :

Example 26 with SHCMessage

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

the class TestSHCMessage method testGPIOAnalogPortAllMixed.

/**
     * test data is: GPIO AnalogPort:
     * c4c000c4c0008000010FF2FF00000000000000000000
     */
@Test
public void testGPIOAnalogPortAllMixed() {
    String message = " PKT:SID=11;PC=2238;MT=8;MGID=1;MID=10;MD=c4c000c4c0008000010FF2FF00000000000000000000;d4e9f531";
    SHCMessage shcMessage = new SHCMessage(message, packet);
    List<Type> values = shcMessage.getData().getOpenHABTypes();
    assertEquals(16, values.size());
    assertEquals("Port0", OnOffType.ON, values.get(0));
    assertEquals("Port0", 1100, ((DecimalType) values.get(1)).intValue());
    assertEquals("Port1", OnOffType.OFF, values.get(2));
    assertEquals("Port1", 0, ((DecimalType) values.get(3)).intValue());
    assertEquals("Port2", OnOffType.ON, values.get(4));
    assertEquals("Port2", 1100, ((DecimalType) values.get(5)).intValue());
    assertEquals("Port3", OnOffType.OFF, values.get(6));
    assertEquals("Port3", 0, ((DecimalType) values.get(7)).intValue());
    assertEquals("Port4", OnOffType.ON, values.get(8));
    assertEquals("Port4", 0, ((DecimalType) values.get(9)).intValue());
    assertEquals("Port5", OnOffType.OFF, values.get(10));
    assertEquals("Port5", 1, ((DecimalType) values.get(11)).intValue());
    assertEquals("Port6", OnOffType.OFF, values.get(12));
    assertEquals("Port6", 255, ((DecimalType) values.get(13)).intValue());
    assertEquals("Port7", OnOffType.OFF, values.get(14));
    assertEquals("Port7", 767, ((DecimalType) values.get(15)).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 27 with SHCMessage

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

the class TestSHCMessage method testDimmerAnimationMax.

/**
     * test data is: Dimmer Animation: 100 (max)
     */
@Test
public void testDimmerAnimationMax() {
    String message = " PKT:SID=13;PC=534;MT=10;MGID=60;MID=2;MD=7ffff20000000000000000000000000000;c5c81435";
    SHCMessage shcMessage = new SHCMessage(message, packet);
    List<Type> values = shcMessage.getData().getOpenHABTypes();
    assertEquals("AnimationMode", 1, ((DecimalType) values.get(0)).intValue());
    assertEquals("TimeoutSec", 65535, ((DecimalType) values.get(1)).intValue());
    assertEquals("StartBrightness", 100, ((DecimalType) values.get(2)).intValue());
    assertEquals("EndBrightness", 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 28 with SHCMessage

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

the class TestSHCMessage method testGenericVersionMax.

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

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

the class TestSHCMessage method testDimmerColorTyp.

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

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

the class TestSHCMessage method testDimmerColorAnimationTyp.

/**
     * test data is: Dimmer Color Animation: (typ)
     */
@Test
public void testDimmerColorAnimationTyp() {
    String message = "PKT:SID=12;PC=9417;MT=10;MGID=60;MID=11;MD=1230418000000000000000000000000000;68ddbb91";
    SHCMessage shcMessage = new SHCMessage(message, packet);
    List<Type> values = shcMessage.getData().getOpenHABTypes();
    assertEquals("Repeat", 1, ((DecimalType) values.get(0)).intValue());
    assertEquals("AutoReverse", OnOffType.OFF, (values.get(1)));
    assertEquals("Time0", 8, ((DecimalType) values.get(2)).intValue());
    assertEquals("Color0", 48, ((DecimalType) values.get(3)).intValue());
    assertEquals("Time1", 8, ((DecimalType) values.get(4)).intValue());
    assertEquals("Color1", 12, ((DecimalType) values.get(5)).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

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