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

Java DiscoveryResultBuilder类代码示例

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

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



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

示例1: createResult

import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder; //导入依赖的package包/类
@Override
public DiscoveryResult createResult(RemoteDevice device) {

    ThingUID uid = getThingUID(device);
    if (uid != null) {

        Map<String, Object> properties = new HashMap<>(2);
        properties.put(HOST, device.getIdentity().getDescriptorURL().getHost());
        properties.put(NAME, device.getDetails().getModelDetails().getModelName());
        DiscoveryResult result = DiscoveryResultBuilder.create(uid).withProperties(properties)
                .withLabel(device.getDetails().getFriendlyName()).withRepresentationProperty(PLAYER_TYPE).build();
        // Debug
        // System.out.println(device.getDetails().getFriendlyName());
        // System.out.println(uid.toString());
        // System.out.println(device.getDetails().getManufacturerDetails().getManufacturer());
        // System.out.println(device.getDetails().getModelDetails().getModelName());
        // System.out.println(device.getIdentity().getDescriptorURL().getHost().toString());
        // System.out.println(device.getIdentity().getUdn().getIdentifierString());
        // System.out.println(device.getType().getType() + "\n");

        logger.info("Found HEOS device with UID: {}", uid.getAsString());
        return result;
    }

    return null;
}
 
开发者ID:Wire82,项目名称:org.openhab.binding.heos,代码行数:27,代码来源:HeosDiscoveryParticipant.java


示例2: detectThing

import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder; //导入依赖的package包/类
private void detectThing(DatagramPacket packet) throws IOException {
    String data = Util
            .decrypt(new ByteArrayInputStream(Arrays.copyOfRange(packet.getData(), 0, packet.getLength())), true);

    logger.debug("Detecting HS110 by data: {}", data);

    String inetAddress = packet.getAddress().getHostAddress();
    String id = HS110.parseDeviceId(data);
    logger.debug("HS110 with id {} found on {} ", id, inetAddress);
    ThingUID thingUID = new ThingUID(HS110BindingConstants.THING_TYPE_HS110, id);
    String label = "HS110 at " + inetAddress;
    Map<String, Object> properties = new TreeMap<>();
    properties.put(HS110BindingConstants.CONFIG_IP, inetAddress);
    DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withLabel(label)
            .withProperties(properties).build();
    thingDiscovered(discoveryResult);
}
 
开发者ID:computerlyrik,项目名称:openhab2-addon-hs110,代码行数:18,代码来源:HS110DiscoveryService.java


示例3: onWMBusMessageReceivedInternal

import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder; //导入依赖的package包/类
private void onWMBusMessageReceivedInternal(WMBusMessage wmBusDevice) {
    // try to find this device in the list of supported devices
    ThingUID thingUID = getThingUID(wmBusDevice);

    if (thingUID != null) {
        // device known -> create discovery result
        ThingUID bridgeUID = bridgeHandler.getThing().getUID();
        Map<String, Object> properties = new HashMap<>(1);
        properties.put(PROPERTY_HKV_ID, wmBusDevice.getSecondaryAddress().getDeviceId().toString());

        // TODO label according to uid
        DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withProperties(properties)
                .withRepresentationProperty(wmBusDevice.getSecondaryAddress().getDeviceId().toString())
                .withBridge(bridgeUID)
                .withLabel("Techem Heizkostenverteiler #" + wmBusDevice.getSecondaryAddress().getDeviceId())
                .build();
        thingDiscovered(discoveryResult);
    } else {
        // device unknown -> log message
        logger.debug("discovered unsupported WMBus device of type '{}' with id {}", wmBusDevice.getSecondaryAddress().getDeviceType(), wmBusDevice.getSecondaryAddress().getDeviceId());
    }
}
 
开发者ID:pokerazor,项目名称:openhab-binding-wmbus,代码行数:23,代码来源:WMBusHKVDiscoveryService.java


示例4: submitDiscoveryResults

