use of org.eclipse.smarthome.core.thing.ChannelUID in project smarthome by eclipse.
the class LifxLightHandler method getPowerOnBrightness.
private PercentType getPowerOnBrightness() {
Channel channel = null;
if (product.isColor()) {
ChannelUID channelUID = new ChannelUID(getThing().getUID(), LifxBindingConstants.CHANNEL_COLOR);
channel = getThing().getChannel(channelUID.getId());
} else {
ChannelUID channelUID = new ChannelUID(getThing().getUID(), LifxBindingConstants.CHANNEL_BRIGHTNESS);
channel = getThing().getChannel(channelUID.getId());
}
if (channel == null) {
return null;
}
Configuration configuration = channel.getConfiguration();
Object powerOnBrightness = configuration.get(LifxBindingConstants.CONFIG_PROPERTY_POWER_ON_BRIGHTNESS);
return powerOnBrightness == null ? null : new PercentType(powerOnBrightness.toString());
}
use of org.eclipse.smarthome.core.thing.ChannelUID in project smarthome by eclipse.
the class LifxLightHandler method getPowerOnColor.
private HSBType getPowerOnColor() {
Channel channel = null;
if (product.isColor()) {
ChannelUID channelUID = new ChannelUID(getThing().getUID(), LifxBindingConstants.CHANNEL_COLOR);
channel = getThing().getChannel(channelUID.getId());
}
if (channel == null) {
return null;
}
Configuration configuration = channel.getConfiguration();
Object powerOnColor = configuration.get(LifxBindingConstants.CONFIG_PROPERTY_POWER_ON_COLOR);
return powerOnColor == null ? null : new HSBType(powerOnColor.toString());
}
use of org.eclipse.smarthome.core.thing.ChannelUID in project smarthome by eclipse.
the class LifxChannelFactoryImpl method createTemperatureZoneChannel.
@Override
public Channel createTemperatureZoneChannel(ThingUID thingUID, int index) {
String label = getText(TEMPERATURE_ZONE_LABEL_KEY, index);
String description = getText(TEMPERATURE_ZONE_DESCRIPTION_KEY, index);
return ChannelBuilder.create(new ChannelUID(thingUID, CHANNEL_TEMPERATURE_ZONE + index), "DimmerItem").withType(CHANNEL_TYPE_TEMPERATURE_ZONE).withLabel(label).withDescription(description).build();
}
use of org.eclipse.smarthome.core.thing.ChannelUID in project smarthome by eclipse.
the class FSInternetRadioHandlerJavaTest method modeChannelUdpated.
/**
* Verify the mode channel is updated.
*/
@Test
public void modeChannelUdpated() {
String modeChannelID = FSInternetRadioBindingConstants.CHANNEL_MODE;
String acceptedItemType = acceptedItemTypes.get(modeChannelID);
createChannel(DEFAULT_THING_UID, modeChannelID, acceptedItemType);
Thing radioThing = initializeRadioThing(DEFAULT_COMPLETE_CONFIGURATION);
testRadioThingConsideringConfiguration(radioThing);
turnTheRadioOn(radioThing);
ChannelUID modeChannelUID = getChannelUID(radioThing, modeChannelID);
initializeItem(modeChannelUID, DEFAULT_TEST_ITEM_NAME, acceptedItemType);
radioHandler.handleCommand(modeChannelUID, DecimalType.valueOf("1"));
waitForAssert(() -> {
assertTrue("We should be able to update the mode channel correctly", radioServiceDummy.containsRequestParameter(1, CHANNEL_MODE));
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(modeChannelUID, DecimalType.valueOf("3"));
waitForAssert(() -> {
assertTrue("We should be able to update the mode channel correctly", radioServiceDummy.containsRequestParameter(3, CHANNEL_MODE));
radioServiceDummy.clearRequestParameters();
});
}
use of org.eclipse.smarthome.core.thing.ChannelUID in project smarthome by eclipse.
the class FSInternetRadioHandlerJavaTest method offlineIfParseError.
/**
* Verify OFFLINE Thing status when the HTTP response cannot be parsed correctly.
*/
@Test
public void offlineIfParseError() {
// create a thing with two channels - the power channel and any of the others
String modeChannelID = FSInternetRadioBindingConstants.CHANNEL_MODE;
String acceptedItemType = acceptedItemTypes.get(modeChannelID);
createChannel(DEFAULT_THING_UID, modeChannelID, acceptedItemType);
Thing radioThing = initializeRadioThing(DEFAULT_COMPLETE_CONFIGURATION);
testRadioThingConsideringConfiguration(radioThing);
ChannelUID modeChannelUID = getChannelUID(radioThing, modeChannelID);
/*
* Setting the isInvalidResponseExpected variable to true
* in order to get the incorrect XML response from the servlet
*/
radioServiceDummy.setInvalidResponse(true);
// try to handle a command
radioHandler.handleCommand(modeChannelUID, DecimalType.valueOf("1"));
waitForAssert(() -> {
String exceptionMessage = "java.io.IOException: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 2;";
verifyCommunicationError(exceptionMessage);
});
radioServiceDummy.setInvalidResponse(false);
}
Aggregations