Search in sources :

Example 21 with ChannelUID

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());
}
Also used : Configuration(org.eclipse.smarthome.config.core.Configuration) ChannelUID(org.eclipse.smarthome.core.thing.ChannelUID) Channel(org.eclipse.smarthome.core.thing.Channel) PercentType(org.eclipse.smarthome.core.library.types.PercentType) LifxMessageUtil.increaseDecreasePercentType(org.eclipse.smarthome.binding.lifx.internal.util.LifxMessageUtil.increaseDecreasePercentType)

Example 22 with ChannelUID

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());
}
Also used : Configuration(org.eclipse.smarthome.config.core.Configuration) ChannelUID(org.eclipse.smarthome.core.thing.ChannelUID) Channel(org.eclipse.smarthome.core.thing.Channel) HSBType(org.eclipse.smarthome.core.library.types.HSBType)

Example 23 with ChannelUID

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();
}
Also used : ChannelUID(org.eclipse.smarthome.core.thing.ChannelUID)

Example 24 with ChannelUID

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

Example 25 with ChannelUID

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);
}
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