import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder; //导入依赖的package包/类
/**
 * Submit the discovered Devices to the Smarthome inbox,
 * 
 * @param ip The Device IP
 */
private void submitDiscoveryResults(String ip) {

	// uid must not contains dots
	ThingUID uid = new ThingUID(THING_TYPE_DEVICE, ip.replace('.', '_') ); 	
	
	if(uid!=null) { 
		Map<String, Object> properties = new HashMap<>(1); 
		properties.put(PARAMETER_HOSTNAME ,ip);
		DiscoveryResult result = DiscoveryResultBuilder.create(uid)
				.withProperties(properties)
				.withLabel("Network Device (" + ip +")").build();
		thingDiscovered(result); 
	}
	 
}
 
开发者ID:Neulinet,项目名称:Zoo,代码行数:21,代码来源:NetworkDiscoveryService.java


示例5: onDeviceAdded

import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder; //导入依赖的package包/类
@Override
public void onDeviceAdded(Bridge bridge, Device device) {
    logger.debug("Adding new TellstickDevice! {} with id '{}' to smarthome inbox", device.getDeviceType(),
            device.getId());
    ThingUID thingUID = getThingUID(bridge, device);
    if (thingUID != null) {
        DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withTTL(DEFAULT_TTL)
                .withProperty(TellstickBindingConstants.DEVICE_ID, device.getUUId())
                .withProperty(TellstickBindingConstants.DEVICE_NAME, device.getName()).withBridge(bridge.getUID())
                .withLabel(device.getDeviceType() + ": " + device.getName()).build();
        thingDiscovered(discoveryResult);

    } else {
        logger.warn("Discovered Tellstick! device is unsupported: type '{}' with id '{}'", device.getDeviceType(),
                device.getId());
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:18,代码来源:TellstickDiscoveryService.java


示例6: playerAdded

import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder; //导入依赖的package包/类
@Override
public void playerAdded(SqueezeBoxPlayer player) {
    ThingUID bridgeUID = squeezeBoxServerHandler.getThing().getUID();

    ThingUID thingUID = new ThingUID(SQUEEZEBOXPLAYER_THING_TYPE, bridgeUID,
            player.getMacAddress().replace(":", ""));

    if (!playerThingExists(thingUID)) {
        logger.debug("player added {} : {} ", player.getMacAddress(), player.getName());

        Map<String, Object> properties = new HashMap<>(1);
        properties.put("mac", player.getMacAddress());

        // Added other properties
        properties.put("modelId", player.getModel());
        properties.put("name", player.getName());
        properties.put("uid", player.getUuid());
        properties.put("ip", player.getIpAddr());

        DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withProperties(properties)
                .withBridge(bridgeUID).withLabel(player.getName()).build();

        thingDiscovered(discoveryResult);
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:26,代码来源:SqueezeBoxPlayerDiscoveryParticipant.java


示例7: onNestDeviceAdded

import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder; //导入依赖的package包/类
private void onNestDeviceAdded(BaseNestDevice device, ThingTypeUID typeUID) {
    ThingUID bridgeUID = bridge.getThing().getUID();
    ThingUID deviceUID = new ThingUID(typeUID, bridgeUID, device.getDeviceId());
    Map<String, Object> properties = new HashMap<>();
    properties.put(NestDeviceConfiguration.DEVICE_ID, device.getDeviceId());
    properties.put(PROPERTY_FIRMWARE_VERSION, device.getSoftwareVersion());
    // @formatter:off
    thingDiscovered(DiscoveryResultBuilder.create(deviceUID)
            .withThingType(typeUID)
            .withLabel(device.getNameLong())
            .withBridge(bridgeUID)
            .withProperties(properties)
            .withRepresentationProperty(NestDeviceConfiguration.DEVICE_ID)
            .build()
    );
    // @formatter:on
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:18,代码来源:NestDiscoveryService.java


示例8: onNewNestStructureData

import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder; //导入依赖的package包/类
@Override
public void onNewNestStructureData(Structure struct) {
    ThingUID bridgeUID = bridge.getThing().getUID();
    ThingUID thingUID = new ThingUID(THING_TYPE_STRUCTURE, bridgeUID, struct.getStructureId());
    Map<String, Object> properties = new HashMap<>();
    properties.put(NestStructureConfiguration.STRUCTURE_ID, struct.getStructureId());
    // @formatter:off
    thingDiscovered(DiscoveryResultBuilder.create(thingUID)
            .withThingType(THING_TYPE_STRUCTURE)
            .withLabel(struct.getName())
            .withBridge(bridgeUID)
            .withProperties(properties)
            .withRepresentationProperty(NestStructureConfiguration.STRUCTURE_ID)
            .build()
    );
    // @formatter:on
    logger.debug("thingDiscovered called for structure");
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:19,代码来源:NestDiscoveryService.java


示例9: extractGatewayInfos

import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder; //导入依赖的package包/类
/**
 * Extracts the CCU infos from the UDP response.
 */
private void extractGatewayInfos() throws IOException {
    try {
        DatagramPacket packet = new DatagramPacket(new byte[265], 256);
        socket.receive(packet);

        Eq3UdpResponse response = new Eq3UdpResponse(packet.getData());
        logger.trace("Eq3UdpResponse: {}", response);
        if (response.isValid()) {
            logger.debug("Discovered a CCU gateway with serial number '{}'", response.getSerialNumber());

            String address = packet.getAddress().getHostAddress();
            ThingUID thingUid = new ThingUID(THING_TYPE_BRIDGE, response.getSerialNumber());
            thingDiscovered(DiscoveryResultBuilder.create(thingUid).withProperty("gatewayAddress", address)
                    .withRepresentationProperty("gatewayAddress")
                    .withLabel(response.getDeviceTypeId() + " - " + address).build());
        }
    } catch (SocketTimeoutException ex) {
        // ignore
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:24,代码来源:CcuDiscoveryService.java


示例10: onItemUpdate

import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder; //导入依赖的package包/类
@Override
public void onItemUpdate(String sid, String command, JsonObject data) {
    if (command.equals("read_ack") || command.equals("report") || command.equals("heartbeat")) {
        String model = data.get("model").getAsString();

        ThingTypeUID thingType = getThingTypeForModel(model);
        if (thingType == null) {
            logger.debug("Unknown discovered model: {}", model);
            return;
        }

        Map<String, Object> properties = new HashMap<>(1);
        properties.put(ITEM_ID, sid);

        ThingUID thingUID = new ThingUID(thingType, sid);

        if (discoveryServiceCallback.getExistingThing(thingUID) == null) {
            logger.debug("Detected Xiaomi smart device - sid: {} model: {}", sid, model);
            thingDiscovered(
                    DiscoveryResultBuilder.create(thingUID).withThingType(thingType).withProperties(properties)
                            .withRepresentationProperty(ITEM_ID).withLabel(getLabelForModel(model))
                            .withBridge(xiaomiBridgeHandler.getThing().getUID()).build());
        }
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:26,代码来源:XiaomiItemDiscoveryService.java


示例11: discover

import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder; //导入依赖的package包/类
private synchronized void discover() {
    logger.debug("Try to discover a SMA Energy Meter device");

    EnergyMeter energyMeter = new EnergyMeter(EnergyMeter.DEFAULT_MCAST_GRP, EnergyMeter.DEFAULT_MCAST_PORT);
    try {
        energyMeter.update();
    } catch (IOException e) {
        logger.debug("No SMA Energy Meter found.");
        logger.debug("Diagnostic: ", e);
        return;
    }

    logger.debug("Adding a new SMA Engergy Meter with S/N '{}' to inbox", energyMeter.getSerialNumber());
    Map<String, Object> properties = new HashMap<>();
    properties.put(Thing.PROPERTY_VENDOR, "SMA");
    properties.put(Thing.PROPERTY_SERIAL_NUMBER, energyMeter.getSerialNumber());
    ThingUID uid = new ThingUID(THING_TYPE_ENERGY_METER, energyMeter.getSerialNumber());
    DiscoveryResult result = DiscoveryResultBuilder.create(uid)
            .withProperties(properties)
            .withLabel("SMA Energy Meter")
            .build();
    thingDiscovered(result);

    logger.debug("Thing discovered '{}'", result);
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:26,代码来源:SMAEnergyMeterDiscoveryService.java


示例12: addResult

import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder; //导入依赖的package包/类
/**
 * Helper method to add our ip address and system type as a discovery result.
 *
 * @param ipAddress a non-null, non-empty ip address
 * @param type a non-null, non-empty model type
 * @throws IllegalArgumentException if ipaddress or type is null or empty
 */
private void addResult(String ipAddress, String type) {
    if (StringUtils.isEmpty(ipAddress)) {
        throw new IllegalArgumentException("ipAddress cannot be null or empty");
    }
    if (StringUtils.isEmpty(type)) {
        throw new IllegalArgumentException("type cannot be null or empty");
    }

    final Map<String, Object> properties = new HashMap<>(3);
    properties.put(RioSystemConfig.IpAddress, ipAddress);
    properties.put(RioSystemConfig.Ping, 30);
    properties.put(RioSystemConfig.RetryPolling, 10);
    properties.put(RioSystemConfig.ScanDevice, true);

    final String id = ipAddress.replace(".", "");
    final ThingUID uid = new ThingUID(RioConstants.BRIDGE_TYPE_RIO, id);
    if (uid != null) {
        final DiscoveryResult result = DiscoveryResultBuilder.create(uid).withProperties(properties)
                .withLabel("Russound " + type).build();
        thingDiscovered(result);
    }

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


示例13: discoverControllers

import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder; //导入依赖的package包/类
/**
 * Helper method to discover controllers - this will iterate through all possible controllers (6 of them )and see if
 * any respond to the "type" command. If they do, we initiate a {@link #thingDiscovered(DiscoveryResult)} for the
 * controller and then scan the controller for zones via {@link #discoverZones(ThingUID, int)}
 */
private void discoverControllers() {
    for (int c = 1; c < 7; c++) {
        final String type = sendAndGet("GET C[" + c + "].type", RSP_CONTROLLERNOTIFICATION, 3);
        if (StringUtils.isNotEmpty(type)) {
            logger.debug("Controller #{} found - {}", c, type);

            final ThingUID thingUID = new ThingUID(RioConstants.BRIDGE_TYPE_CONTROLLER,
                    sysHandler.getThing().getUID(), String.valueOf(c));

            final DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID)
                    .withProperty(RioControllerConfig.Controller, c).withBridge(sysHandler.getThing().getUID())
                    .withLabel("Controller #" + c).build();
            thingDiscovered(discoveryResult);

            discoverZones(thingUID, c);
        }
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:24,代码来源:RioSystemDeviceDiscoveryService.java


示例14: discoverSources

import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder; //导入依赖的package包/类
/**
 * Helper method to discover sources. This will iterate through all possible sources (8 of them) and see if they
 * respond to the "type" command. If they do, we retrieve the source "name" and initial a
 * {@link #thingDiscovered(DiscoveryResult)} for the source.
 */
private void discoverSources() {
    for (int s = 1; s < 9; s++) {
        final String type = sendAndGet("GET S[" + s + "].type", RSP_SRCNOTIFICATION, 3);
        if (StringUtils.isNotEmpty(type)) {
            final String name = sendAndGet("GET S[" + s + "].name", RSP_SRCNOTIFICATION, 3);
            logger.debug("Source #{} - {}/{}", s, type, name);

            final ThingUID thingUID = new ThingUID(RioConstants.THING_TYPE_SOURCE, sysHandler.getThing().getUID(),
                    String.valueOf(s));

            final DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID)
                    .withProperty(RioSourceConfig.Source, s).withBridge(sysHandler.getThing().getUID())
                    .withLabel((StringUtils.isEmpty(name) || name.equalsIgnoreCase("null") ? "Source" : name) + " ("
                            + s + ")")
                    .build();
            thingDiscovered(discoveryResult);
        }
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:25,代码来源:RioSystemDeviceDiscoveryService.java


示例15: discoverZones

import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder; //导入依赖的package包/类
/**
 * Helper method to discover zones. This will iterate through all possible zones (8 of them) and see if they
 * respond to the "name" command. If they do, initial a {@link #thingDiscovered(DiscoveryResult)} for the zone.
 *
 * @param controllerUID the {@link ThingUID} of the parent controller
 * @param c the controller identifier
 * @throws IllegalArgumentException if controllerUID is null
 * @throws IllegalArgumentException if c is < 1 or > 8
 */
private void discoverZones(ThingUID controllerUID, int c) {
    if (controllerUID == null) {
        throw new IllegalArgumentException("controllerUID cannot be null");
    }
    if (c < 1 || c > 8) {
        throw new IllegalArgumentException("c must be between 1 and 8");
    }
    for (int z = 1; z < 9; z++) {
        final String name = sendAndGet("GET C[" + c + "].Z[" + z + "].name", RSP_ZONENOTIFICATION, 4);
        if (StringUtils.isNotEmpty(name)) {
            logger.debug("Controller #{}, Zone #{} found - {}", c, z, name);

            final ThingUID thingUID = new ThingUID(RioConstants.THING_TYPE_ZONE, controllerUID, String.valueOf(z));

            final DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID)
                    .withProperty(RioZoneConfig.Zone, z).withBridge(controllerUID)
                    .withLabel((name.equalsIgnoreCase("null") ? "Zone" : name) + " (" + z + ")").build();
            thingDiscovered(discoveryResult);
        }
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:31,代码来源:RioSystemDeviceDiscoveryService.java


示例16: deviceInformationUpdate

import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder; //导入依赖的package包/类
@Override
public void deviceInformationUpdate(List<DeviceInformation> deviceInformationList) {
    if (deviceInformationList != null) {
        for (DeviceInformation deviceInformationRecord : deviceInformationList) {

            String deviceTypeName = deviceInformationRecord.getDeviceDisplayName();
            String deviceOwnerName = deviceInformationRecord.getName();

            String thingLabel = deviceOwnerName + " (" + deviceTypeName + ")";
            String deviceId = deviceInformationRecord.getId();
            String deviceIdHash = Integer.toHexString(deviceId.hashCode());

            logger.debug("iCloud device discovery for [{}]", deviceInformationRecord.getDeviceDisplayName());

            ThingUID uid = new ThingUID(THING_TYPE_ICLOUDDEVICE, bridgeUID, deviceIdHash);
            DiscoveryResult result = DiscoveryResultBuilder.create(uid).withBridge(bridgeUID)
                    .withProperty(DEVICE_NAME, deviceOwnerName).withProperty(DEVICE_PROPERTY_ID, deviceId)
                    .withRepresentationProperty(DEVICE_PROPERTY_ID).withLabel(thingLabel).build();

            logger.debug("Device [{}, {}] found.", deviceIdHash, deviceId);

            thingDiscovered(result);

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


示例17: startScan

import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder; //导入依赖的package包/类
@Override
protected void startScan() {
    logger.debug("Starting system information discovery !");
    String hostname;

    try {
        hostname = getHostName();
        if (hostname.isEmpty()) {
            throw new UnknownHostException();
        }
        if (!hostname.matches("[" + THING_UID_VALID_CHARS + "]*")) {
            hostname = hostname.replaceAll("[^" + THING_UID_VALID_CHARS + "]", HOST_NAME_SEPERATOR);
        }
    } catch (UnknownHostException ex) {
        hostname = DEFAULT_THING_ID;
        logger.info("Hostname can not be resolved. Computer name will be set to the default one: {}",
                DEFAULT_THING_ID);
    }

    ThingTypeUID computerType = SysteminfoBindingConstants.THING_TYPE_COMPUTER;
    ThingUID computer = new ThingUID(computerType, hostname);
    thingDiscovered(DiscoveryResultBuilder.create(computer).withLabel(DEFAULT_THING_LABEL).build());
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:24,代码来源:SysteminfoDiscoveryService.java


示例18: createScanner

import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder; //导入依赖的package包/类
private Runnable createScanner() {
    return () -> {
        HDPowerViewWebTargets targets = hub.getWebTargets();
        Shades shades;
        try {
            shades = targets.getShades();
        } catch (IOException e) {
            logger.error("{}", e.getMessage(), e);
            stopScan();
            return;
        }
        if (shades != null) {
            for (Shade shade : shades.shadeData) {
                ThingUID thingUID = new ThingUID(HDPowerViewBindingConstants.THING_TYPE_SHADE, shade.id);
                DiscoveryResult result = DiscoveryResultBuilder.create(thingUID)
                        .withProperty(HDPowerViewShadeConfiguration.ID, shade.id).withLabel(shade.getName())
                        .withBridge(hub.getThing().getUID()).build();
                thingDiscovered(result);
            }
        }
        stopScan();
    };
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:24,代码来源:HDPowerViewShadeDiscoveryService.java


示例19: createScanner

import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder; //导入依赖的package包/类
private Runnable createScanner() {
    return () -> {
        try {
            NbtAddress address = NbtAddress.getByName(HDPowerViewBindingConstants.NETBIOS_NAME);
            if (address != null) {
                String host = address.getInetAddress().getHostAddress();
                ThingUID thingUID = new ThingUID(HDPowerViewBindingConstants.THING_TYPE_HUB,
                        host.replace('.', '_'));
                DiscoveryResult result = DiscoveryResultBuilder.create(thingUID)
                        .withProperty(HDPowerViewHubConfiguration.HOST, host)
                        .withLabel("PowerView Hub (" + host + ")").build();
                thingDiscovered(result);
            }
        } catch (UnknownHostException e) {
            // Nothing to do here - the host couldn't be found, likely because it doesn't exist
        }
    };
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:19,代码来源:HDPowerViewHubDiscoveryService.java


示例20: detectThing

import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder; //导入依赖的package包/类
/**
 * Detected a device (thing) and get process the data from the device and report it discovered.
 *
 * @param packet containing data of detected device
 * @throws IOException in case decrypting of the data failed
 */
private void detectThing(DatagramPacket packet) throws IOException {
    String ipAddress = packet.getAddress().getHostAddress();
    String rawData = CryptUtil.decrypt(packet.getData(), packet.getLength());
    Sysinfo sysinfo = commands.getSysinfoReponse(rawData);

    logger.trace("Detected TP-Link Smart Home device: {}", rawData);
    String deviceId = sysinfo.getDeviceId();
    logger.debug("TP-Link Smart Home device '{}' with id {} found on {} ", sysinfo.getAlias(), deviceId, ipAddress);
    Optional<ThingTypeUID> thingTypeUID = getThingTypeUID(sysinfo.getModel());

    if (thingTypeUID.isPresent()) {
        ThingUID thingUID = new ThingUID(thingTypeUID.get(),
                deviceId.substring(deviceId.length() - 6, deviceId.length()));
        DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withLabel(sysinfo.getAlias())
                .withProperties(PropertiesCollector.collectProperties(thingTypeUID.get(), ipAddress, sysinfo))
                .build();
        thingDiscovered(discoveryResult);
    } else {
        logger.debug("Detected, but ignoring unsupported TP-Link Smart Home device model '{}'", sysinfo.getModel());
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:28,代码来源:TPLinkSmartHomeDiscoveryService.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java JWTVerifyException类代码示例发布时间:2022-05-22
下一篇:
Java SingleCounterBlock类代码示例发布时间: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