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