本文整理汇总了Java中org.openhab.core.library.types.OnOffType.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java OnOffType.valueOf方法的具体用法?Java OnOffType.valueOf怎么用?Java OnOffType.valueOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openhab.core.library.types.OnOffType
的用法示例。
在下文中一共展示了OnOffType.valueOf方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createState
import org.openhab.core.library.types.OnOffType; //导入方法依赖的package包/类
/**
* Returns a {@link State} which is inherited from the {@link Item}s
* accepted DataTypes. The call is delegated to the {@link TypeParser}. If
* <code>item</code> is <code>null</code> the {@link StringType} is used.
*
* @param itemType
* @param transformedResponse
*
* @return a {@link State} which type is inherited by the {@link TypeParser}
* or a {@link StringType} if <code>item</code> is <code>null</code>
*/
private State createState(Class<? extends Item> itemType, String transformedResponse) {
try {
if (itemType.isAssignableFrom(NumberItem.class)) {
return DecimalType.valueOf(transformedResponse);
} else if (itemType.isAssignableFrom(ContactItem.class)) {
return OpenClosedType.valueOf(transformedResponse);
} else if (itemType.isAssignableFrom(SwitchItem.class)) {
return OnOffType.valueOf(transformedResponse);
} else if (itemType.isAssignableFrom(RollershutterItem.class)) {
return PercentType.valueOf(transformedResponse);
} else if (itemType.isAssignableFrom(DateTimeItem.class)) {
return DateTimeType.valueOf(transformedResponse);
} else {
return StringType.valueOf(transformedResponse);
}
} catch (Exception e) {
logger.debug("Couldn't create state of type '{}' for value '{}'", itemType, transformedResponse);
return StringType.valueOf(transformedResponse);
}
}
示例2: createState
import org.openhab.core.library.types.OnOffType; //导入方法依赖的package包/类
private State createState(Class<? extends Item> itemType,
String transformedResponse) {
try {
if (itemType.isAssignableFrom(NumberItem.class)) {
return DecimalType.valueOf(transformedResponse);
} else if (itemType.isAssignableFrom(SwitchItem.class)) {
return OnOffType.valueOf(transformedResponse);
} else if (itemType.isAssignableFrom(DimmerItem.class)) {
return PercentType.valueOf(transformedResponse);
} else {
return StringType.valueOf(transformedResponse);
}
} catch (Exception e) {
logger.debug("Couldn't create state of type '{}' for value '{}'",
itemType, transformedResponse);
return StringType.valueOf(transformedResponse);
}
}
示例3: getOHState
import org.openhab.core.library.types.OnOffType; //导入方法依赖的package包/类
@Override
/**
* Returns a type used by openHAB to show the actual state of the souliss' typical
* @return org.openhab.core.types.State
*/
public State getOHState() {
String sOHState = StateTraslator.statesSoulissToOH(this.getNote(),
this.getType(), (short) this.getState());
if (sOHState != null) {
if (this.getNote().equals("ContactItem"))
return OpenClosedType.valueOf(sOHState);
else
return OnOffType.valueOf(sOHState);
}
return null;
}
示例4: createState
import org.openhab.core.library.types.OnOffType; //导入方法依赖的package包/类
/**
* Returns a {@link State} which is inherited from the {@link Item}s
* accepted DataTypes. The call is delegated to the {@link TypeParser}. If
* <code>item</code> is <code>null</code> the {@link StringType} is used.
*
* @param itemType
* @param transformedResponse
*
* @return a {@link State} which type is inherited by the {@link TypeParser}
* or a {@link StringType} if <code>item</code> is <code>null</code>
*/
private State createState(Class<? extends Item> itemType,
String transformedResponse) {
try {
if (itemType.isAssignableFrom(NumberItem.class)) {
return DecimalType.valueOf(transformedResponse);
} else if (itemType.isAssignableFrom(ContactItem.class)) {
return OpenClosedType.valueOf(transformedResponse);
} else if (itemType.isAssignableFrom(SwitchItem.class)) {
return OnOffType.valueOf(transformedResponse);
} else if (itemType.isAssignableFrom(RollershutterItem.class)) {
return PercentType.valueOf(transformedResponse);
} else {
return StringType.valueOf(transformedResponse);
}
} catch (Exception e) {
logger.debug("Couldn't create state of type '{}' for value '{}'",
itemType, transformedResponse);
return StringType.valueOf(transformedResponse);
}
}
示例5: createState
import org.openhab.core.library.types.OnOffType; //导入方法依赖的package包/类
/**
* Returns a {@link State} which is inherited from the {@link Item}s
* accepted DataTypes. The call is delegated to the {@link TypeParser}. If
* <code>item</code> is <code>null</code> the {@link StringType} is used.
*
* @param itemType
* @param transformedResponse
*
* @return a {@link State} which type is inherited by the {@link TypeParser}
* or a {@link StringType} if <code>item</code> is <code>null</code>
*/
private State createState(Class<? extends Item> itemType, String transformedResponse) {
try {
if (itemType.isAssignableFrom(NumberItem.class)) {
return DecimalType.valueOf(transformedResponse);
} else if (itemType.isAssignableFrom(ContactItem.class)) {
return OpenClosedType.valueOf(transformedResponse);
} else if (itemType.isAssignableFrom(SwitchItem.class)) {
return OnOffType.valueOf(transformedResponse);
} else if (itemType.isAssignableFrom(RollershutterItem.class)) {
return PercentType.valueOf(transformedResponse);
} else {
return StringType.valueOf(transformedResponse);
}
} catch (Exception e) {
logger.debug("Couldn't create state of type '{}' for value '{}'", itemType, transformedResponse);
return StringType.valueOf(transformedResponse);
}
}
示例6: getOHState
import org.openhab.core.library.types.OnOffType; //导入方法依赖的package包/类
@Override
public State getOHState() {
String sOHState = StateTraslator.statesSoulissToOH(this.getNote(),
this.getType(), (short) this.getState());
if (sOHState != null) {
if (this.getNote().equals("ContactItem"))
return OpenClosedType.valueOf(sOHState);
else
return OnOffType.valueOf(sOHState);
}
return null;
}
示例7: getOHState
import org.openhab.core.library.types.OnOffType; //导入方法依赖的package包/类
@Override
/**
* Returns a type used in openHAB to show the actual state of the souliss' typical
* @return org.openhab.core.types.State
*/
public State getOHState() {
String sOHState = StateTraslator.statesSoulissToOH(this.getNote(),
this.getType(), (short) this.getState());
if (sOHState != null) {
return OnOffType.valueOf(sOHState);
} else {
return new PercentType(
String.valueOf((this.getState() / 250) * 100));
}
}
示例8: getOHState
import org.openhab.core.library.types.OnOffType; //导入方法依赖的package包/类
@Override
public State getOHState() {
String sOHState = StateTraslator.statesSoulissToOH(this.getNote(),
this.getType(), (short) this.getState(iBit));
if (sOHState != null) {
if (this.getNote().equals("ContactItem"))
return OpenClosedType.valueOf(sOHState);
else
return OnOffType.valueOf(sOHState);
}
return null;
}
示例9: convertToImpl
import org.openhab.core.library.types.OnOffType; //导入方法依赖的package包/类
@Override
protected OnOffType convertToImpl(OnOffState source) {
return OnOffType.valueOf(source.name());
}
示例10: dispatchPdu
import org.openhab.core.library.types.OnOffType; //导入方法依赖的package包/类
private void dispatchPdu(Address address, PDU pdu) {
if (pdu != null & address != null) {
logger.debug("Received PDU from '{}' '{}'", address, pdu);
for (SnmpBindingProvider provider : providers) {
for (String itemName : provider.getItemNames()) {
// Check the IP address
if (!provider.getAddress(itemName).equals(address)) {
continue;
}
// Check the OID
OID oid = provider.getOID(itemName);
Variable variable = pdu.getVariable(oid);
if (variable != null) {
Class<? extends Item> itemType = provider.getItemType(itemName);
// Do any transformations
String value = variable.toString();
try {
value = provider.doTransformation(itemName, value);
} catch (TransformationException e) {
logger.error("Transformation error with item {}: {}", itemName, e);
}
// Change to a state
State state = null;
if (itemType.isAssignableFrom(StringItem.class)) {
state = StringType.valueOf(value);
} else if (itemType.isAssignableFrom(NumberItem.class)) {
state = DecimalType.valueOf(value);
} else if (itemType.isAssignableFrom(SwitchItem.class)) {
state = OnOffType.valueOf(value);
}
if (state != null) {
eventPublisher.postUpdate(itemName, state);
} else {
logger.debug(
"'{}' couldn't be parsed to a State. Valid State-Types are String and Number",
variable.toString());
}
} else {
logger.trace("PDU doesn't contain a variable with OID ‘{}‘", oid.toString());
}
}
}
}
}
示例11: getOpenhabStateFromZibaseValue
import org.openhab.core.library.types.OnOffType; //导入方法依赖的package包/类
/**
* {@link Inherited}
*/
@Override
public State getOpenhabStateFromZibaseValue(Zibase zibase, String zbResponseStr) {
return OnOffType.valueOf(zibase.getState(this.getId()) ? "ON":"OFF");
}
示例12: getCommandValue
import org.openhab.core.library.types.OnOffType; //导入方法依赖的package包/类
@Override
public OnOffType getCommandValue() {
return OnOffType.valueOf(data.name());
}