本文整理汇总了Java中org.eclipse.smarthome.config.discovery.DiscoveryResult类的典型用法代码示例。如果您正苦于以下问题:Java DiscoveryResult类的具体用法?Java DiscoveryResult怎么用?Java DiscoveryResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DiscoveryResult类属于org.eclipse.smarthome.config.discovery包,在下文中一共展示了DiscoveryResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例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());
}
}
示例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);
}
}
示例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());
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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();
};
}
示例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
}
};
}
示例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));
}