use of org.openhab.binding.satel.internal.event.IntegraStateEvent 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;
}
Aggregations