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