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

Java DiscoveryResult类代码示例

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

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



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

示例1: createResult

import org.eclipse.smarthome.config.discovery.DiscoveryResult; //导入依赖的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.DiscoveryResult; //导入依赖的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.DiscoveryResult; //导入依赖的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.DiscoveryResult; //导入依赖的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.DiscoveryResult; //导入依赖的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.DiscoveryResult; //导入依赖的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: discover

import org.eclipse.smarthome.config.discovery.DiscoveryResult; //导入依赖的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


示例8: addResult

import org.eclipse.smarthome.config.discovery.DiscoveryResult; //导入依赖的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


示例9: discoverControllers

import org.eclipse.smarthome.config.discovery.DiscoveryResult; //导入依赖的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


示例10: discoverSources

import org.eclipse.smarthome.config.discovery.DiscoveryResult; //导入依赖的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


示例11: discoverZones

import org.eclipse.smarthome.config.discovery.DiscoveryResult; //导入依赖的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


示例12: deviceInformationUpdate

import org.eclipse.smarthome.config.discovery.DiscoveryResult; //导入依赖的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


示例13: createScanner

import org.eclipse.smarthome.config.discovery.DiscoveryResult; //导入依赖的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


示例14: createScanner

import org.eclipse.smarthome.config.discovery.DiscoveryResult; //导入依赖的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


示例15: pingDeviceDetected

import org.eclipse.smarthome.config.discovery.DiscoveryResult; //导入依赖的package包/类
@Test
public void pingDeviceDetected() {
    NetworkDiscoveryService d = new NetworkDiscoveryService();
    d.addDiscoveryListener(listener);

    ArgumentCaptor<DiscoveryResult> result = ArgumentCaptor.forClass(DiscoveryResult.class);

    // Ping device
    when(value.isPingReachable()).thenReturn(true);
    when(value.isTCPServiceReachable()).thenReturn(false);
    d.partialDetectionResult(value);
    verify(listener).thingDiscovered(anyObject(), result.capture());
    DiscoveryResult dresult = result.getValue();
    Assert.assertThat(dresult.getThingUID(), is(NetworkDiscoveryService.createPingUID(ip)));
    Assert.assertThat(dresult.getProperties().get(NetworkBindingConstants.PARAMETER_HOSTNAME), is(ip));
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:17,代码来源:DiscoveryTest.java


示例16: tcpDeviceDetected

import org.eclipse.smarthome.config.discovery.DiscoveryResult; //导入依赖的package包/类
@Test
public void tcpDeviceDetected() {
    NetworkDiscoveryService d = new NetworkDiscoveryService();
    d.addDiscoveryListener(listener);

    ArgumentCaptor<DiscoveryResult> result = ArgumentCaptor.forClass(DiscoveryResult.class);

    // TCP device
    when(value.isPingReachable()).thenReturn(false);
    when(value.isTCPServiceReachable()).thenReturn(true);
    when(value.getReachableTCPports()).thenReturn(Collections.singletonList(1010));
    d.partialDetectionResult(value);
    verify(listener).thingDiscovered(anyObject(), result.capture());
    DiscoveryResult dresult = result.getValue();
    Assert.assertThat(dresult.getThingUID(), is(NetworkDiscoveryService.createServiceUID(ip, 1010)));
    Assert.assertThat(dresult.getProperties().get(NetworkBindingConstants.PARAMETER_HOSTNAME), is(ip));
    Assert.assertThat(dresult.getProperties().get(NetworkBindingConstants.PARAMETER_PORT), is(1010));
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:19,代码来源:DiscoveryTest.java


示例17: detectThing

import org.eclipse.smarthome.config.discovery.DiscoveryResult; //导入依赖的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


示例18: createResult

import org.eclipse.smarthome.config.discovery.DiscoveryResult; //导入依赖的package包/类
/**
 * Create a discovery result from UPNP discovery
 */
@Override
public DiscoveryResult createResult(RemoteDevice device) {
    ThingUID uid = getThingUID(device);
    if (uid != null) {
        logger.debug("discovered: {} at {}", device.getDisplayString(),
                device.getIdentity().getDescriptorURL().getHost());
        Map<String, Object> properties = new HashMap<>();
        properties.put(CONFIG_IP_ADDRESS, device.getIdentity().getDescriptorURL().getHost());
        DiscoveryResult result = DiscoveryResultBuilder.create(uid).withProperties(properties)
                .withLabel(device.getDetails().getFriendlyName()).withRepresentationProperty(CONFIG_IP_ADDRESS)
                .withTTL(Math.max(MIN_MAX_AGE_SECS, device.getIdentity().getMaxAgeSeconds())).build();
        return result;
    }
    return null;
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:19,代码来源:AVMFritzUpnpDiscoveryParticipant.java


示例19: onDeviceAddedInternal

import org.eclipse.smarthome.config.discovery.DiscoveryResult; //导入依赖的package包/类
/**
 * Add one discovered AHA device to inbox.
 *
 * @param device Device model received from a FRITZ!Box
 */
public void onDeviceAddedInternal(DeviceModel device) {
    ThingTypeUID thingTypeUID = new ThingTypeUID(BINDING_ID,
            device.getProductName().replaceAll("[^a-zA-Z0-9_]", "_"));

    if (SUPPORTED_DEVICE_THING_TYPES_UIDS.contains(thingTypeUID)) {
        ThingUID bridgeUID = bridgeHandler.getThing().getUID();
        ThingUID thingUID = new ThingUID(thingTypeUID, bridgeUID,
                device.getIdentifier().replaceAll("[^a-zA-Z0-9_]", "_"));

        Map<String, Object> properties = new HashMap<>();
        properties.put(THING_AIN, device.getIdentifier());
        properties.put(PROPERTY_VENDOR, device.getManufacturer());
        properties.put(PROPERTY_MODEL_ID, device.getDeviceId());
        properties.put(PROPERTY_SERIAL_NUMBER, device.getIdentifier());
        properties.put(PROPERTY_FIRMWARE_VERSION, device.getFirmwareVersion());

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

        thingDiscovered(discoveryResult);
    } else {
        logger.debug("discovered unsupported device: {}", device);
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:30,代码来源:AVMFritzDiscoveryService.java


示例20: createResult

import org.eclipse.smarthome.config.discovery.DiscoveryResult; //导入依赖的package包/类
@Override
public DiscoveryResult createResult(ServiceInfo service) {
    if (service.getName().equals("wc-minecraft")) {
        ThingUID uid = getThingUID(service);

        if (uid != null) {
            Map<String, Object> properties = new HashMap<>();
            int port = service.getPort();
            String host = service.getInetAddresses()[0].getHostAddress();

            properties.put(MinecraftBindingConstants.PARAMETER_HOSTNAME, host);
            properties.put(MinecraftBindingConstants.PARAMETER_PORT, port);

            return DiscoveryResultBuilder.create(uid).withProperties(properties)
                    .withRepresentationProperty(uid.getId()).withLabel("Minecraft Server (" + host + ")").build();
        }
    }
    return null;
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:20,代码来源:MinecraftMDNSDiscoveryParticipant.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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