本文整理汇总了Java中org.eclipse.smarthome.core.library.types.OnOffType.ON属性的典型用法代码示例。如果您正苦于以下问题:Java OnOffType.ON属性的具体用法?Java OnOffType.ON怎么用?Java OnOffType.ON使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.smarthome.core.library.types.OnOffType
的用法示例。
在下文中一共展示了OnOffType.ON属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleCommand
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
if (channelUID.getId().equals(ALLOW_PIR_SWITCH)) {
// TODO: handle command
// Note: if communication with thing fails for some reason,
// indicate that by setting the status with detail information
// updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
// "Could not control device at IP address x.x.x.x");
} else if (channelUID.getId().equals(PIR_SWITCH)) {
if ((OnOffType) command == OnOffType.ON) {
triggerChannel(getThing().getChannel(EVENT_CHANNEL_ID_MOTION).getUID(), EVENT_MOTION_START);
triggerChannel(getThing().getChannel(EVENT_CHANNEL_ID_MOTION_START).getUID(), EVENT_MOTION_START);
} else if ((OnOffType) command == OnOffType.OFF) {
triggerChannel(getThing().getChannel(EVENT_CHANNEL_ID_MOTION).getUID(), EVENT_MOTION_STOP);
triggerChannel(getThing().getChannel(EVENT_CHANNEL_ID_MOTION_STOP).getUID(), EVENT_MOTION_STOP);
}
} else if (channelUID.getId().equals(MQTT_SWITCH)) {
} else if (channelUID.getId().equals(MOTION)) {
}
}
示例2: handleCommand
@Override
public void handleCommand(final Command command) {
int level = 0;
if (command instanceof PercentType) {
level = ((PercentType) command).intValue();
} else if (command instanceof OnOffType) {
OnOffType cmdOnOff = (OnOffType) command;
if (cmdOnOff == OnOffType.ON) {
level = 100;
} else {
level = 0;
}
}
clusterLevelControl.moveToLevelWithOnOffCommand((int) (level * 254.0 / 100.0 + 0.5),
configLevelControl.getDefaultTransitionTime());
}
示例3: handleCommand
@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());
}
}
示例4: getNAThingProperty
@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);
}
示例5: convertToState
@Override
public State convertToState(String channelId) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_COMMAND:
case CHANNEL_MOTION:
return command.isOn() ? OnOffType.ON : OnOffType.OFF;
case CHANNEL_CONTACT:
return command.isOn() ? OpenClosedType.OPEN : OpenClosedType.CLOSED;
case CHANNEL_COMMAND_ID:
return new DecimalType(commandId);
default:
return super.convertToState(channelId);
}
}
示例6: convertFromState
@Override
public void convertFromState(String channelId, Type type) throws RFXComUnsupportedChannelException {
switch (channelId) {
case CHANNEL_COMMAND:
if (type instanceof OnOffType) {
if (group) {
command = (type == OnOffType.ON ? Commands.GROUP_ON : Commands.GROUP_OFF);
} else {
command = (type == OnOffType.ON ? Commands.ON : Commands.OFF);
}
} else {
throw new RFXComUnsupportedChannelException("Channel " + channelId + " does not accept " + type);
}
break;
default:
throw new RFXComUnsupportedChannelException("Channel " + channelId + " is not relevant here");
}
}
示例7: getSwing
public State getSwing() {
if (zoneState.getSetting().getType() == TadoSystemType.AIR_CONDITIONING) {
CoolingZoneSetting setting = (CoolingZoneSetting) zoneState.getSetting();
if (setting.getSwing() == null) {
return UnDefType.NULL;
} else if (setting.getSwing() == Power.ON) {
return OnOffType.ON;
} else {
return OnOffType.OFF;
}
} else {
return UnDefType.UNDEF;
}
}
示例8: commandReceived
@Override
public void commandReceived(ZclCommand command) {
if (command instanceof ZoneStatusChangeNotificationCommand) {
ZoneStatusChangeNotificationCommand zoneStatus = (ZoneStatusChangeNotificationCommand) command;
OnOffType state = ((zoneStatus.getZoneStatus() & 0x01) != 0) ? OnOffType.ON : OnOffType.OFF;
updateChannelState(state);
}
}
示例9: commandReceived
@Override
public void commandReceived(ZclCommand command) {
if (command instanceof ZoneStatusChangeNotificationCommand) {
ZoneStatusChangeNotificationCommand zoneStatus = (ZoneStatusChangeNotificationCommand) command;
OnOffType state = ((zoneStatus.getZoneStatus() & 0x02) != 0) ? OnOffType.ON : OnOffType.OFF;
updateChannelState(state);
}
}
示例10: setBrightness
public void setBrightness(Command command) throws FreeboxException {
if (command != null) {
if (command instanceof OnOffType || command instanceof IncreaseDecreaseType ||
command instanceof DecimalType || command instanceof PercentType) {
LCDConfig lcd = fbClient.getLCDManager().getLCDConfig();
int value = 0;
int newValue = 0;
if (command instanceof IncreaseDecreaseType) {
value = lcd.getBrightness();
if (command == IncreaseDecreaseType.INCREASE) {
newValue = Math.min(100, value + 1);
} else {
newValue = Math.max(0, value - 1);
}
} else if (command instanceof OnOffType) {
newValue = (command == OnOffType.ON) ? 100 : 0;
} else if (command instanceof DecimalType) {
newValue = Math.min(100, ((DecimalType) command).intValue());
newValue = Math.max(newValue, 0);
} else {
return;
}
lcd.setBrightness(newValue);
fbClient.getLCDManager().setLCDConfig(lcd);
fetchLCDConfig();
}
}
}
示例11: startAutomaticRefresh
private void startAutomaticRefresh() {
Runnable runnable = new Runnable() {
public void run() {
try {
State state = networkService.updateDeviceState() ? OnOffType.ON : OnOffType.OFF;
updateState(CHANNEL_ONLINE, state);
} catch( InvalidConfigurationException invalidConfigurationException) {
getThing().setStatus(ThingStatus.OFFLINE);
}
}
};
refreshJob = scheduler.scheduleAtFixedRate(runnable, 0, networkService.getRefreshInterval(), TimeUnit.MILLISECONDS);
}
示例12: handleSendEvent
@Override
public void handleSendEvent(Device device, int resendCount, boolean isdimmer, Command command)
throws TellstickException {
logger.info("Send {} to {}", command, device);
if (device instanceof TellstickNetDevice) {
if (command == OnOffType.ON) {
turnOn(device);
} else if (command == OnOffType.OFF) {
turnOff(device);
} else if (command instanceof PercentType) {
dim(device, (PercentType) command);
} else if (command instanceof IncreaseDecreaseType) {
increaseDecrease(device, ((IncreaseDecreaseType) command));
}
} else if (device instanceof SwitchableDevice) {
if (command == OnOffType.ON) {
if (isdimmer) {
logger.debug("Turn off first in case it is allready on");
turnOff(device);
}
turnOn(device);
} else if (command == OnOffType.OFF) {
turnOff(device);
}
} else {
logger.warn("Cannot send to {}", device);
}
}
示例13: isLowBattery
/**
* Check if battery level is below low battery threshold level.
*
* @param batteryLevel Internal battery level
* @return OnOffType
*/
private State isLowBattery(State batteryLevel) {
int level = ((DecimalType) batteryLevel).intValue();
if (level <= LOW_BATTERY_LEVEL) {
return OnOffType.ON;
} else {
return OnOffType.OFF;
}
}
示例14: updateMotion
private void updateMotion(String[] messageParts) {
if (messageParts.length != 4) {
logger.debug("SNSROCC has unexpected number of parameters: {}", Arrays.toString(messageParts));
return;
}
logger.debug("Process motion sensor update for {}: {}", thing.getUID(), messageParts[3]);
OnOffType state = "OCCUPIED".equalsIgnoreCase(messageParts[3]) ? OnOffType.ON : OnOffType.OFF;
updateChannel(CHANNEL_MOTION, state);
fanStateMap.put(CHANNEL_MOTION, state);
}
示例15: handleCommand
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
try {
if (command instanceof RefreshType) {
refresh();
} else if (channelUID.getId().equals("run")) {
if (command == OnOffType.ON) {
sendCommand("unpause");
} else if (command == OnOffType.OFF) {
sendCommand("pause");
}
refresh();
delayedRefresh();
} else if (channelUID.getId().equals("finish")) {
if (command == OnOffType.ON) {
sendCommand("finish");
} else if (command == OnOffType.OFF) {
sendCommand("unpause");
}
refresh();
delayedRefresh();
}
} catch (IOException e) {
logger.debug("Input/output error while handing command", e);
disconnected();
}
}