Java Code Examples for org.eclipse.smarthome.core.thing.ThingTypeUID#equals()

The following examples show how to use org.eclipse.smarthome.core.thing.ThingTypeUID#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MqttBrokerHandlerFactory.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected @Nullable ThingHandler createHandler(Thing thing) {
    if (mqttService == null) {
        throw new IllegalStateException("MqttService must be bound, before ThingHandlers can be created");
    }
    if (!(thing instanceof Bridge)) {
        throw new IllegalStateException("A bridge type is expected");
    }
    final ThingTypeUID thingTypeUID = thing.getThingTypeUID();

    final AbstractBrokerHandler handler;
    if (thingTypeUID.equals(MqttBindingConstants.BRIDGE_TYPE_SYSTEMBROKER)) {
        handler = new SystemBrokerHandler((Bridge) thing, mqttService);
    } else if (thingTypeUID.equals(MqttBindingConstants.BRIDGE_TYPE_BROKER)) {
        handler = new BrokerHandler((Bridge) thing);
    } else {
        throw new IllegalStateException("Not supported " + thingTypeUID.toString());
    }
    createdHandler(handler);
    return handler;
}
 
Example 2
Source File: WeatherUndergroundHandlerFactory.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected ThingHandler createHandler(Thing thing) {
    ThingTypeUID thingTypeUID = thing.getThingTypeUID();

    if (thingTypeUID.equals(THING_TYPE_WEATHER)) {
        return new WeatherUndergroundHandler(thing, localeProvider, unitProvider);
    }

    if (thingTypeUID.equals(THING_TYPE_BRIDGE)) {
        WeatherUndergroundBridgeHandler handler = new WeatherUndergroundBridgeHandler((Bridge) thing);
        registerDiscoveryService(handler.getThing().getUID());
        return handler;
    }

    return null;
}
 
Example 3
Source File: WemoHandler.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
private synchronized void removeSubscription() {
    logger.debug("Removing WeMo GENA subscription for '{}'", this);

    if (service.isRegistered(this)) {
        ThingTypeUID thingTypeUID = thing.getThingTypeUID();
        String subscription = "basicevent1";

        if ((subscriptionState.get(subscription) != null) && subscriptionState.get(subscription).booleanValue()) {
            logger.debug("WeMo {}: Unsubscribing from service {}...", getUDN(), subscription);
            service.removeSubscription(this, subscription);
        }

        if (thingTypeUID.equals(THING_TYPE_INSIGHT)) {
            subscription = "insight1";
            if ((subscriptionState.get(subscription) != null)
                    && subscriptionState.get(subscription).booleanValue()) {
                logger.debug("WeMo {}: Unsubscribing from service {}...", getUDN(), subscription);
                service.removeSubscription(this, subscription);
            }
        }
        subscriptionState = new HashMap<String, Boolean>();
        service.unregisterParticipant(this);
    }
}
 
Example 4
Source File: MeteoBlueHandlerFactory.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected ThingHandler createHandler(Thing thing) {
    ThingTypeUID thingTypeUID = thing.getThingTypeUID();

    if (thingTypeUID.equals(THING_TYPE_WEATHER)) {
        return new MeteoBlueHandler(thing);
    }

    if (thingTypeUID.equals(THING_TYPE_BRIDGE)) {
        return new MeteoBlueBridgeHandler((Bridge) thing);
    }

    return null;
}
 
Example 5
Source File: GreeAirHandlerFactory.java    From openhab-greeair-binding with Apache License 2.0 5 votes vote down vote up
@Override
// protected @Nullable ThingHandler createHandler(Thing thing) {
protected ThingHandler createHandler(Thing thing) {
    ThingTypeUID thingTypeUID = thing.getThingTypeUID();

    if (thingTypeUID.equals(GREE_THING_TYPE)) {
        return new GreeAirHandler(thing);
    }

    return null;
}
 
Example 6
Source File: AstroHandlerFactory.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected ThingHandler createHandler(Thing thing) {
    ThingTypeUID thingTypeUID = thing.getThingTypeUID();
    AstroThingHandler thingHandler = null;
    if (thingTypeUID.equals(THING_TYPE_SUN)) {
        thingHandler = new SunHandler(thing, scheduler);
    } else if (thingTypeUID.equals(THING_TYPE_MOON)) {
        thingHandler = new MoonHandler(thing, scheduler);
    }
    if (thingHandler != null) {
        ASTRO_THING_HANDLERS.put(thing.getUID().toString(), thingHandler);
    }
    return thingHandler;
}
 
Example 7
Source File: BlueGigaHandlerFactory.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected ThingHandler createHandler(Thing thing) {
    ThingTypeUID thingTypeUID = thing.getThingTypeUID();

    if (thingTypeUID.equals(BlueGigaAdapterConstants.THING_TYPE_BLUEGIGA)) {
        BlueGigaBridgeHandler handler = new BlueGigaBridgeHandler((Bridge) thing, serialPortManager);
        registerBluetoothAdapter(handler);
        return handler;
    } else {
        return null;
    }
}
 
Example 8
Source File: LIRCHandlerFactory.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@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;
}
 
