use of org.eclipse.smarthome.core.thing.ThingUID in project smarthome by eclipse.
the class TradfriDiscoveryServiceTest method setUp.
@Before
public void setUp() {
initMocks(this);
when(handler.getThing()).thenReturn(BridgeBuilder.create(GATEWAY_TYPE_UID, "1").build());
discovery = new TradfriDiscoveryService(handler);
listener = new DiscoveryListener() {
@Override
public void thingRemoved(DiscoveryService source, ThingUID thingUID) {
}
@Override
public void thingDiscovered(DiscoveryService source, DiscoveryResult result) {
discoveryResult = result;
}
@Override
public Collection<ThingUID> removeOlderResults(DiscoveryService source, long timestamp, Collection<ThingTypeUID> thingTypeUIDs, ThingUID bridgeUID) {
return null;
}
};
discovery.addDiscoveryListener(listener);
}
use of org.eclipse.smarthome.core.thing.ThingUID in project smarthome by eclipse.
the class TradfriDiscoveryServiceTest method validDiscoveryResultWhiteLightW.
@Test
public void validDiscoveryResultWhiteLightW() {
String json = "{\"9001\":\"TRADFRI bulb E27 W opal 1000lm\",\"9002\":1492856270,\"9020\":1507194357,\"9003\":65537,\"3311\":[{\"5850\":1,\"5851\":254,\"9003\":0}],\"9054\":0,\"5750\":2,\"9019\":1,\"3\":{\"0\":\"IKEA of Sweden\",\"1\":\"TRADFRI bulb E27 W opal 1000lm\",\"2\":\"\",\"3\":\"1.2.214\",\"6\":1}}";
JsonObject data = new JsonParser().parse(json).getAsJsonObject();
discovery.onUpdate("65537", data);
assertNotNull(discoveryResult);
assertThat(discoveryResult.getFlag(), is(DiscoveryResultFlag.NEW));
assertThat(discoveryResult.getThingUID(), is(new ThingUID("tradfri:0100:1:65537")));
assertThat(discoveryResult.getThingTypeUID(), is(THING_TYPE_DIMMABLE_LIGHT));
assertThat(discoveryResult.getBridgeUID(), is(GATEWAY_THING_UID));
assertThat(discoveryResult.getProperties().get(CONFIG_ID), is(65537));
assertThat(discoveryResult.getRepresentationProperty(), is(CONFIG_ID));
}
use of org.eclipse.smarthome.core.thing.ThingUID in project smarthome by eclipse.
the class TradfriDiscoveryServiceTest method validDiscoveryResultRemoteControl.
@Test
public void validDiscoveryResultRemoteControl() {
String json = "{\"9001\":\"TRADFRI remote control\",\"9002\":1492843083,\"9020\":1506977986,\"9003\":65536,\"9054\":0,\"5750\":0,\"9019\":1,\"3\":{\"0\":\"IKEA of Sweden\",\"1\":\"TRADFRI remote control\",\"2\":\"\",\"3\":\"1.2.214\",\"6\":3,\"9\":47},\"15009\":[{\"9003\":0}]}";
JsonObject data = new JsonParser().parse(json).getAsJsonObject();
discovery.onUpdate("65536", data);
assertNotNull(discoveryResult);
assertThat(discoveryResult.getFlag(), is(DiscoveryResultFlag.NEW));
assertThat(discoveryResult.getThingUID(), is(new ThingUID("tradfri:0830:1:65536")));
assertThat(discoveryResult.getThingTypeUID(), is(THING_TYPE_REMOTE_CONTROL));
assertThat(discoveryResult.getBridgeUID(), is(GATEWAY_THING_UID));
assertThat(discoveryResult.getProperties().get(CONFIG_ID), is(65536));
assertThat(discoveryResult.getRepresentationProperty(), is(CONFIG_ID));
}
use of org.eclipse.smarthome.core.thing.ThingUID in project smarthome by eclipse.
the class NtpOSGiTest method initialize.
private void initialize(Configuration configuration, String channelID, String acceptedItemType, Configuration channelConfiguration) {
configuration.put(NtpBindingConstants.PROPERTY_NTP_SERVER_PORT, TEST_PORT);
ThingUID ntpUid = new ThingUID(NtpBindingConstants.THING_TYPE_NTP, TEST_THING_ID);
ChannelUID channelUID = new ChannelUID(ntpUid, channelID);
Channel channel = ChannelBuilder.create(channelUID, acceptedItemType).withType(channelTypeUID).withConfiguration(channelConfiguration).withLabel("label").withKind(ChannelKind.STATE).build();
ntpThing = ThingBuilder.create(NtpBindingConstants.THING_TYPE_NTP, ntpUid).withConfiguration(configuration).withChannel(channel).build();
managedThingProvider.add(ntpThing);
// Wait for the NTP thing to be added to the ManagedThingProvider.
ntpHandler = waitForAssert(() -> {
final ThingHandler thingHandler = ntpThing.getHandler();
assertThat(thingHandler, is(instanceOf(NtpHandler.class)));
return (NtpHandler) thingHandler;
}, DFL_TIMEOUT * 3, DFL_SLEEP_TIME);
if (acceptedItemType.equals(ACCEPTED_ITEM_TYPE_STRING)) {
testItem = new StringItem(TEST_ITEM_NAME);
} else if (acceptedItemType.equals(ACCEPTED_ITEM_TYPE_DATE_TIME)) {
testItem = new DateTimeItem(TEST_ITEM_NAME);
}
itemRegistry.add(testItem);
// Wait for the item , linked to the NTP thing to be added to the
// ManagedThingProvider.
final ManagedItemChannelLinkProvider itemChannelLinkProvider = waitForAssert(() -> {
final ManagedItemChannelLinkProvider tmp = getService(ManagedItemChannelLinkProvider.class);
assertNotNull(tmp);
return tmp;
});
itemChannelLinkProvider.add(new ItemChannelLink(TEST_ITEM_NAME, channelUID));
}
use of org.eclipse.smarthome.core.thing.ThingUID in project smarthome by eclipse.
the class PersistentInbox method removeResultsForBridge.
private void removeResultsForBridge(ThingUID bridgeUID) {
for (ThingUID thingUID : getResultsForBridge(bridgeUID)) {
DiscoveryResult discoveryResult = get(thingUID);
if (discoveryResult != null) {
this.discoveryResultStorage.remove(thingUID.toString());
notifyListeners(discoveryResult, EventType.removed);
}
}
}
Aggregations