use of org.openhab.binding.tinkerforge.internal.types.DirectionValue in project openhab1-addons by openhab.
the class MBrickDCImpl method setDirection.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void setDirection(DirectionValue newDirection) {
DirectionValue oldDirection = direction;
direction = newDirection;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MBRICK_DC__DIRECTION, oldDirection, direction));
}
use of org.openhab.binding.tinkerforge.internal.types.DirectionValue in project openhab1-addons by openhab.
the class MServoImpl method setDirection.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void setDirection(DirectionValue newDirection) {
DirectionValue oldDirection = direction;
direction = newDirection;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MSERVO__DIRECTION, oldDirection, direction));
}
use of org.openhab.binding.tinkerforge.internal.types.DirectionValue in project openhab1-addons by openhab.
the class TinkerforgeBinding method postUpdate.
private void postUpdate(String uid, String subId, TinkerforgeValue sensorValue) {
// TODO undef handling
logger.trace("postUpdate called for uid {} subid {}", uid, subId);
Map<String, TinkerforgeBindingProvider> providerMap = getBindingProviders(uid, subId);
if (providerMap.size() == 0) {
logger.debug("{} found no item for uid {}, subid {}", LoggerConstants.TFMODELUPDATE, uid, subId);
}
for (Entry<String, TinkerforgeBindingProvider> entry : providerMap.entrySet()) {
String itemName = entry.getKey();
TinkerforgeBindingProvider provider = entry.getValue();
Class<? extends Item> itemType = provider.getItemType(itemName);
State value = UnDefType.UNDEF;
if (sensorValue instanceof DecimalValue) {
if (itemType.isAssignableFrom(NumberItem.class) || itemType.isAssignableFrom(StringItem.class)) {
value = DecimalType.valueOf(String.valueOf(sensorValue));
logger.trace("found item to update for DecimalValue {}", itemName);
} else if (itemType.isAssignableFrom(ContactItem.class)) {
value = sensorValue.equals(DecimalValue.ZERO) ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
} else if (itemType.isAssignableFrom(SwitchItem.class)) {
value = sensorValue.equals(DecimalValue.ZERO) ? OnOffType.OFF : OnOffType.ON;
} else {
logger.trace("no update for DecimalValue for item {}", itemName);
continue;
}
} else if (sensorValue instanceof HighLowValue) {
if (itemType.isAssignableFrom(NumberItem.class) || itemType.isAssignableFrom(StringItem.class)) {
value = sensorValue == HighLowValue.HIGH ? DecimalType.valueOf("1") : DecimalType.valueOf("0");
} else if (itemType.isAssignableFrom(ContactItem.class)) {
value = sensorValue == HighLowValue.HIGH ? OpenClosedType.OPEN : OpenClosedType.CLOSED;
} else if (itemType.isAssignableFrom(SwitchItem.class)) {
value = sensorValue == HighLowValue.HIGH ? OnOffType.ON : OnOffType.OFF;
} else {
continue;
}
} else if (sensorValue instanceof OnOffValue) {
if (itemType.isAssignableFrom(NumberItem.class) || itemType.isAssignableFrom(StringItem.class)) {
value = sensorValue == OnOffValue.ON ? DecimalType.valueOf("1") : DecimalType.valueOf("0");
} else if (itemType.isAssignableFrom(ContactItem.class)) {
value = sensorValue == OnOffValue.ON ? OpenClosedType.OPEN : OpenClosedType.CLOSED;
} else if (itemType.isAssignableFrom(SwitchItem.class)) {
value = sensorValue == OnOffValue.ON ? OnOffType.ON : OnOffType.OFF;
} else {
continue;
}
} else if (sensorValue instanceof PercentValue) {
if (itemType.isAssignableFrom(SwitchItem.class)) {
value = ((PercentValue) sensorValue).toBigDecimal().compareTo(BigDecimal.ZERO) == 1 ? OnOffType.ON : OnOffType.OFF;
logger.debug("switch found {}", itemName);
} else if (itemType.isAssignableFrom(RollershutterItem.class) || itemType.isAssignableFrom(DimmerItem.class)) {
value = new PercentType(((PercentValue) sensorValue).toBigDecimal());
logger.debug("Rollershutter or dimmer found {} {}", itemName);
} else if (itemType.isAssignableFrom(ContactItem.class)) {
value = ((PercentValue) sensorValue).toBigDecimal().compareTo(BigDecimal.ZERO) == -1 ? OpenClosedType.OPEN : OpenClosedType.CLOSED;
logger.debug("contact found {}", itemName);
} else {
continue;
}
} else if (sensorValue instanceof DirectionValue) {
if (itemType.isAssignableFrom(RollershutterItem.class)) {
value = sensorValue == DirectionValue.RIGHT ? UpDownType.UP : UpDownType.DOWN;
logger.trace("found item to update for UpDownValue {}", itemName);
} else {
continue;
}
} else if (sensorValue instanceof HSBValue) {
if (itemType.isAssignableFrom(ColorItem.class)) {
logger.trace("found item to update for HSBValue {}", itemName);
value = ((HSBValue) sensorValue).getHsbValue();
}
} else if (sensorValue == UnDefValue.UNDEF || sensorValue == null) {
value = UnDefType.UNDEF;
}
eventPublisher.postUpdate(itemName, value);
logger.debug("{} postupdate: found sensorValue: {} for item {}", LoggerConstants.TFMODELUPDATE, sensorValue, itemName);
}
}
Aggregations