Search in sources :

Example 41 with ThingTypeUID

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

the class LIRCHandlerFactory method createHandler.

@Override
protected ThingHandler createHandler(Thing thing) {
    ThingTypeUID thingTypeUID = thing.getThingTypeUID();
    if (LIRCBindingConstants.SUPPORTED_BRIDGE_TYPES.contains(thingTypeUID)) {
        LIRCBridgeHandler handler = new LIRCBridgeHandler((Bridge) thing);
        registerDeviceDiscoveryService(handler);
        return handler;
    } else if (thingTypeUID.equals(THING_TYPE_REMOTE)) {
        return new LIRCRemoteHandler(thing);
    }
    return null;
}
Also used : ThingTypeUID(org.eclipse.smarthome.core.thing.ThingTypeUID) LIRCRemoteHandler(org.eclipse.smarthome.binding.lirc.handler.LIRCRemoteHandler) LIRCBridgeHandler(org.eclipse.smarthome.binding.lirc.handler.LIRCBridgeHandler)

Example 42 with ThingTypeUID

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

the class SonosHandlerFactory method createHandler.

@Override
protected ThingHandler createHandler(Thing thing) {
    ThingTypeUID thingTypeUID = thing.getThingTypeUID();
    if (SonosBindingConstants.SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID)) {
        logger.debug("Creating a ZonePlayerHandler for thing '{}' with UDN '{}'", thing.getUID(), thing.getConfiguration().get(UDN));
        ZonePlayerHandler handler = new ZonePlayerHandler(thing, upnpIOService, opmlUrl);
        // register the speaker as an audio sink
        String callbackUrl = createCallbackUrl();
        SonosAudioSink audioSink = new SonosAudioSink(handler, audioHTTPServer, callbackUrl);
        @SuppressWarnings("unchecked") ServiceRegistration<AudioSink> reg = (ServiceRegistration<AudioSink>) getBundleContext().registerService(AudioSink.class.getName(), audioSink, new Hashtable<String, Object>());
        audioSinkRegistrations.put(thing.getUID().toString(), reg);
        return handler;
    }
    return null;
}
Also used : AudioSink(org.eclipse.smarthome.core.audio.AudioSink) ZonePlayerHandler(org.eclipse.smarthome.binding.sonos.internal.handler.ZonePlayerHandler) Hashtable(java.util.Hashtable) ThingTypeUID(org.eclipse.smarthome.core.thing.ThingTypeUID) ServiceRegistration(org.osgi.framework.ServiceRegistration)

Example 43 with ThingTypeUID

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

the class TradfriHandlerFactory method createHandler.

@Override
protected ThingHandler createHandler(Thing thing) {
    ThingTypeUID thingTypeUID = thing.getThingTypeUID();
    if (GATEWAY_TYPE_UID.equals(thingTypeUID)) {
        TradfriGatewayHandler handler = new TradfriGatewayHandler((Bridge) thing);
        registerDiscoveryService(handler);
        return handler;
    } else if (THING_TYPE_DIMMER.equals(thingTypeUID) || THING_TYPE_REMOTE_CONTROL.equals(thingTypeUID)) {
        return new TradfriControllerHandler(thing);
    } else if (THING_TYPE_MOTION_SENSOR.equals(thingTypeUID)) {
        return new TradfriSensorHandler(thing);
    } else if (SUPPORTED_LIGHT_TYPES_UIDS.contains(thingTypeUID)) {
        return new TradfriLightHandler(thing);
    }
    return null;
}
Also used : TradfriControllerHandler(org.eclipse.smarthome.binding.tradfri.handler.TradfriControllerHandler) TradfriSensorHandler(org.eclipse.smarthome.binding.tradfri.handler.TradfriSensorHandler) TradfriLightHandler(org.eclipse.smarthome.binding.tradfri.handler.TradfriLightHandler) TradfriGatewayHandler(org.eclipse.smarthome.binding.tradfri.handler.TradfriGatewayHandler) ThingTypeUID(org.eclipse.smarthome.core.thing.ThingTypeUID)

Example 44 with ThingTypeUID

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

the class DiscoveryConsoleCommandExtension method execute.

