• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java OnOffType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.smarthome.core.library.types.OnOffType的典型用法代码示例。如果您正苦于以下问题:Java OnOffType类的具体用法?Java OnOffType怎么用?Java OnOffType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OnOffType类属于org.eclipse.smarthome.core.library.types包,在下文中一共展示了OnOffType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: updateDevice

import org.eclipse.smarthome.core.library.types.OnOffType; //导入依赖的package包/类
private void updateDevice(DeviceConfig info) {
    if (info == null) {
        return;
    }

    if (info.getIsConnected() != null) {
        if (info.getIsConnected() != 0) {
            if (!ThingStatus.ONLINE.equals(getThing().getStatus())) {
                updateStatus(ThingStatus.ONLINE);
            }
        } else {
            if (!ThingStatus.OFFLINE.equals(getThing().getStatus())) {
                updateStatus(ThingStatus.OFFLINE);
            }
        }
    }

    if (info.getCurrentState() != null) {
        updateChannel(CHANNEL_SWITCH_BINARY, info.getCurrentState() == 0 ? OnOffType.OFF : OnOffType.ON);
    }
    if (info.getCurrentUsage() != null) {
        BigDecimal d = new BigDecimal(info.getCurrentUsage()).setScale(1, BigDecimal.ROUND_HALF_UP);
        updateChannel(CHANNEL_POWER_CONSUMPTION, new DecimalType(d));
    }

}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:27,代码来源:ToonPlugHandler.java


示例17: handleLightPower

import org.eclipse.smarthome.core.library.types.OnOffType; //导入依赖的package包/类
private void handleLightPower(Command command) {
    if (!isLightPresent()) {
        logger.debug("Fan does not have light installed for command {}", command);
        return;
    }

    logger.debug("Handling light power command {}", command);
    // <mac;LIGHT;PWR;ON|OFF>
    if (command instanceof OnOffType) {
        if (command.equals(OnOffType.OFF)) {
            sendCommand(macAddress, ";LIGHT;PWR;OFF");
        } else if (command.equals(OnOffType.ON)) {
            sendCommand(macAddress, ";LIGHT;PWR;ON");
        }
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:17,代码来源:BigAssFanHandler.java


示例18: handleLightSmarter

import org.eclipse.smarthome.core.library.types.OnOffType; //导入依赖的package包/类
private void handleLightSmarter(Command command) {
    if (!isLightPresent()) {
        logger.debug("Fan does not have light installed for command {}", command);
        return;
    }

    logger.debug("Handling light smartmode command {}", command);
    // <mac;LIGHT;SMART;ON/OFF>
    if (command instanceof OnOffType) {
        if (command.equals(OnOffType.OFF)) {
            sendCommand(macAddress, ";LIGHT;SMART;OFF");
        } else if (command.equals(OnOffType.ON)) {
            sendCommand(macAddress, ";LIGHT;SMART;ON");
        }
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:17,代码来源:BigAssFanHandler.java


示例19: handlePercentage

import org.eclipse.smarthome.core.library.types.OnOffType; //导入依赖的package包/类
/**
 * Handle percentType commands. Action depends on what channel send the command. For brightness related channels
 * after the brightness command an extra onOff command is send to update the onOff state conform the brightness
 * state.
 *
 * @param channelUID Channel the command is for
 * @param command The percentType command
 * @throws IOException Connection to the bulb failed
 */
private void handlePercentage(ChannelUID channelUID, PercentType command) throws IOException {
    String id = channelUID.getId();

    switch (id) {
        case CHANNEL_COLOR:
            handleBrightness(command);
            handleOnOff((OnOffType) command.as(OnOffType.class));
            break;
        case CHANNEL_COLOR_TEMPERATURE:
            handleColorTemperature(command);
            handleOnOff(OnOffType.ON);
            break;
        case CHANNEL_PROGRAM_SPEED:
            handleProgramSpeed(command);
            handleOnOff(OnOffType.ON);
            break;
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:28,代码来源:FeicanHandler.java


示例20: sendPowerCommand

import org.eclipse.smarthome.core.library.types.OnOffType; //导入依赖的package包/类
@Override
public boolean sendPowerCommand(Command command, int zone) throws CommandTypeNotSupportedException {
    AvrCommand commandToSend = null;

    if (command == OnOffType.ON) {
        commandToSend = RequestResponseFactory.getIpControlCommand(SimpleCommandType.POWER_ON, zone);
        // Send the first Power ON command.
        sendCommand(commandToSend);

        // According to the Pioneer Specs, the first request only wakeup the
        // AVR CPU, the second one Power ON the AVR. Still according to the Pioneer Specs, the second
        // request has to be delayed of 100 ms.
        try {
            TimeUnit.MILLISECONDS.sleep(100);
        } catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
        }

    } else if (command == OnOffType.OFF) {
        commandToSend = RequestResponseFactory.getIpControlCommand(SimpleCommandType.POWER_OFF, zone);
    } else {
        throw new CommandTypeNotSupportedException("Command type not supported.");
    }

    return sendCommand(commandToSend);
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:27,代码来源:StreamAvrConnection.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SSTableScanner类代码示例发布时间:2022-05-22
下一篇:
Java TitleBuffer类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap