Search in sources :

Example 1 with ChannelUID

use of org.openhab.core.thing.ChannelUID in project org.openhab.binding.zwave by openhab.

the class ZWaveIndicatorConverterTest method createChannel.

private ZWaveThingChannel createChannel(String channelType, DataType dataType, String type) {
    ChannelUID uid = new ChannelUID("zwave:node:bridge:" + channelType);
    ChannelTypeUID typeUid = new ChannelTypeUID("zwave:" + channelType);
    Map<String, String> args = new HashMap<String, String>();
    if (type != null) {
        args.put("type", type);
    }
    return new ZWaveThingChannel(null, typeUid, uid, dataType, CommandClass.COMMAND_CLASS_INDICATOR.toString(), 0, args);
}
Also used : ChannelTypeUID(org.openhab.core.thing.type.ChannelTypeUID) HashMap(java.util.HashMap) ChannelUID(org.openhab.core.thing.ChannelUID) ZWaveThingChannel(org.openhab.binding.zwave.handler.ZWaveThingChannel)

Example 2 with ChannelUID

use of org.openhab.core.thing.ChannelUID in project org.openhab.binding.zwave by openhab.

the class ZWaveManufacturerProprietaryFibaroFgrm222ConverterTest method Set_Fgrm222_Lamella.

@Test
public void Set_Fgrm222_Lamella() {
    ZWaveManufacturerProprietaryConverter converter = new ZWaveManufacturerProprietaryConverter(null);
    ChannelUID uid = new ChannelUID("zwave:node:bridge:blinds_lamella");
    ChannelTypeUID typeUid = new ChannelTypeUID("zwave:blinds_lamella");
    ZWaveThingChannel channel = new ZWaveThingChannel(null, typeUid, uid, DataType.PercentType, CommandClass.COMMAND_CLASS_MANUFACTURER_PROPRIETARY.toString(), 0, new HashMap<String, String>());
    ZWaveNode node = CreateMockedNode(1);
    PercentType command = new PercentType(48);
    List<ZWaveCommandClassTransactionPayload> msgs = converter.receiveCommand(channel, node, command);
    assertNotNull(msgs);
    assertEquals(1, msgs.size());
    byte[] expectedResponse = { -111, 1, 15, 38, 1, 1, 0, 48 };
    ZWaveCommandClassTransactionPayload msg = msgs.get(0);
    assertTrue(Arrays.equals(msg.getPayloadBuffer(), expectedResponse));
}
Also used : ChannelTypeUID(org.openhab.core.thing.type.ChannelTypeUID) ZWaveNode(org.openhab.binding.zwave.internal.protocol.ZWaveNode) ZWaveCommandClassTransactionPayload(org.openhab.binding.zwave.internal.protocol.transaction.ZWaveCommandClassTransactionPayload) ChannelUID(org.openhab.core.thing.ChannelUID) ZWaveThingChannel(org.openhab.binding.zwave.handler.ZWaveThingChannel) PercentType(org.openhab.core.library.types.PercentType) Test(org.junit.jupiter.api.Test)

Example 3 with ChannelUID

use of org.openhab.core.thing.ChannelUID in project org.openhab.binding.zwave by openhab.

the class ZWaveManufacturerProprietaryFibaroFgrm222ConverterTest method Set_Fgrm222_Shutter.

@Test
public void Set_Fgrm222_Shutter() {
    ZWaveManufacturerProprietaryConverter converter = new ZWaveManufacturerProprietaryConverter(null);
    ChannelUID uid = new ChannelUID("zwave:node:bridge:blinds_shutter");
    ChannelTypeUID typeUid = new ChannelTypeUID("zwave:blinds_shutter");
    ZWaveThingChannel channel = new ZWaveThingChannel(null, typeUid, uid, DataType.PercentType, CommandClass.COMMAND_CLASS_MANUFACTURER_PROPRIETARY.toString(), 0, new HashMap<String, String>());
    ZWaveNode node = CreateMockedNode(1);
    PercentType command = new PercentType(48);
    List<ZWaveCommandClassTransactionPayload> msgs = converter.receiveCommand(channel, node, command);
    assertNotNull(msgs);
    assertEquals(1, msgs.size());
    byte[] expectedResponse = { -111, 1, 15, 38, 1, 2, 48, 0 };
    ZWaveCommandClassTransactionPayload msg = msgs.get(0);
    assertTrue(Arrays.equals(msg.getPayloadBuffer(), expectedResponse));
}
Also used : ChannelTypeUID(org.openhab.core.thing.type.ChannelTypeUID) ZWaveNode(org.openhab.binding.zwave.internal.protocol.ZWaveNode) ZWaveCommandClassTransactionPayload(org.openhab.binding.zwave.internal.protocol.transaction.ZWaveCommandClassTransactionPayload) ChannelUID(org.openhab.core.thing.ChannelUID) ZWaveThingChannel(org.openhab.binding.zwave.handler.ZWaveThingChannel) PercentType(org.openhab.core.library.types.PercentType) Test(org.junit.jupiter.api.Test)

Example 4 with ChannelUID

use of org.openhab.core.thing.ChannelUID in project org.openhab.binding.zwave by openhab.

the class ZWaveManufacturerProprietaryFibaroFgrm222ConverterTest method Event_Fgrm222_Lamella.

@Test
public void Event_Fgrm222_Lamella() {
    ZWaveManufacturerProprietaryConverter converter = new ZWaveManufacturerProprietaryConverter(null);
    ChannelUID uid = new ChannelUID("zwave:node:bridge:blinds_lamella");
    ZWaveThingChannel channel = new ZWaveThingChannel(null, typeUid, uid, DataType.PercentType, CommandClass.COMMAND_CLASS_MANUFACTURER_PROPRIETARY.toString(), 0, new HashMap<String, String>());
    State state;
    ZWaveValueEvent event;
    Map<String, String> values = new HashMap<String, String>();
    values.put("LAMELLA_POSITION", "62");
    values.put("SHUTTER_POSITION", "12");
    event = new ZWaveValueEvent(1, 0, CommandClass.COMMAND_CLASS_MANUFACTURER_PROPRIETARY, values);
    state = converter.handleEvent(channel, event);
    assertEquals(state.getClass(), PercentType.class);
    assertEquals(state, new PercentType(62));
}
Also used : HashMap(java.util.HashMap) ChannelUID(org.openhab.core.thing.ChannelUID) State(org.openhab.core.types.State) ZWaveValueEvent(org.openhab.binding.zwave.internal.protocol.event.ZWaveValueEvent) ZWaveThingChannel(org.openhab.binding.zwave.handler.ZWaveThingChannel) PercentType(org.openhab.core.library.types.PercentType) Test(org.junit.jupiter.api.Test)

Example 5 with ChannelUID

use of org.openhab.core.thing.ChannelUID in project org.openhab.binding.zwave by openhab.

the class ZWaveThingHandlerTest method testConvertToDataTypeFails.

@Test
public void testConvertToDataTypeFails() {
    ZWaveThingHandler sut = new ZWaveThingHandlerForTest(null);
    ChannelUID channelUID = new ChannelUID("channel:for:a:test");
    // couldnt convert to channel data-type because channel data-type is not an instance of State
    Command result = sut.convertCommandToDataType(channelUID, ZWaveThingChannel.DataType.StopMoveType, StopMoveType.STOP, ZWaveThingChannel.DataType.DecimalType);
    assertNull(result);
    // command is not an instance of State and couldnt be converted to something
    result = sut.convertCommandToDataType(channelUID, ZWaveThingChannel.DataType.DecimalType, StopMoveType.STOP, ZWaveThingChannel.DataType.StopMoveType);
    assertNull(result);
}
Also used : Command(org.openhab.core.types.Command) ChannelUID(org.openhab.core.thing.ChannelUID) Test(org.junit.jupiter.api.Test)

Aggregations

ChannelUID (org.openhab.core.thing.ChannelUID)573 Channel (org.openhab.core.thing.Channel)185 Test (org.junit.jupiter.api.Test)154 Thing (org.openhab.core.thing.Thing)125 ChannelTypeUID (org.openhab.core.thing.type.ChannelTypeUID)88 ArrayList (java.util.ArrayList)80 State (org.openhab.core.types.State)79 StringType (org.openhab.core.library.types.StringType)68 ThingUID (org.openhab.core.thing.ThingUID)67 Nullable (org.eclipse.jdt.annotation.Nullable)59 DecimalType (org.openhab.core.library.types.DecimalType)59 ThingBuilder (org.openhab.core.thing.binding.builder.ThingBuilder)55 Command (org.openhab.core.types.Command)55 HashMap (java.util.HashMap)50 Bridge (org.openhab.core.thing.Bridge)47 NonNullByDefault (org.eclipse.jdt.annotation.NonNullByDefault)46 Configuration (org.openhab.core.config.core.Configuration)46 StateOption (org.openhab.core.types.StateOption)43 ThingStatus (org.openhab.core.thing.ThingStatus)40 OnOffType (org.openhab.core.library.types.OnOffType)39