当前位置: 首页>>代码示例>>Java>>正文


Java OnOffType类代码示例

本文整理汇总了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");
}
 
开发者ID:IncQueryLabs,项目名称:smarthome-cep-demonstrator,代码行数:17,代码来源:DroolsEventBusClient.java

示例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)) {

    }
}
 
开发者ID:IncQueryLabs,项目名称:smarthome-cep-demonstrator,代码行数:24,代码来源:SimpleMotionSensorHandler.java

示例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");
    }
}
 
开发者ID:Wire82,项目名称:org.openhab.binding.heos,代码行数:20,代码来源:HeosBridgeHandler.java

示例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());
}
 
开发者ID:openhab,项目名称:org.openhab.binding.zigbee,代码行数:18,代码来源:ZigBeeConverterSwitchLevel.java

示例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()));
}
 
开发者ID:Neulinet,项目名称:Zoo,代码行数:23,代码来源:FreeboxHandler.java

示例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();	
		}
	}		
}
 
开发者ID:Neulinet,项目名称:Zoo,代码行数:19,代码来源:FreeboxHandler.java

示例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();	
		}
	}	
}
 
开发者ID:Neulinet,项目名称:Zoo,代码行数:20,代码来源:FreeboxHandler.java

示例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());
       }	
}
 
开发者ID:Neulinet,项目名称:Zoo,代码行数:21,代码来源:NetworkHandler.java

示例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");
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:28,代码来源:DataConverters.java

示例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);
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:25,代码来源:FreeboxThingHandler.java

示例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();
        }
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:18,代码来源:XiaomiSensorMotionHandler.java

示例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(), ",")));
        }
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:22,代码来源:PulseaudioHandler.java

示例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);
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:23,代码来源:SlotHandler.java

示例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);
        }
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:17,代码来源:SilvercrestWifiSocketHandler.java

示例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));
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:20,代码来源:CommandGetstate.java


注:本文中的org.eclipse.smarthome.core.library.types.OnOffType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。