use of org.eclipse.smarthome.config.discovery.DiscoveryResult in project smarthome by eclipse.
the class FSInternetRadioDiscoveryParticipantJavaTest method validDiscoveryResultIfWithoutBaseUrl.
/**
* Verify valid DiscoveryResult with FSInterntRadio device without base URL.
*
* @throws ValidationException
*/
@SuppressWarnings("null")
@Test
public void validDiscoveryResultIfWithoutBaseUrl() throws ValidationException {
RemoteDevice fsInternetRadioDeviceWithoutUrl = createDefaultFSInternetRadioDevice(null);
final DiscoveryResult result = discoveryParticipant.createResult(fsInternetRadioDeviceWithoutUrl);
assertEquals(new ThingUID(DEFAULT_RADIO_THING_UID), result.getThingUID());
assertEquals(FSInternetRadioBindingConstants.THING_TYPE_RADIO, result.getThingTypeUID());
assertEquals(DEFAULT_RADIO_MANIFACTURER, result.getProperties().get(FSInternetRadioBindingConstants.PROPERTY_MANUFACTURER));
assertEquals(DEFAULT_RADIO_MODEL_NUMBER, result.getProperties().get(FSInternetRadioBindingConstants.PROPERTY_MODEL));
}
use of org.eclipse.smarthome.config.discovery.DiscoveryResult in project smarthome by eclipse.
the class HueBridgeNupnpDiscovery method discoverHueBridges.
/**
* Discover available Hue Bridges and then add them in the discovery inbox
*/
private void discoverHueBridges() {
for (BridgeJsonParameters bridge : getBridgeList()) {
if (isReachableAndValidHueBridge(bridge)) {
String host = bridge.getInternalIpAddress();
String serialNumber = bridge.getId().substring(0, 6) + bridge.getId().substring(10);
ThingUID uid = new ThingUID(THING_TYPE_BRIDGE, serialNumber);
DiscoveryResult result = DiscoveryResultBuilder.create(uid).withProperties(buildProperties(host, serialNumber)).withLabel(LABEL_PATTERN.replace("IP", host)).withRepresentationProperty(SERIAL_NUMBER).build();
thingDiscovered(result);
}
}
}
use of org.eclipse.smarthome.config.discovery.DiscoveryResult in project smarthome by eclipse.
the class MagicDiscoveryService method startScan.
@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);
}
use of org.eclipse.smarthome.config.discovery.DiscoveryResult in project smarthome by eclipse.
the class DeviceDiscoveryService method onDeviceAddedInternal.
private void onDeviceAddedInternal(GeneralDeviceInformation device) {
boolean isSupported = false;
if (device instanceof Device) {
Device tempDevice = (Device) device;
if ((tempDevice.isSensorDevice() && deviceType.equals(tempDevice.getHWinfo().replaceAll("-", ""))) || (deviceType.equals(tempDevice.getHWinfo().substring(0, 2)) && (tempDevice.isDeviceWithOutput() || tempDevice.isBinaryInputDevice()) && tempDevice.isPresent())) {
isSupported = true;
}
} else if (device instanceof Circuit && DsDeviceThingTypeProvider.SupportedThingTypes.circuit.toString().equals(deviceType)) {
isSupported = true;
}
if (isSupported) {
ThingUID thingUID = getThingUID(device);
if (thingUID != null) {
Map<String, Object> properties = new HashMap<>(1);
properties.put(DigitalSTROMBindingConstants.DEVICE_DSID, device.getDSID().getValue());
String deviceName = null;
if (StringUtils.isNotBlank(device.getName())) {
deviceName = device.getName();
} else {
// if no name is set, the dSID will be used as name
deviceName = device.getDSID().getValue();
}
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withProperties(properties).withBridge(bridgeUID).withLabel(deviceName).build();
thingDiscovered(discoveryResult);
} else {
if (device instanceof Device) {
logger.debug("Discovered unsupported device hardware type '{}' with uid {}", ((Device) device).getHWinfo(), device.getDSUID());
}
}
} else {
if (device instanceof Device) {
logger.debug("Discovered device with disabled or no output mode. Device was not added to inbox. " + "Device information: hardware info: {}, dSUID: {}, device-name: {}, output value: {}", ((Device) device).getHWinfo(), device.getDSUID(), device.getName(), ((Device) device).getOutputMode());
}
}
}
use of org.eclipse.smarthome.config.discovery.DiscoveryResult in project smarthome by eclipse.
the class SceneDiscoveryService method onSceneAddedInternal.
private void onSceneAddedInternal(InternalScene scene) {
logger.debug("{}", scene.getSceneType());
if (scene != null && scene.getSceneType().equals(sceneType)) {
if (!ignoredScene(scene.getSceneID()) && !ignoreGroup(scene.getGroupID())) {
ThingUID thingUID = getThingUID(scene);
if (thingUID != null) {
ThingUID bridgeUID = bridgeHandler.getThing().getUID();
Map<String, Object> properties = new HashMap<>();
properties.put(ZONE_ID, scene.getZoneID());
properties.put(GROUP_ID, scene.getGroupID());
if (SceneEnum.containsScene(scene.getSceneID())) {
properties.put(SCENE_ID, SceneEnum.getScene(scene.getSceneID()).toString());
} else {
logger.debug("discovered scene: name '{}' with id {} have an invalid scene-ID", scene.getSceneName(), scene.getID());
}
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withProperties(properties).withBridge(bridgeUID).withLabel(scene.getSceneName()).build();
thingDiscovered(discoveryResult);
} else {
logger.debug("discovered unsupported scene: name '{}' with id {}", scene.getSceneName(), scene.getID());
}
}
}
}
Aggregations