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

The following examples show how to use org.eclipse.smarthome.core.thing.ThingTypeUID#getId() . 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: ChangeThingTypeOSGiTest.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
private ThingType registerThingTypeAndConfigDescription(ThingTypeUID thingTypeUID,
        Map<String, String> thingTypeProperties) throws URISyntaxException {
    URI configDescriptionUri = new URI("test:" + thingTypeUID.getId());
    ThingType thingType = ThingTypeBuilder.instance(thingTypeUID, "label")
            .withChannelDefinitions(getChannelDefinitions(thingTypeUID))
            .withConfigDescriptionURI(configDescriptionUri).withProperties(thingTypeProperties).build();
    ConfigDescription configDescription = new ConfigDescription(configDescriptionUri,
            Arrays.asList(
                    ConfigDescriptionParameterBuilder
                            .create("parameter" + thingTypeUID.getId(), ConfigDescriptionParameter.Type.TEXT)
                            .withRequired(false).withDefault("default" + thingTypeUID.getId()).build(),
                    ConfigDescriptionParameterBuilder
                            .create("provided" + thingTypeUID.getId(), ConfigDescriptionParameter.Type.TEXT)
                            .withRequired(false).build()));

    thingTypes.put(thingTypeUID, thingType);
    configDescriptions.put(configDescriptionUri, configDescription);

    return thingType;
}
 
Example 2
Source File: SonyAudioHandlerFactory.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();

    switch (thingTypeUID.getId()) {
        case SonyAudioBindingConstants.SONY_TYPE_STRDN1080:
            return new StrDn1080Handler(thing, webSocketClient);
        case SonyAudioBindingConstants.SONY_TYPE_HTCT800:
            return new HtCt800Handler(thing, webSocketClient);
        case SonyAudioBindingConstants.SONY_TYPE_HTST5000:
            return new HtSt5000Handler(thing, webSocketClient);
        case SonyAudioBindingConstants.SONY_TYPE_HTZ9F:
            return new HtZ9fHandler(thing, webSocketClient);
        case SonyAudioBindingConstants.SONY_TYPE_HTZF9:
            return new HtZf9Handler(thing, webSocketClient);
        case SonyAudioBindingConstants.SONY_TYPE_HTMT500:
            return new HtMt500Handler(thing, webSocketClient);
        case SonyAudioBindingConstants.SONY_TYPE_SRSZR5:
            return new SrsZr5Handler(thing, webSocketClient);
        default:
            return null;
    }
}
 
Example 3
Source File: ChangeThingTypeOSGiTest.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
private List<ChannelDefinition> getChannelDefinitions(ThingTypeUID thingTypeUID) throws URISyntaxException {
    List<ChannelDefinition> channelDefinitions = new ArrayList<>();
    ChannelTypeUID channelTypeUID = new ChannelTypeUID("test:" + thingTypeUID.getId());
    ChannelType channelType = new ChannelType(channelTypeUID, false, "itemType", "channelLabel", "description",
            "category", new HashSet<String>(), null,
            new URI("scheme", "channelType:" + thingTypeUID.getId(), null));

    channelTypes.put(channelTypeUID, channelType);

    ChannelDefinition cd = new ChannelDefinitionBuilder("channel" + thingTypeUID.getId(), channelTypeUID).build();
    channelDefinitions.add(cd);
    return channelDefinitions;
}
 
Example 4
Source File: WemoDiscoveryParticipantTest.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
public void testDiscoveryResult(ThingTypeUID thingTypeUid)
        throws MalformedURLException, ValidationException, URISyntaxException {
    String thingTypeId = thingTypeUid.getId();
    RemoteDevice device = createUpnpDevice(thingTypeId);
    DiscoveryResult result = participant.createResult(device);

    assertNotNull(result);
    assertThat(result.getThingUID(), is(new ThingUID(thingTypeUid, DEVICE_UDN)));
    assertThat(result.getThingTypeUID(), is(thingTypeUid));
    assertThat(result.getBridgeUID(), is(nullValue()));
    assertThat(result.getProperties().get(WemoBindingConstants.UDN), is(DEVICE_UDN.toString()));
    assertThat(result.getRepresentationProperty(), is(WemoBindingConstants.UDN));
}
 