Example 9
Source File: DmxTestHandlerFactory.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected ThingHandler createHandler(Thing thing) {
    ThingTypeUID thingTypeUID = thing.getThingTypeUID();
    if (thingTypeUID.equals(TestBridgeHandler.THING_TYPE_TEST_BRIDGE)) {
        TestBridgeHandler handler = new TestBridgeHandler((Bridge) thing);
        return handler;
    }
    return null;
}
 
Example 10
Source File: BlueZHandlerFactory.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected ThingHandler createHandler(Thing thing) {
    ThingTypeUID thingTypeUID = thing.getThingTypeUID();

    if (thingTypeUID.equals(BlueZAdapterConstants.THING_TYPE_BLUEZ)) {
        BlueZBridgeHandler handler = new BlueZBridgeHandler((Bridge) thing);
        registerBluetoothAdapter(handler);
        return handler;
    } else {
        return null;
    }
}
 
Example 11
Source File: FSInternetRadioHandlerFactory.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected ThingHandler createHandler(Thing thing) {
    ThingTypeUID thingTypeUID = thing.getThingTypeUID();

    if (thingTypeUID.equals(THING_TYPE_RADIO)) {
        return new FSInternetRadioHandler(thing, httpClient);
    }

    return null;
}
 
Example 12
Source File: SerialButtonHandlerFactory.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected @Nullable ThingHandler createHandler(Thing thing) {
    ThingTypeUID thingTypeUID = thing.getThingTypeUID();

    if (thingTypeUID.equals(SerialButtonBindingConstants.THING_TYPE_BUTTON)) {
        return new SerialButtonHandler(thing, serialPortManager);
    }

    return null;
}
 
Example 13
Source File: WemoHandlerFactory.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected ThingHandler createHandler(Thing thing) {
    ThingTypeUID thingTypeUID = thing.getThingTypeUID();
    if (thingTypeUID != null) {
        logger.debug("Trying to create a handler for ThingType '{}", thingTypeUID);

        WemoHttpCall wemoHttpcaller = new WemoHttpCall();

        if (thingTypeUID.equals(WemoBindingConstants.THING_TYPE_BRIDGE)) {
            logger.debug("Creating a WemoBridgeHandler for thing '{}' with UDN '{}'", thing.getUID(),
                    thing.getConfiguration().get(UDN));
            WemoBridgeHandler handler = new WemoBridgeHandler((Bridge) thing);
            registerDeviceDiscoveryService(handler, wemoHttpcaller);
            return handler;
        } else if (thingTypeUID.equals(WemoBindingConstants.THING_TYPE_MAKER)) {
            logger.debug("Creating a WemoMakerHandler for thing '{}' with UDN '{}'", thing.getUID(),
                    thing.getConfiguration().get(UDN));
            return new WemoMakerHandler(thing, upnpIOService, wemoHttpcaller);
        } else if (WemoBindingConstants.SUPPORTED_DEVICE_THING_TYPES.contains(thing.getThingTypeUID())) {
            logger.debug("Creating a WemoHandler for thing '{}' with UDN '{}'", thing.getUID(),
                    thing.getConfiguration().get(UDN));
            return new WemoHandler(thing, upnpIOService, wemoHttpcaller);
        } else if (thingTypeUID.equals(WemoBindingConstants.THING_TYPE_COFFEE)) {
            logger.debug("Creating a WemoCoffeeHandler for thing '{}' with UDN '{}'", thing.getUID(),
                    thing.getConfiguration().get(UDN));
            return new WemoCoffeeHandler(thing, upnpIOService, wemoHttpcaller);
        } else if (thingTypeUID.equals(WemoBindingConstants.THING_TYPE_MZ100)) {
            return new WemoLightHandler(thing, upnpIOService, wemoHttpcaller);
        } else {
            logger.warn("ThingHandler not found for {}", thingTypeUID);
            return null;
        }
    }
    return null;
}
 
Example 14
Source File: WemoHandler.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
private synchronized void onSubscription() {
    if (service.isRegistered(this)) {
        logger.debug("Checking WeMo GENA subscription for '{}'", this);

        ThingTypeUID thingTypeUID = thing.getThingTypeUID();
        String subscription = "basicevent1";

        if ((subscriptionState.get(subscription) == null) || !subscriptionState.get(subscription).booleanValue()) {
            logger.debug("Setting up GENA subscription {}: Subscribing to service {}...", getUDN(), subscription);
            service.addSubscription(this, subscription, SUBSCRIPTION_DURATION);
            subscriptionState.put(subscription, true);
        }

        if (thingTypeUID.equals(THING_TYPE_INSIGHT)) {
            subscription = "insight1";
            if ((subscriptionState.get(subscription) == null)
                    || !subscriptionState.get(subscription).booleanValue()) {
                logger.debug("Setting up GENA subscription {}: Subscribing to service {}...", getUDN(),
                        subscription);
                service.addSubscription(this, subscription, SUBSCRIPTION_DURATION);
                subscriptionState.put(subscription, true);
            }
        }
    } else {
        logger.debug("Setting up WeMo GENA subscription for '{}' FAILED - service.isRegistered(this) is FALSE",
                this);
    }
}
 
