本文整理汇总了Java中org.eclipse.smarthome.core.library.types.OnOffType类的典型用法代码示例。如果您正苦于以下问题:Java OnOffType类的具体用法?Java OnOffType怎么用?Java OnOffType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OnOffType类属于org.eclipse.smarthome.core.library.types包,在下文中一共展示了OnOffType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initGlobals
import org.eclipse.smarthome.core.library.types.OnOffType; //导入依赖的package包/类
private void initGlobals() {
kSession.setGlobal("logger", droolsLogger);
kSession.setGlobal("ON", OnOffType.ON);
kSession.setGlobal("OFF", OnOffType.OFF);
kSession.setGlobal("OPEN", OpenClosedType.OPEN);
kSession.setGlobal("CLOSED", OpenClosedType.CLOSED);
kSession.setGlobal("ZERO", PercentType.ZERO);
kSession.setGlobal("HUNDRED", PercentType.HUNDRED);
kSession.setGlobal("INCREASE", IncreaseDecreaseType.INCREASE);
kSession.setGlobal("DECREASE", IncreaseDecreaseType.DECREASE);
if (eventPublisher != null) {
kSession.setGlobal("openhab", eventPublisher);
}
logger.debug("Initialized global variables");
}
示例2: handleCommand
import org.eclipse.smarthome.core.library.types.OnOffType; //导入依赖的package包/类
@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)) {
}
}
示例3: run
import org.eclipse.smarthome.core.library.types.OnOffType; //导入依赖的package包/类
@Override
public void run() {
bridgeHandlerdisposalOngoing = false;
heos.startEventListener();
heos.startHeartBeat(heartBeatPulse);
logger.info("HEOS System heart beat startet. Pulse time is {}s", heartBeatPulse);
updateState(CH_ID_DYNGROUPSHAND, OnOffType.ON); // activates dynamic group handling by default
if (thing.getConfiguration().containsKey(USER_NAME) && thing.getConfiguration().containsKey(PASSWORD)) {
logger.info("Logging in to HEOS account.");
String name = thing.getConfiguration().get(USER_NAME).toString();
String password = thing.getConfiguration().get(PASSWORD).toString();
api.logIn(name, password);
} else {
logger.error("Can not log in. Username and Password not set");
}
}
示例4: handleCommand
import org.eclipse.smarthome.core.library.types.OnOffType; //导入依赖的package包/类
@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());
}
示例5: fetchSystemConfig
import org.eclipse.smarthome.core.library.types.OnOffType; //导入依赖的package包/类
private void fetchSystemConfig() throws FreeboxException {
SystemConfiguration systemConfiguration = fbClient.getSystemManager().getConfiguration();
updateState(new ChannelUID(getThing().getUID(), FWVERSION),
new StringType(systemConfiguration.getFirmware_version()));
long newUptime = systemConfiguration.getUptimeVal();
updateState(new ChannelUID(getThing().getUID(), RESTARTED),
newUptime < uptime ? OnOffType.ON : OnOffType.OFF );
uptime = newUptime;
updateState(new ChannelUID(getThing().getUID(), UPTIME),
new DecimalType(uptime));
updateState(new ChannelUID(getThing().getUID(), TEMPCPUM),
new DecimalType(systemConfiguration.getTemp_cpum()));
updateState(new ChannelUID(getThing().getUID(), TEMPCPUB),
new DecimalType(systemConfiguration.getTemp_cpub()));
updateState(new ChannelUID(getThing().getUID(), TEMPSWITCH),
new DecimalType(systemConfiguration.getTemp_sw()));
updateState(new ChannelUID(getThing().getUID(), FANSPEED),
new DecimalType(systemConfiguration.getFan_rpm()));
}
示例6: setForced
import org.eclipse.smarthome.core.library.types.OnOffType; //导入依赖的package包/类
private void setForced(Command command) throws FreeboxException {
if (command != null) {
if (command instanceof OnOffType
|| command instanceof OpenClosedType
|| command instanceof UpDownType) {
LCDConfig lcd = fbClient.getLCDManager().getLCDConfig();
lcd.setOrientationForced(
command.equals(OnOffType.ON) ||
command.equals(UpDownType.UP) ||
command.equals(OpenClosedType.OPEN)
);
fbClient.getLCDManager().setLCDConfig(lcd);
fetchLCDConfig();
}
}
}
示例7: setWifiStatus
import org.eclipse.smarthome.core.library.types.OnOffType; //导入依赖的package包/类
private void setWifiStatus(Command command) throws FreeboxException {
if (command != null) {
if (command instanceof OnOffType
|| command instanceof OpenClosedType
|| command instanceof UpDownType) {
WifiGlobalConfig wifiConfiguration = fbClient.getWifiManager().getGlobalConfig();
wifiConfiguration.setEnabled(
command.equals(OnOffType.ON) ||
command.equals(UpDownType.UP) ||
command.equals(OpenClosedType.OPEN)
);
fbClient.getWifiManager().setGlobalConfig(wifiConfiguration);
fetchWifiConfig();
}
}
}
示例8: handleCommand
import org.eclipse.smarthome.core.library.types.OnOffType; //导入依赖的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());
}
}
示例9: convertCommandToBooleanValue
import org.eclipse.smarthome.core.library.types.OnOffType; //导入依赖的package包/类
/**
* Convert openHAB command to boolean.
*
* @param command
* @return
*/
public static boolean convertCommandToBooleanValue(Command command) {
if (command instanceof OnOffType || command instanceof OpenClosedType || command instanceof UpDownType) {
boolean newValue;
if (command.equals(OnOffType.ON) || command.equals(UpDownType.UP) || command.equals(OpenClosedType.OPEN)) {
newValue = true;
} else if (command.equals(OnOffType.OFF) || command.equals(UpDownType.DOWN)
|| command.equals(OpenClosedType.CLOSED)) {
newValue = false;
} else {
throw new NumberFormatException("Command '" + command + "' not supported");
}
return newValue;
} else {
throw new NumberFormatException("Command '" + command + "' not supported for channel");
}
}
示例10: handleCommand
import org.eclipse.smarthome.core.library.types.OnOffType; //导入依赖的package包/类
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
if ((getThing().getStatus() == ThingStatus.OFFLINE)
&& ((getThing().getStatusInfo().getStatusDetail() == ThingStatusDetail.BRIDGE_OFFLINE)
|| (getThing().getStatusInfo().getStatusDetail() == ThingStatusDetail.CONFIGURATION_ERROR))) {
return;
}
try {
if (command == null || command instanceof RefreshType) {
return;
} else if (command instanceof StringType && PLAYURL.equals(channelUID.getId())) {
playMedia(command.toString());
} else if (command instanceof OnOffType && STOP.equals(channelUID.getId())) {
stopMedia();
} else {
logger.debug("Thing {}: unexpected command {} from channel {}", getThing().getUID(), command,
channelUID.getId());
}
} catch (FreeboxException e) {
logger.debug("Thing {}: error while handling command {} from channel {}", getThing().getUID(), command,
channelUID.getId(), e);
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR);
}
}
示例11: parseReport
import org.eclipse.smarthome.core.library.types.OnOffType; //导入依赖的package包/类
@Override
void parseReport(JsonObject data) {
boolean hasMotion = data.has(STATUS) && MOTION.equals(data.get(STATUS).getAsString());
if (data.has(LUX)) {
int illu = data.get(LUX).getAsInt();
updateState(CHANNEL_ILLUMINATION, new DecimalType(illu));
}
synchronized (this) {
if (hasMotion) {
updateState(CHANNEL_MOTION, OnOffType.ON);
updateState(CHANNEL_LAST_MOTION, new DateTimeType());
startTimer();
}
}
}
示例12: onDeviceStateChanged
import org.eclipse.smarthome.core.library.types.OnOffType; //导入依赖的package包/类
@Override
public void onDeviceStateChanged(ThingUID bridge, AbstractAudioDeviceConfig device) {
if (device.getPaName().equals(name)) {
updateStatus(ThingStatus.ONLINE);
logger.debug("Updating states of {} id: {}", device, PulseaudioBindingConstants.VOLUME_CHANNEL);
updateState(PulseaudioBindingConstants.VOLUME_CHANNEL, new PercentType(device.getVolume()));
updateState(PulseaudioBindingConstants.MUTE_CHANNEL, device.isMuted() ? OnOffType.ON : OnOffType.OFF);
updateState(PulseaudioBindingConstants.STATE_CHANNEL,
device.getState() != null ? new StringType(device.getState().toString()) : new StringType("-"));
if (device instanceof SinkInput) {
updateState(PulseaudioBindingConstants.ROUTE_TO_SINK_CHANNEL,
((SinkInput) device).getSink() != null
? new StringType(((SinkInput) device).getSink().getPaName())
: new StringType("-"));
}
if (device instanceof Sink && ((Sink) device).isCombinedSink()) {
updateState(PulseaudioBindingConstants.SLAVES_CHANNEL,
new StringType(StringUtils.join(((Sink) device).getCombinedSinkNames(), ",")));
}
}
}
示例13: handleCommand
import org.eclipse.smarthome.core.library.types.OnOffType; //导入依赖的package包/类
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
try {
if (channelUID.getId().equals("run")) {
if (command == OnOffType.ON) {
getBridgeHandler().sendCommand("unpause " + myId());
} else if (command == OnOffType.OFF) {
getBridgeHandler().sendCommand("pause " + myId());
}
} else if (channelUID.getId().equals("finish")) {
if (command == OnOffType.ON) {
getBridgeHandler().sendCommand("finish " + myId());
} else if (command == OnOffType.OFF) {
getBridgeHandler().sendCommand("unpause " + myId());
}
}
getBridgeHandler().refresh();
getBridgeHandler().delayedRefresh();
} catch (IOException e) {
logger.debug("Input/output error while handing command to Folding slot", e);
}
}
示例14: handleCommand
import org.eclipse.smarthome.core.library.types.OnOffType; //导入依赖的package包/类
@Override
public void handleCommand(final ChannelUID channelUID, final Command command) {
if (channelUID.getId().equals(WIFI_SOCKET_CHANNEL_ID)) {
logger.debug("Silvercrest socket command received: {}", command);
if (command == OnOffType.ON) {
this.sendCommand(SilvercrestWifiSocketRequestType.ON);
} else if (command == OnOffType.OFF) {
this.sendCommand(SilvercrestWifiSocketRequestType.OFF);
} else if (command == RefreshType.REFRESH) {
this.sendCommand(SilvercrestWifiSocketRequestType.GPIO_STATUS);
}
}
}
示例15: parseSuccessfulReply
import org.eclipse.smarthome.core.library.types.OnOffType; //导入依赖的package包/类
@Override
public void parseSuccessfulReply() {
if (deviceReply == null) {
return;
}
// decode response of form state,1:3,0
Pattern p = Pattern.compile("state,\\d:\\d,[01]");
Matcher m = p.matcher(deviceReply);
if (!m.matches()) {
logger.warn("Successful reply from device can't be matched: {}", deviceReply);
state = OnOffType.OFF;
return;
}
setModule(deviceReply.substring(6, 7));
setConnector(deviceReply.substring(8, 9));
setState((deviceReply.charAt(10) == '0' ? OnOffType.OFF : OnOffType.ON));
}