Example 5
Source File: DeviceDiscoveryService.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates a new {@link DeviceDiscoveryService} for the given supported {@link ThingTypeUID}.
 *
 * @param bridgeHandler (must not be null)
 * @param supportedThingType (must not be null)
 * @throws IllegalArgumentException see {@link AbstractDiscoveryService#AbstractDiscoveryService(int)}
 */
public DeviceDiscoveryService(BridgeHandler bridgeHandler, ThingTypeUID supportedThingType)
        throws IllegalArgumentException {
    super(new HashSet<>(Arrays.asList(supportedThingType)), TIMEOUT, true);
    this.deviceType = supportedThingType.getId();
    this.bridgeHandler = bridgeHandler;
    bridgeUID = bridgeHandler.getThing().getUID();
}
 
Example 6
Source File: ZoneTemperatureControlDiscoveryService.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates a new {@link ZoneTemperatureControlDiscoveryService}.
 *
 * @param bridgeHandler must not be null
 * @param supportedThingType must not be null
 * @throws IllegalArgumentException see {@link AbstractDiscoveryService#AbstractDiscoveryService(int)}
 */
public ZoneTemperatureControlDiscoveryService(BridgeHandler bridgeHandler, ThingTypeUID supportedThingType)
        throws IllegalArgumentException {
    super(new HashSet<>(Arrays.asList(supportedThingType)), TIMEOUT, true);
    bridgeUID = bridgeHandler.getThing().getUID();
    this.bridgeHandler = bridgeHandler;
    thingTypeID = supportedThingType.getId();
}
 
Example 7
Source File: ThingTypeI18nUtil.java    From smarthome with Eclipse Public License 2.0 4 votes vote down vote up
private String inferThingTypeKey(ThingTypeUID thingTypeUID, String lastSegment) {
    return "thing-type." + thingTypeUID.getBindingId() + "." + thingTypeUID.getId() + "." + lastSegment;
}
 
Example 8
Source File: ThingTypeI18nUtil.java    From smarthome with Eclipse Public License 2.0 4 votes vote down vote up
private String inferThingTypeKey(ThingTypeUID thingTypeUID, ChannelGroupDefinition channelGroup,
        String lastSegment) {
    return "thing-type." + thingTypeUID.getBindingId() + "." + thingTypeUID.getId() + ".group."
            + channelGroup.getId() + "." + lastSegment;
}
 
Example 9
Source File: ThingTypeI18nUtil.java    From smarthome with Eclipse Public License 2.0 4 votes vote down vote up
private String inferThingTypeKey(ThingTypeUID thingTypeUID, ChannelDefinition channel, String lastSegment) {
    return "thing-type." + thingTypeUID.getBindingId() + "." + thingTypeUID.getId() + ".channel." + channel.getId()
            + "." + lastSegment;
}
 
Example 10
Source File: SceneDiscoveryService.java    From smarthome with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Creates a new {@link SceneDiscoveryService} for the given supportedThingType.
 *
 * @param bridgeHandler (must not be null)
 * @param supportedThingType (must not be null)
 * @throws IllegalArgumentException see {@link AbstractDiscoveryService#AbstractDiscoveryService(int)}
 */
public SceneDiscoveryService(BridgeHandler bridgeHandler, ThingTypeUID supportedThingType)
        throws IllegalArgumentException {
    super(new HashSet<>(Arrays.asList(supportedThingType)), TIMEOUT, false);
    this.sceneType = supportedThingType.getId();
    this.bridgeHandler = bridgeHandler;
}
 
Example 11
Source File: ThingImpl.java    From smarthome with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * @param thingTypeUID thing type UID
 * @param thingId thing ID
 * @throws IllegalArgumentException
 */
public ThingImpl(ThingTypeUID thingTypeUID, String thingId) throws IllegalArgumentException {
    this.uid = new ThingUID(thingTypeUID.getBindingId(), thingTypeUID.getId(), thingId);
    this.thingTypeUID = thingTypeUID;
}
 
Example 12
Source File: ThingTypeBuilder.java    From smarthome with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Create and return a {@link ThingTypeBuilder} with the given {@link ThingTypeUID} and {@code label}. Also,
 * {@code listed} defaults to {@code true}.
 *
 * @param thingTypeUID the {@link ThingTypeUID} the resulting {@link ThingType} will have. Must not be null.
 * @param label the label of the resulting {@link ThingType}. Must not be null or empty.
 * @return the new {@link ThingTypeBuilder}.
 */
public static ThingTypeBuilder instance(ThingTypeUID thingTypeUID, String label) {
    return new ThingTypeBuilder(thingTypeUID.getBindingId(), thingTypeUID.getId(), label);
}