Search in sources :

Example 36 with ThingUID

use of org.eclipse.smarthome.core.thing.ThingUID in project smarthome by eclipse.

the class ThingBuilderTest method testWithChannel_wrongThing.

@Test(expected = IllegalArgumentException.class)
public void testWithChannel_wrongThing() {
    ThingBuilder thingBuilder = ThingBuilder.create(THING_TYPE_UID, THING_UID);
    thingBuilder.withChannel(ChannelBuilder.create(new ChannelUID(new ThingUID(THING_TYPE_UID, "wrong"), "channel1"), "").build());
}
Also used : ThingBuilder(org.eclipse.smarthome.core.thing.binding.builder.ThingBuilder) ChannelUID(org.eclipse.smarthome.core.thing.ChannelUID) ThingUID(org.eclipse.smarthome.core.thing.ThingUID) Test(org.junit.Test)

Example 37 with ThingUID

use of org.eclipse.smarthome.core.thing.ThingUID in project smarthome by eclipse.

the class BridgeMDNSDiscoveryParticipant method createResult.

@Override
public DiscoveryResult createResult(ServiceInfo service) {
    if (service.getApplication().contains("dssweb")) {
        ThingUID uid = getThingUID(service);
        if (uid != null) {
            String hostAddress = service.getName() + "." + service.getDomain() + ".";
            Map<String, Object> properties = new HashMap<>(2);
            properties.put(DigitalSTROMBindingConstants.HOST, hostAddress);
            return DiscoveryResultBuilder.create(uid).withProperties(properties).withRepresentationProperty(uid.getId()).withLabel("digitalSTROM-Server").build();
        }
    }
    return null;
}
Also used : HashMap(java.util.HashMap) ThingUID(org.eclipse.smarthome.core.thing.ThingUID)

Example 38 with ThingUID

use of org.eclipse.smarthome.core.thing.ThingUID 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);
        }
    }
}
Also used : DiscoveryResult(org.eclipse.smarthome.config.discovery.DiscoveryResult) HashMap(java.util.HashMap) ThingUID(org.eclipse.smarthome.core.thing.ThingUID)

Example 39 with ThingUID

use of org.eclipse.smarthome.core.thing.ThingUID in project smarthome by eclipse.

the class LifxLightDiscovery method createDiscoveryResult.

private DiscoveryResult createDiscoveryResult(DiscoveredLight light) throws IllegalArgumentException {
    Products product = light.product;
    if (product == null) {
        throw new IllegalArgumentException("Product of discovered light is null");
    }
    String macAsLabel = light.macAddress.getAsLabel();
    ThingUID thingUID = new ThingUID(product.getThingTypeUID(), macAsLabel);
    String label = light.label;
    if (StringUtils.isBlank(label)) {
        label = product.getName();
    }
    logger.trace("Discovered a LIFX light: {}", label);
    DiscoveryResultBuilder builder = DiscoveryResultBuilder.create(thingUID);
    builder.withRepresentationProperty(LifxBindingConstants.PROPERTY_MAC_ADDRESS);
    builder.withLabel(label);
    builder.withProperty(LifxBindingConstants.CONFIG_PROPERTY_DEVICE_ID, macAsLabel);
    builder.withProperty(LifxBindingConstants.PROPERTY_MAC_ADDRESS, macAsLabel);
    builder.withProperty(LifxBindingConstants.PROPERTY_PRODUCT_ID, product.getProduct());
    builder.withProperty(LifxBindingConstants.PROPERTY_PRODUCT_NAME, product.getName());
    builder.withProperty(LifxBindingConstants.PROPERTY_PRODUCT_VERSION, light.productVersion);
    builder.withProperty(LifxBindingConstants.PROPERTY_VENDOR_ID, product.getVendor());
    builder.withProperty(LifxBindingConstants.PROPERTY_VENDOR_NAME, product.getVendorName());
    return builder.build();
}
Also used : Products(org.eclipse.smarthome.binding.lifx.internal.protocol.Products) DiscoveryResultBuilder(org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder) ThingUID(org.eclipse.smarthome.core.thing.ThingUID)

Example 40 with ThingUID

use of org.eclipse.smarthome.core.thing.ThingUID 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);
}
Also used : DiscoveryResult(org.eclipse.smarthome.config.discovery.DiscoveryResult) HashMap(java.util.HashMap) ThingUID(org.eclipse.smarthome.core.thing.ThingUID)

Aggregations

ThingUID (org.eclipse.smarthome.core.thing.ThingUID)99 DiscoveryResult (org.eclipse.smarthome.config.discovery.DiscoveryResult)29 ThingTypeUID (org.eclipse.smarthome.core.thing.ThingTypeUID)27 Thing (org.eclipse.smarthome.core.thing.Thing)26 Test (org.junit.Test)25 HashMap (java.util.HashMap)21 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)14 ApiOperation (io.swagger.annotations.ApiOperation)10 ApiResponses (io.swagger.annotations.ApiResponses)10 Path (javax.ws.rs.Path)9 JsonObject (com.google.gson.JsonObject)8 JsonParser (com.google.gson.JsonParser)7 RolesAllowed (javax.annotation.security.RolesAllowed)7 Locale (java.util.Locale)6 Nullable (org.eclipse.jdt.annotation.Nullable)6 Consumes (javax.ws.rs.Consumes)5 Configuration (org.eclipse.smarthome.config.core.Configuration)5 Collection (java.util.Collection)4 GET (javax.ws.rs.GET)4 InboxPredicates.forThingUID (org.eclipse.smarthome.config.discovery.inbox.InboxPredicates.forThingUID)4