use of org.eclipse.smarthome.config.discovery.DiscoveryResult in project smarthome by eclipse.
the class ZoneTemperatureControlDiscoveryService method internalConfigChanged.
private void internalConfigChanged(TemperatureControlStatus tempControlStatus) {
if (tempControlStatus == null) {
return;
}
if (tempControlStatus.getIsConfigured()) {
logger.debug("found configured zone TemperatureControlStatus = {}", tempControlStatus);
ThingUID thingUID = getThingUID(tempControlStatus);
if (thingUID != null) {
Map<String, Object> properties = new HashMap<>();
properties.put(DigitalSTROMBindingConstants.ZONE_ID, tempControlStatus.getZoneID());
String zoneName = tempControlStatus.getZoneName();
if (StringUtils.isBlank(zoneName)) {
zoneName = tempControlStatus.getZoneID().toString();
}
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withProperties(properties).withBridge(bridgeUID).withLabel(zoneName).build();
thingDiscovered(discoveryResult);
}
}
}
use of org.eclipse.smarthome.config.discovery.DiscoveryResult in project smarthome by eclipse.
the class NtpDiscovery method discoverNtp.
/**
* Add a ntp Thing for the local time in the discovery inbox
*/
private void discoverNtp() {
Map<String, Object> properties = new HashMap<>(4);
properties.put(PROPERTY_TIMEZONE, TimeZone.getDefault().getID());
ThingUID uid = new ThingUID(THING_TYPE_NTP, "local");
DiscoveryResult result = DiscoveryResultBuilder.create(uid).withProperties(properties).withLabel("Local Time").build();
thingDiscovered(result);
}
use of org.eclipse.smarthome.config.discovery.DiscoveryResult in project smarthome by eclipse.
the class LIRCRemoteDiscoveryService method addRemote.
private void addRemote(ThingUID bridge, String remote) {
ThingTypeUID uid = LIRCBindingConstants.THING_TYPE_REMOTE;
ThingUID thingUID = new ThingUID(uid, bridge, remote);
if (thingUID != null) {
if (discoveryServiceCallback != null && discoveryServiceCallback.getExistingDiscoveryResult(thingUID) != null) {
// Ignore this remote as we already know about it
logger.debug("Remote {}: Already known.", remote);
return;
}
logger.trace("Remote {}: Discovered new remote.", remote);
Map<String, Object> properties = new HashMap<>(1);
properties.put(LIRCBindingConstants.PROPERTY_REMOTE, remote);
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withLabel(remote).withBridge(bridge).withProperties(properties).build();
thingDiscovered(discoveryResult);
}
}
use of org.eclipse.smarthome.config.discovery.DiscoveryResult in project smarthome by eclipse.
the class AutomaticInboxProcessorTest method testThingWentOnline.
@Test
public void testThingWentOnline() {
inbox.add(DiscoveryResultBuilder.create(THING_UID).withProperty(DEVICE_ID_KEY, DEVICE_ID).withRepresentationProperty(DEVICE_ID_KEY).build());
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).collect(Collectors.toList());
assertThat(results.size(), is(1));
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
when(thingRegistry.get(THING_UID)).thenReturn(thing);
when(thingStatusInfoChangedEvent.getStatusInfo()).thenReturn(new ThingStatusInfo(ThingStatus.ONLINE, ThingStatusDetail.NONE, null));
when(thingStatusInfoChangedEvent.getThingUID()).thenReturn(THING_UID);
inboxAutoIgnore.receive(thingStatusInfoChangedEvent);
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).collect(Collectors.toList());
assertThat(results.size(), is(0));
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).collect(Collectors.toList());
assertThat(results.size(), is(1));
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
}
use of org.eclipse.smarthome.config.discovery.DiscoveryResult in project smarthome by eclipse.
the class AutomaticInboxProcessorTest method testThingWithOtherBindingIDButSameRepresentationPropertyWentOnline.
/**
* This test is just like the test testThingWentOnline in the AutomaticInboxProcessorTest, but in contrast to the
* above test (where a thing with the same binding ID and the same representation property value went online) here a
* thing with another binding ID and the same representation property value goes online.
* <p/>
* In this case, the discovery result should not be ignored, since it has a different thing type.
*/
@Test
public void testThingWithOtherBindingIDButSameRepresentationPropertyWentOnline() {
// Add discovery result with thing type THING_TYPE_UID and representation property value DEVICE_ID
inbox.add(DiscoveryResultBuilder.create(THING_UID).withProperty(DEVICE_ID_KEY, DEVICE_ID).withRepresentationProperty(DEVICE_ID_KEY).build());
// Then there is a discovery result which is NEW
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).collect(Collectors.toList());
assertThat(results.size(), is(1));
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
// Now a thing with thing type THING_TYPE_UID3 goes online, with representation property value being also the
// device id
when(thingRegistry.get(THING_UID3)).thenReturn(thing3);
when(thingStatusInfoChangedEvent.getStatusInfo()).thenReturn(new ThingStatusInfo(ThingStatus.ONLINE, ThingStatusDetail.NONE, null));
when(thingStatusInfoChangedEvent.getThingUID()).thenReturn(THING_UID3);
inboxAutoIgnore.receive(thingStatusInfoChangedEvent);
// Then there should still be the NEW discovery result, but no IGNORED discovery result
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).collect(Collectors.toList());
assertThat(results.size(), is(1));
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).collect(Collectors.toList());
assertThat(results.size(), is(0));
}
Aggregations