@Override
public void execute(String[] args, Console console) {
    if (args.length > 0) {
        String subCommand = args[0];
        switch(subCommand) {
            case SUBCMD_START:
                if (args.length > 1) {
                    String arg1 = args[1];
                    if (arg1.contains(":")) {
                        ThingTypeUID thingTypeUID = new ThingTypeUID(arg1);
                        runDiscoveryForThingType(console, thingTypeUID);
                    } else {
                        runDiscoveryForBinding(console, arg1);
                    }
                } else {
                    console.println("Specify thing type id or binding id to discover: discovery " + "start <thingTypeUID|bindingID> (e.g. \"hue:bridge\" or \"hue\")");
                }
                return;
            case SUBCMD_BACKGROUND_DISCOVERY_ENABLE:
                if (args.length > 1) {
                    String discoveryServiceName = args[1];
                    configureBackgroundDiscovery(console, discoveryServiceName, true);
                } else {
                    console.println("Specify discovery service PID to configure background discovery: discovery " + "enableBackgroundDiscovery <PID> (e.g. \"hue.discovery\")");
                }
                return;
            case SUBCMD_BACKGROUND_DISCOVERY_DISABLE:
                if (args.length > 1) {
                    String discoveryServiceName = args[1];
                    configureBackgroundDiscovery(console, discoveryServiceName, false);
                } else {
                    console.println("Specify discovery service PID to configure background discovery: discovery " + "disableBackgroundDiscovery <PID> (e.g. \"hue.discovery\")");
                }
                return;
            default:
                break;
        }
    } else {
        console.println(getUsages().get(0));
    }
}
Also used : ThingTypeUID(org.eclipse.smarthome.core.thing.ThingTypeUID)

Example 45 with ThingTypeUID

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

the class InboxConsoleCommandExtension method printInboxEntries.

private void printInboxEntries(Console console, List<DiscoveryResult> discoveryResults) {
    if (discoveryResults.isEmpty()) {
        console.println("No inbox entries found.");
    }
    for (DiscoveryResult discoveryResult : discoveryResults) {
        ThingTypeUID thingTypeUID = discoveryResult.getThingTypeUID();
        ThingUID thingUID = discoveryResult.getThingUID();
        String label = discoveryResult.getLabel();
        DiscoveryResultFlag flag = discoveryResult.getFlag();
        ThingUID bridgeId = discoveryResult.getBridgeUID();
        Map<String, Object> properties = discoveryResult.getProperties();
        String representationProperty = discoveryResult.getRepresentationProperty();
        String timestamp = new Date(discoveryResult.getTimestamp()).toString();
        String timeToLive = discoveryResult.getTimeToLive() == DiscoveryResult.TTL_UNLIMITED ? "UNLIMITED" : "" + discoveryResult.getTimeToLive();
        console.println(String.format("%s [%s]: %s [thingId=%s, bridgeId=%s, properties=%s, representationProperty=%s, timestamp=%s, timeToLive=%s]", flag.name(), thingTypeUID, label, thingUID, bridgeId, properties, representationProperty, timestamp, timeToLive));
    }
}
Also used : DiscoveryResult(org.eclipse.smarthome.config.discovery.DiscoveryResult) DiscoveryResultFlag(org.eclipse.smarthome.config.discovery.DiscoveryResultFlag) ThingUID(org.eclipse.smarthome.core.thing.ThingUID) ThingTypeUID(org.eclipse.smarthome.core.thing.ThingTypeUID) Date(java.util.Date)

Aggregations

ThingTypeUID (org.eclipse.smarthome.core.thing.ThingTypeUID)63 ThingUID (org.eclipse.smarthome.core.thing.ThingUID)27 Test (org.junit.Test)27 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)25 Thing (org.eclipse.smarthome.core.thing.Thing)12 DiscoveryResult (org.eclipse.smarthome.config.discovery.DiscoveryResult)11 Locale (java.util.Locale)10 HashMap (java.util.HashMap)9 Collection (java.util.Collection)5 DiscoveryService (org.eclipse.smarthome.config.discovery.DiscoveryService)5 Before (org.junit.Before)5 Configuration (org.eclipse.smarthome.config.core.Configuration)4 DiscoveryListener (org.eclipse.smarthome.config.discovery.DiscoveryListener)4 ApiOperation (io.swagger.annotations.ApiOperation)3 ApiResponses (io.swagger.annotations.ApiResponses)3 Nullable (org.eclipse.jdt.annotation.Nullable)3 ThingRegistry (org.eclipse.smarthome.core.thing.ThingRegistry)3 BaseThingHandlerFactory (org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory)3 Firmware (org.eclipse.smarthome.core.thing.binding.firmware.Firmware)3 ArrayList (java.util.ArrayList)2