logger.debug("Trying to match command to object type "
+ config.getObjectType());
switch (config.getObjectType()) {
case UNIT: {
Unit unit = (Unit) config.getDevice();
boolean resendToChildren = false;
if (command == OnOffType.ON) {
cmd = OmniLinkCmd.CMD_UNIT_ON.getNumber();
} else if (command == OnOffType.OFF) {
cmd = OmniLinkCmd.CMD_UNIT_OFF.getNumber();
} else if (command == IncreaseDecreaseType.INCREASE) {
cmd = OmniLinkCmd.CMD_UNIT_UPB_BRIGHTEN_STEP_1.getNumber();
resendToChildren = true;
} else if (command == IncreaseDecreaseType.DECREASE) {
cmd = OmniLinkCmd.CMD_UNIT_UPB_DIM_STEP_1.getNumber();
resendToChildren = true;
} else if (command instanceof PercentType) {
int level = ((PercentType) command).intValue();
if (level == 0 || level == 100) {
cmd = level == 0 ? OmniLinkCmd.CMD_UNIT_OFF.getNumber()
: OmniLinkCmd.CMD_UNIT_ON.getNumber();
} else {
cmd = OmniLinkCmd.CMD_UNIT_PERCENT.getNumber();
param1 = level;
resendToChildren = true;
}
} else if (command instanceof StringType
&& unit.getProperties().getUnitType() == UnitProperties.UNIT_TYPE_HLC_ROOM) {
int roomNum = (unit.getProperties().getNumber() + 7) / 8;
// every room has 6 links, the 3rd is where link A starts,
// so in room 1 linkA=link3 linkB=link4 linkc=link6 linkd=link7
String str = ((StringType) command).toString().toLowerCase();
int linkNum = 0;
if (str.contains("scene a"))
linkNum = 0;
else if (str.contains("scene b"))
linkNum = 1;
else if (str.contains("scene c"))
linkNum = 2;
else if (str.contains("scene d"))
linkNum = 3;
else
break;
param1 = 0;
param2 = ((roomNum * 6) - 3) + linkNum;
cmd = OmniLinkCmd.CMD_UNIT_UPB_LINK_ON.getNumber();
}
// if this is a room, send the command to all the other units
if (resendToChildren
&& unit.getProperties().getUnitType() == UnitProperties.UNIT_TYPE_HLC_ROOM) {
for (int i = unit.getProperties().getNumber() + 1; i < unit
.getProperties().getNumber() + 8; i++) {
commands.add(new OmniLinkControllerCommand(cmd, param1, i));
}
} else {
commands.add(new OmniLinkControllerCommand(cmd, param1, param2));