Search in sources :

Example 61 with ChannelUID

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

the class ItemChannelLinkResource method unlink.

@DELETE
@Path("/{itemName}/{channelUID}")
@ApiOperation(value = "Unlinks item from a channel.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 404, message = "Link not found."), @ApiResponse(code = 405, message = "Link not editable.") })
public Response unlink(@PathParam("itemName") @ApiParam(value = "itemName") String itemName, @PathParam("channelUID") @ApiParam(value = "channelUID") String channelUid) {
    String linkId = AbstractLink.getIDFor(itemName, new ChannelUID(channelUid));
    if (itemChannelLinkRegistry.get(linkId) == null) {
        String message = "Link " + linkId + " does not exist!";
        return JSONResponse.createResponse(Status.NOT_FOUND, null, message);
    }
    ItemChannelLink result = itemChannelLinkRegistry.remove(AbstractLink.getIDFor(itemName, new ChannelUID(channelUid)));
    if (result != null) {
        return Response.ok(null, MediaType.TEXT_PLAIN).build();
    } else {
        return JSONResponse.createErrorResponse(Status.METHOD_NOT_ALLOWED, "Channel is read-only.");
    }
}
Also used : ChannelUID(org.eclipse.smarthome.core.thing.ChannelUID) ItemChannelLink(org.eclipse.smarthome.core.thing.link.ItemChannelLink) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 62 with ChannelUID

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

the class EnrichedThingDTOMapperTest method mockChannels.

private List<Channel> mockChannels() {
    List<Channel> channels = new ArrayList<>();
    channels.add(ChannelBuilder.create(new ChannelUID(THING_TYPE_UID + ":" + UID + ":1"), ITEM_TYPE).build());
    channels.add(ChannelBuilder.create(new ChannelUID(THING_TYPE_UID + ":" + UID + ":2"), ITEM_TYPE).build());
    return channels;
}
Also used : ChannelUID(org.eclipse.smarthome.core.thing.ChannelUID) Channel(org.eclipse.smarthome.core.thing.Channel) ArrayList(java.util.ArrayList)

Example 63 with ChannelUID

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

the class LifxChannelFactoryImpl method createColorZoneChannel.

@Override
public Channel createColorZoneChannel(ThingUID thingUID, int index) {
    String label = getText(COLOR_ZONE_LABEL_KEY, index);
    String description = getText(COLOR_ZONE_DESCRIPTION_KEY, index);
    return ChannelBuilder.create(new ChannelUID(thingUID, CHANNEL_COLOR_ZONE + index), "ColorItem").withType(CHANNEL_TYPE_COLOR_ZONE).withLabel(label).withDescription(description).build();
}
Also used : ChannelUID(org.eclipse.smarthome.core.thing.ChannelUID)

Example 64 with ChannelUID

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

the class FSInternetRadioHandlerJavaTest method createChannel.

private Channel createChannel(ThingUID thingUID, String channelID, String acceptedItemType) {
    ChannelUID channelUID = new ChannelUID(thingUID, channelID);
    Channel radioChannel = ChannelBuilder.create(channelUID, acceptedItemType).build();
    channels.add(radioChannel);
    return radioChannel;
}
Also used : ChannelUID(org.eclipse.smarthome.core.thing.ChannelUID) Channel(org.eclipse.smarthome.core.thing.Channel)

Example 65 with ChannelUID

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

the class FSInternetRadioHandlerJavaTest method powerChannelUpdated.

/**
 * Verify the power channel is updated.
 */
@Test
public void powerChannelUpdated() {
    Thing radioThing = initializeRadioThing(DEFAULT_COMPLETE_CONFIGURATION);
    testRadioThingConsideringConfiguration(radioThing);
    ChannelUID powerChannelUID = powerChannel.getUID();
    initializeItem(powerChannelUID, DEFAULT_TEST_ITEM_NAME, acceptedItemTypes.get(FSInternetRadioBindingConstants.CHANNEL_POWER));
    radioHandler.handleCommand(powerChannelUID, OnOffType.ON);
    waitForAssert(() -> {
        assertTrue("We should be able to turn on the radio", radioServiceDummy.containsRequestParameter(1, CHANNEL_POWER));
        radioServiceDummy.clearRequestParameters();
    });
    radioHandler.handleCommand(powerChannelUID, OnOffType.OFF);
    waitForAssert(() -> {
        assertTrue("We should be able to turn off the radio", radioServiceDummy.containsRequestParameter(0, CHANNEL_POWER));
        radioServiceDummy.clearRequestParameters();
    });
    /*
         * Setting the needed boolean variable to true, so we can be sure
         * that an invalid value will be returned in the XML response
         */
    radioHandler.handleCommand(powerChannelUID, OnOffType.ON);
    waitForAssert(() -> {
        assertTrue("We should be able to turn on the radio", radioServiceDummy.containsRequestParameter(1, CHANNEL_POWER));
        radioServiceDummy.clearRequestParameters();
    });
}
Also used : ChannelUID(org.eclipse.smarthome.core.thing.ChannelUID) Thing(org.eclipse.smarthome.core.thing.Thing) Test(org.junit.Test) JavaTest(org.eclipse.smarthome.test.java.JavaTest)

Aggregations

ChannelUID (org.eclipse.smarthome.core.thing.ChannelUID)69 Test (org.junit.Test)31 Thing (org.eclipse.smarthome.core.thing.Thing)24 Channel (org.eclipse.smarthome.core.thing.Channel)16 JavaTest (org.eclipse.smarthome.test.java.JavaTest)14 Configuration (org.eclipse.smarthome.config.core.Configuration)10 Bridge (org.eclipse.smarthome.core.thing.Bridge)9 ThingBuilder (org.eclipse.smarthome.core.thing.binding.builder.ThingBuilder)9 Item (org.eclipse.smarthome.core.items.Item)7 Command (org.eclipse.smarthome.core.types.Command)7 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)7 DmxBridgeHandler (org.eclipse.smarthome.binding.dmx.internal.DmxBridgeHandler)6 StringItem (org.eclipse.smarthome.core.library.items.StringItem)6 ThingUID (org.eclipse.smarthome.core.thing.ThingUID)6 BaseThingHandler (org.eclipse.smarthome.core.thing.binding.BaseThingHandler)6 ThingHandler (org.eclipse.smarthome.core.thing.binding.ThingHandler)6 ItemChannelLink (org.eclipse.smarthome.core.thing.link.ItemChannelLink)6 NonNull (org.eclipse.jdt.annotation.NonNull)5 DimmerItem (org.eclipse.smarthome.core.library.items.DimmerItem)5 NumberItem (org.eclipse.smarthome.core.library.items.NumberItem)5