本文整理汇总了Java中org.eclipse.smarthome.core.types.State类的典型用法代码示例。如果您正苦于以下问题:Java State类的具体用法?Java State怎么用?Java State使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
State类属于org.eclipse.smarthome.core.types包,在下文中一共展示了State类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapState
import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
private org.openhab.core.types.State mapState(State state, String itemName) {
if(state==null) return null;
Item eshItem;
try {
eshItem = itemRegistry.getItem(itemName);
if(eshItem!=null) {
return org.openhab.core.types.TypeParser.parseState(
ItemMapper.mapToOpenHABItem(eshItem).getAcceptedDataTypes(), state.toString());
} else {
return null;
}
} catch (ItemNotFoundException e) {
return null;
}
}
示例2: handleCommand
import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
if (command instanceof RefreshType) {
switch (channelUID.getId()) {
case CHANNEL_ONLINE:
try {
State state = networkService.updateDeviceState() ? OnOffType.ON : OnOffType.OFF;
updateState(CHANNEL_ONLINE, state);
} catch( InvalidConfigurationException invalidConfigurationException) {
getThing().setStatus(ThingStatus.OFFLINE);
}
break;
default:
logger.debug("Command received for an unknown channel: {}", channelUID.getId());
break;
}
} else {
logger.debug("Command {} is not supported for channel: {}", command, channelUID.getId());
}
}
示例3: convertNetUsbPlayStatus
import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
private State convertNetUsbPlayStatus(String data) {
State state = UnDefType.UNDEF;
switch (data.charAt(0)) {
case 'P':
state = PlayPauseType.PLAY;
break;
case 'p':
case 'S':
state = PlayPauseType.PAUSE;
break;
case 'F':
state = RewindFastforwardType.FASTFORWARD;
break;
case 'R':
state = RewindFastforwardType.REWIND;
break;
}
return state;
}
示例4: getNAThingProperty
import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
@Override
protected State getNAThingProperty(String channelId) {
try {
if (channelId.equalsIgnoreCase(CHANNEL_LAST_MESSAGE) && module != null) {
Method getLastMessage = module.getClass().getMethod("getLastMessage");
Integer lastMessage = (Integer) getLastMessage.invoke(module);
return ChannelTypeUtils.toDateTimeType(lastMessage);
}
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException e) {
logger.error("The module has no method to access {} property ", channelId);
return UnDefType.NULL;
}
return super.getNAThingProperty(channelId);
}
示例5: getChannelState
import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
@Override
protected State getChannelState(ChannelUID channelUID, SmokeDetector smokeDetector) {
switch (channelUID.getId()) {
case CHANNEL_CO_ALARM_STATE:
return new StringType(smokeDetector.getCoAlarmState().toString());
case CHANNEL_LAST_CONNECTION:
return getAsDateTimeTypeOrNull(smokeDetector.getLastConnection());
case CHANNEL_LAST_MANUAL_TEST_TIME:
return getAsDateTimeTypeOrNull(smokeDetector.getLastManualTestTime());
case CHANNEL_LOW_BATTERY:
return getAsOnOffType(smokeDetector.getBatteryHealth() == BatteryHealth.REPLACE);
case CHANNEL_MANUAL_TEST_ACTIVE:
return getAsOnOffType(smokeDetector.isManualTestActive());
case CHANNEL_SMOKE_ALARM_STATE:
return new StringType(smokeDetector.getSmokeAlarmState().toString());
case CHANNEL_UI_COLOR_STATE:
return new StringType(smokeDetector.getUiColorState().toString());
default:
logger.error("Unsupported channelId '{}'", channelUID.getId());
return UnDefType.UNDEF;
}
}
示例6: setBrightness
import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
@Override
public CompletableFuture<Void> setBrightness(Integer value) throws Exception {
if (value == null) {
value = 0;
}
State state = getItem().getStateAs(HSBType.class);
if (state instanceof HSBType) {
HSBType hsb = (HSBType) state;
HSBType newState = new HSBType(hsb.getHue(), hsb.getSaturation(), new PercentType(value));
((ColorItem) getItem()).send(newState);
return CompletableFuture.completedFuture(null);
} else {
// state is undefined (light is not connected)
return CompletableFuture.completedFuture(null);
}
}
示例7: handleUpdate
import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
@Override
public void handleUpdate(ChannelUID channelUID, State newState) {
logger.debug("Update {} for channel {} received", newState, channelUID);
switch (channelUID.getId()) {
case CHANNEL_BRIGHTNESS:
if (newState instanceof PercentType) {
lastBrigthness = ((PercentType) newState).intValue();
}
break;
case CHANNEL_COLOR:
if (newState instanceof HSBType) {
lastColor = ((HSBType) newState).getRGB();
}
break;
case CHANNEL_GATEWAY_VOLUME:
if (newState instanceof DecimalType) {
updateLastVolume((DecimalType) newState);
}
break;
}
}
示例8: convertToState
import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
@Override
public State convertToState(String channelId) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_WIND_DIRECTION:
return new DecimalType(windDirection);
case CHANNEL_AVG_WIND_SPEED:
return new DecimalType(avgWindSpeed);
case CHANNEL_WIND_SPEED:
return new DecimalType(windSpeed);
case CHANNEL_TEMPERATURE:
return new DecimalType(temperature);
case CHANNEL_CHILL_TEMPERATURE:
return new DecimalType(chillTemperature);
default:
return super.convertToState(channelId);
}
}
示例9: getNAThingProperty
import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
@Override
protected State getNAThingProperty(String chanelId) {
switch (chanelId) {
case CHANNEL_WELCOME_CAMERA_STATUS:
return module != null ? toOnOffType(module.getStatus()) : UnDefType.UNDEF;
case CHANNEL_WELCOME_CAMERA_SDSTATUS:
return module != null ? toOnOffType(module.getSdStatus()) : UnDefType.UNDEF;
case CHANNEL_WELCOME_CAMERA_ALIMSTATUS:
return module != null ? toOnOffType(module.getAlimStatus()) : UnDefType.UNDEF;
case CHANNEL_WELCOME_CAMERA_ISLOCAL:
return (module == null || module.getIsLocal() == null) ? UnDefType.UNDEF
: module.getIsLocal() ? OnOffType.ON : OnOffType.OFF;
case CHANNEL_WELCOME_CAMERA_LIVEPICTURE_URL:
return getLivePictureURL() == null ? UnDefType.UNDEF : toStringType(getLivePictureURL());
case CHANNEL_WELCOME_CAMERA_LIVEPICTURE:
return getLivePictureURL() == null ? UnDefType.UNDEF : HttpUtil.downloadImage(getLivePictureURL());
case CHANNEL_WELCOME_CAMERA_LIVESTREAM_URL:
return getLiveStreamURL() == null ? UnDefType.UNDEF : new StringType(getLiveStreamURL());
}
return super.getNAThingProperty(chanelId);
}
示例10: handleMMInfoText
import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
/**
* Helper method to handle MMInfoText notifications. There may be multiple infotext messages that represent a single
* message. We know when we get the last info text when the MMATTR contains an 'E' (last item). Once we have the
* last item, we update the channel with the complete message.
*
* @param infoTextValue the last info text value
* @return a non-null containing the complete or null if the message isn't complete yet
*/
private String handleMMInfoText(String infoTextValue) {
final StatefulHandlerCallback callback = ((StatefulHandlerCallback) getCallback());
final State attr = callback.getProperty(RioConstants.CHANNEL_SOURCEMMATTR);
infoLock.lock();
try {
infoText.append(infoTextValue.toString());
if (attr != null && attr.toString().indexOf("E") >= 0) {
final String text = infoText.toString();
infoText.setLength(0);
callback.removeState(RioConstants.CHANNEL_SOURCEMMATTR);
return text;
}
return null;
} finally {
infoLock.unlock();
}
}
示例11: handleVolumeSet
import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
private void handleVolumeSet(EiscpCommand.Zone zone, final State currentValue, final Command command) {
if (command instanceof PercentType) {
sendCommand(EiscpCommand.getCommandForZone(zone, EiscpCommand.VOLUME_SET),
downScaleVolume((PercentType) command));
} else if (command.equals(IncreaseDecreaseType.INCREASE)) {
if (currentValue instanceof PercentType) {
if (((DecimalType) currentValue).intValue() < configuration.volumeLimit) {
sendCommand(EiscpCommand.getCommandForZone(zone, EiscpCommand.VOLUME_UP));
} else {
logger.info("Volume level is limited to {}, ignore volume up command.", configuration.volumeLimit);
}
}
} else if (command.equals(IncreaseDecreaseType.DECREASE)) {
sendCommand(EiscpCommand.getCommandForZone(zone, EiscpCommand.VOLUME_DOWN));
} else if (command.equals(OnOffType.OFF)) {
sendCommand(EiscpCommand.getCommandForZone(zone, EiscpCommand.MUTE_SET), command);
} else if (command.equals(OnOffType.ON)) {
sendCommand(EiscpCommand.getCommandForZone(zone, EiscpCommand.MUTE_SET), command);
} else if (command.equals(RefreshType.REFRESH)) {
sendCommand(EiscpCommand.getCommandForZone(zone, EiscpCommand.VOLUME_QUERY));
sendCommand(EiscpCommand.getCommandForZone(zone, EiscpCommand.MUTE_QUERY));
}
}
示例12: stateUpdated
import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
@Override
public void stateUpdated(Item item, State state) {
if (item instanceof GroupItem) {
// group item update could be relevant for the client, although the state of switch group does not change
// wenn more the one are on, the number-groupFunction changes
Map<String, Class<? extends State>> clientItems = eventBroadcaster.getClientItems(item);
if (clientItems != null && clientItems.size() > 0) {
for (String cvItemName : clientItems.keySet()) {
Class<? extends State> stateClass = clientItems.get(cvItemName);
if (stateClass != null) {
StateBean stateBean = new StateBean();
stateBean.name = cvItemName;
stateBean.state = item.getStateAs(stateClass).toString();
eventBroadcaster.broadcastEvent(stateBean);
}
}
}
}
}
示例13: convertToState
import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
@Override
public State convertToState(String channelId) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_CHANNEL1_AMPS:
return new DecimalType(channel1Amps);
case CHANNEL_CHANNEL2_AMPS:
return new DecimalType(channel2Amps);
case CHANNEL_CHANNEL3_AMPS:
return new DecimalType(channel3Amps);
default:
return super.convertToState(channelId);
}
}
示例14: itemStateEvent
import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
private void itemStateEvent(ItemStateEvent event) throws ItemNotFoundException {
String itemName = event.getItemName();
State itemState = event.getItemState();
Item item = itemRegistry.getItem(itemName);
for (EventSubscriberStruct subscriberStruct : eventSubscribers) {
subscriberStruct.eventSubscriber
.stateUpdated(new com.incquerylabs.smarthome.eventbus.api.events.ItemStateEvent(item, itemState));
}
logger.trace(event.toString());
}
示例15: itemStateChangedEvent
import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
private void itemStateChangedEvent(ItemStateChangedEvent event) throws ItemNotFoundException {
String itemName = event.getItemName();
State newState = event.getItemState();
State oldState = event.getOldItemState();
Item item = itemRegistry.getItem(itemName);
for (EventSubscriberStruct subscriberStruct : eventSubscribers) {
subscriberStruct.eventSubscriber.stateChanged(
new com.incquerylabs.smarthome.eventbus.api.events.ItemStateChangedEvent(item, newState, oldState));
}
logger.trace(event.toString());
}