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.");
}
}
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;
}
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();
}
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;
}
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();
});
}
Aggregations