/** * Maps discovery result data transfer object into discovery result. * * @param discoveryResultDTO the discovery result data transfer object * @return the discovery result */ public static DiscoveryResult map(DiscoveryResultDTO discoveryResultDTO) { final ThingUID thingUID = new ThingUID(discoveryResultDTO.thingUID); final String dtoThingTypeUID = discoveryResultDTO.thingTypeUID; final ThingTypeUID thingTypeUID = dtoThingTypeUID != null ? new ThingTypeUID(dtoThingTypeUID) : null; final String dtoBridgeUID = discoveryResultDTO.bridgeUID; final ThingUID bridgeUID = dtoBridgeUID != null ? new ThingUID(dtoBridgeUID) : null; return DiscoveryResultBuilder.create(thingUID).withThingType(thingTypeUID).withBridge(bridgeUID) .withLabel(discoveryResultDTO.label) .withRepresentationProperty(discoveryResultDTO.representationProperty) .withProperties(discoveryResultDTO.properties).build(); } }
/** * Creates a new builder for a given thing UID. * * @param thingUID the thing UID for which the builder should be created- * * @return a new instance of a {@link DiscoveryResultBuilder} */ public static DiscoveryResultBuilder create(ThingUID thingUID) { return new DiscoveryResultBuilder(thingUID); }
@Override protected void startScan() { String serialNumber = createRandomSerialNumber(); DiscoveryResult discoveryResult = DiscoveryResultBuilder .create(new ThingUID(MagicBindingConstants.THING_TYPE_CONFIG_THING, serialNumber)) .withRepresentationProperty(Thing.PROPERTY_SERIAL_NUMBER) .withProperty(Thing.PROPERTY_SERIAL_NUMBER, serialNumber).withLabel("Magic Thing").build(); thingDiscovered(discoveryResult); }
private DiscoveryResult createDiscoveryResultWithUsbProperties(DiscoveryResult result, UsbSerialDeviceInformation usbSerialDeviceInformation) { Map<String, Object> resultProperties = new HashMap<>(result.getProperties()); resultProperties.put(THING_PROPERTY_USB_VENDOR_ID, usbSerialDeviceInformation.getVendorId()); resultProperties.put(THING_PROPERTY_USB_PRODUCT_ID, usbSerialDeviceInformation.getProductId()); return DiscoveryResultBuilder.create(result.getThingUID()).withProperties(resultProperties) .withBridge(result.getBridgeUID()).withTTL(result.getTimeToLive()).withLabel(result.getLabel()) .withRepresentationProperty(result.getRepresentationProperty()).build(); } }
private void discover(DiscoveredAdapter adapter) { thingDiscovered(DiscoveryResultBuilder .create(BluetoothUtils.getAdapterUID(adapter.getURL())) .withLabel(adapter.getAlias() != null ? adapter.getAlias() : adapter.getName()) .withRepresentationProperty(adapter.getURL().getAdapterAddress()) .withTTL(DISCOVERY_RATE_SEC * 3).build()); }
/** * Maps discovery result data transfer object into discovery result. * * @param discoveryResultDTO the discovery result data transfer object * @return the discovery result */ public static DiscoveryResult map(DiscoveryResultDTO discoveryResultDTO) { final ThingUID thingUID = new ThingUID(discoveryResultDTO.thingUID); final String dtoThingTypeUID = discoveryResultDTO.thingTypeUID; final ThingTypeUID thingTypeUID = dtoThingTypeUID != null ? new ThingTypeUID(dtoThingTypeUID) : null; final String dtoBridgeUID = discoveryResultDTO.bridgeUID; final ThingUID bridgeUID = dtoBridgeUID != null ? new ThingUID(dtoBridgeUID) : null; return DiscoveryResultBuilder.create(thingUID).withThingType(thingTypeUID).withBridge(bridgeUID) .withLabel(discoveryResultDTO.label) .withRepresentationProperty(discoveryResultDTO.representationProperty) .withProperties(discoveryResultDTO.properties).build(); } }
private void discover(DiscoveredDevice device) { ThingUID bridgeUID = device.isCombined() ? null : BluetoothUtils.getAdapterUID(device.getURL()); ThingUID thingUID = BluetoothUtils.getDeviceUID(device); DiscoveryResultBuilder builder = DiscoveryResultBuilder .create(thingUID) .withLabel((device.getAlias() != null ? device.getAlias() : device.getName())) .withTTL(DISCOVERY_RATE_SEC * 3) .withRepresentationProperty(device.getURL().getDeviceAddress()) .withBridge(bridgeUID); thingDiscovered(builder.build()); }
/** * Creates a new builder for a given thing UID. * * @param thingUID the thing UID for which the builder should be created- * @return a new instance of a {@link DiscoveryResultBuilder} */ public static DiscoveryResultBuilder create(ThingUID thingUID) { return new DiscoveryResultBuilder(thingUID); }
@Override public DiscoveryResult createResult(ThingUID bridgeUID, ZigBeeNode node, Map<String, Object> properties) { ThingTypeUID thingTypeUID = matcher.matchThingType(properties); if (thingTypeUID == null) { return null; } ThingUID thingUID = new ThingUID(thingTypeUID, bridgeUID, node.getIeeeAddress().toString().toLowerCase().replaceAll("[^a-z0-9_/]", "")); String label; // If we know the manufacturer and model, then give this device a name if ((properties.get(Thing.PROPERTY_VENDOR) != null) && (properties.get(Thing.PROPERTY_MODEL_ID) != null)) { label = properties.get(Thing.PROPERTY_VENDOR) + " " + properties.get(Thing.PROPERTY_MODEL_ID); } else { label = "Unknown ZigBee Device"; } return DiscoveryResultBuilder.create(thingUID).withThingType(thingTypeUID).withProperties(properties) .withBridge(bridgeUID).withLabel(label).build(); } }
properties.put(ZWaveBindingConstants.CONFIGURATION_NODEID, new BigDecimal(nodeId)); DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withBridge(bridgeUID) .withProperties(properties).withLabel(String.format(ZWAVE_NODE_LABEL, nodeId)).build();
objProperties.put(ZigBeeBindingConstants.CONFIGURATION_MACADDRESS, node.getIeeeAddress().toString()); DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(defaultThingUID) .withThingType(defaultThingTypeUID).withProperties(objProperties).withBridge(bridgeUID) .withLabel(label).build(); defaultThingTypeUID, bridgeUID, label); DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(defaultThingUID) .withThingType(defaultThingTypeUID).withProperties(objProperties).withBridge(bridgeUID) .withLabel(label).build();
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withThingType(thingTypeUID) .withProperties(properties).withBridge(bridgeUID).withLabel(label).build(); thingDiscovered(discoveryResult);