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());
}
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());
}
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());
}
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;
}
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);
}
Aggregations