Example 15
Source File: MqttThingHandlerFactory.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected @Nullable ThingHandler createHandler(Thing thing) {
    ThingTypeUID thingTypeUID = thing.getThingTypeUID();

    if (thingTypeUID.equals(MqttBindingConstants.GENERIC_MQTT_THING)) {
        return new GenericThingHandler(thing, stateDescriptionProvider, this, 1500);
    } else if (thingTypeUID.equals(MqttBindingConstants.HOMIE300_MQTT_THING)) {
        return new HomieThingHandler(thing, typeProvider, 1500, 200);
    } else if (thingTypeUID.equals(MqttBindingConstants.HOMEASSISTANT_MQTT_THING)) {
        return new HomeAssistantThingHandler(thing, typeProvider, 1500, 200);
    }
    return null;
}
 
Example 16
Source File: BlukiiHandlerFactory.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected ThingHandler createHandler(Thing thing) {
    ThingTypeUID thingTypeUID = thing.getThingTypeUID();

    if (thingTypeUID.equals(BlukiiBindingConstants.THING_TYPE_BEACON)) {
        return new BlukiiHandler(thing);
    }

    return null;
}
 
Example 17
Source File: BluetoothHandlerFactory.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected ThingHandler createHandler(Thing thing) {
    ThingTypeUID thingTypeUID = thing.getThingTypeUID();

    if (thingTypeUID.equals(BluetoothBindingConstants.THING_TYPE_BEACON)) {
        return new BeaconBluetoothHandler(thing);
    } else if (thingTypeUID.equals(BluetoothBindingConstants.THING_TYPE_CONNECTED)) {
        return new ConnectedBluetoothHandler(thing);
    }

    return null;
}
 
Example 18
Source File: MagicHandlerFactory.java    From smarthome with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected ThingHandler createHandler(Thing thing) {
    ThingTypeUID thingTypeUID = thing.getThingTypeUID();

    if (thingTypeUID.equals(THING_TYPE_EXTENSIBLE_THING)) {
        return new MagicExtensibleThingHandler(thing);
    }
    if (thingTypeUID.equals(THING_TYPE_ON_OFF_LIGHT)) {
        return new MagicOnOffLightHandler(thing);
    }
    if (thingTypeUID.equals(THING_TYPE_DIMMABLE_LIGHT)) {
        return new MagicDimmableLightHandler(thing);
    }
    if (thingTypeUID.equals(THING_TYPE_COLOR_LIGHT)) {
        return new MagicColorLightHandler(thing);
    }
    if (thingTypeUID.equals(THING_TYPE_CONTACT_SENSOR)) {
        return new MagicContactHandler(thing);
    }
    if (thingTypeUID.equals(THING_TYPE_CONFIG_THING)) {
        return new MagicConfigurableThingHandler(thing);
    }
    if (thingTypeUID.equals(THING_TYPE_DELAYED_THING)) {
        return new MagicDelayedOnlineHandler(thing);
    }
    if (thingTypeUID.equals(THING_TYPE_LOCATION)) {
        return new MagicLocationThingHandler(thing);
    }
    if (thingTypeUID.equals(THING_TYPE_THERMOSTAT)) {
        return new MagicThermostatThingHandler(thing);
    }
    if (thingTypeUID.equals(THING_TYPE_FIRMWARE_UPDATE)) {
        return new MagicFirmwareUpdateThingHandler(thing);
    }
    if (thingTypeUID.equals(THING_TYPE_BRIDGED_THING)) {
        return new MagicBridgedThingHandler(thing);
    }
    if (thingTypeUID.equals(THING_TYPE_CHATTY_THING)) {
        return new MagicChattyThingHandler(thing);
    }
    if (thingTypeUID.equals(THING_TYPE_ROLLERSHUTTER)) {
        return new MagicRolllershutterHandler(thing);
    }
    if (thingTypeUID.equals(THING_TYPE_PLAYER)) {
        return new MagicPlayerHandler(thing);
    }
    if (thingTypeUID.equals(THING_TYPE_IMAGE)) {
        return new MagicImageHandler(thing);
    }
    if (thingTypeUID.equals(THING_TYPE_ACTION_MODULE)) {
        MagicActionModuleThingHandler handler = new MagicActionModuleThingHandler(thing);
        return handler;
    }
    if (thingTypeUID.equals(THING_TYPE_ONLINE_OFFLINE)) {
        return new MagicOnlineOfflineHandler(thing);
    }

    if (thingTypeUID.equals(THING_TYPE_BRIDGE_1) || thingTypeUID.equals(THING_TYPE_BRIDGE_2)) {
        return new MagicBridgeHandler((Bridge) thing);
    }

    return null;
}
 
Example 19
Source File: InboxPredicates.java    From smarthome with Eclipse Public License 2.0 4 votes vote down vote up
public static Predicate<DiscoveryResult> forThingTypeUID(@Nullable ThingTypeUID uid) {
    return r -> uid != null && uid.equals(r.getThingTypeUID());
}