use of org.openhab.binding.rfxcom.internal.RFXComException in project openhab1-addons by openhab.
the class RFXComLighting3Message method convertFromState.
@Override
public void convertFromState(RFXComValueSelector valueSelector, String id, Object subType, Type type, byte seqNumber) throws RFXComException {
this.subType = ((SubType) subType);
seqNbr = seqNumber;
switch(valueSelector) {
case COMMAND:
if (type instanceof OnOffType) {
command = (type == OnOffType.ON ? Commands.ON : Commands.OFF);
dimmingLevel = 0;
} else if (type instanceof DecimalType) {
command = Commands.fromByte(((DecimalType) type).intValue());
dimmingLevel = 0;
} else {
throw new RFXComException("Can't convert " + type + " to Command");
}
break;
case DIMMING_LEVEL:
if (type instanceof OnOffType) {
command = (type == OnOffType.ON ? Commands.ON : Commands.OFF);
dimmingLevel = 0;
} else if (type instanceof PercentType) {
command = Commands.DIM;
dimmingLevel = (byte) getDimLevelFromPercentType((PercentType) type);
if (dimmingLevel == 0) {
command = Commands.OFF;
}
} else if (type instanceof IncreaseDecreaseType) {
command = Commands.DIM;
// Evert: I do not know how to get previous object state...
dimmingLevel = 5;
} else {
throw new RFXComException("Can't convert " + type + " to Command");
}
break;
default:
throw new RFXComException("Can't convert " + type + " to " + valueSelector);
}
}
use of org.openhab.binding.rfxcom.internal.RFXComException in project openhab1-addons by openhab.
the class RFXComMessageFactory method getMessageInterface.
public static RFXComMessageInterface getMessageInterface(byte[] packet) throws RFXComException {
PacketType packetType = getPacketType(packet[1]);
try {
String className = messageClasses.get(packetType);
Class<?> cl = Class.forName(classUrl + className);
Constructor<?> c = cl.getConstructor(byte[].class);
return (RFXComMessageInterface) c.newInstance(packet);
} catch (ClassNotFoundException e) {
throw new RFXComException("Message " + packetType + "(" + packet[1] + ") not implemented", e);
} catch (Exception e) {
throw new RFXComException(e);
}
}
use of org.openhab.binding.rfxcom.internal.RFXComException in project openhab1-addons by openhab.
the class RFXComMessageFactory method getMessageInterface.
public static RFXComMessageInterface getMessageInterface(PacketType packetType) throws RFXComException {
try {
String className = messageClasses.get(packetType);
Class<?> cl = Class.forName(classUrl + className);
return (RFXComMessageInterface) cl.newInstance();
} catch (ClassNotFoundException e) {
throw new RFXComException("Message " + packetType + " not implemented", e);
} catch (Exception e) {
throw new RFXComException(e);
}
}
use of org.openhab.binding.rfxcom.internal.RFXComException in project openhab1-addons by openhab.
the class RFXComThermostat2Message method convertFromState.
@Override
public void convertFromState(RFXComValueSelector valueSelector, String id, Object subType, Type type, byte seqNumber) throws RFXComException {
this.subType = ((SubType) subType);
seqNbr = seqNumber;
String[] ids = id.split("\\.");
unitcode = Byte.parseByte(ids[0]);
switch(valueSelector) {
case COMMAND:
if (type instanceof OnOffType) {
command = (type == OnOffType.ON ? Commands.ON : Commands.OFF);
} else if (type instanceof OpenClosedType) {
command = (type == OpenClosedType.CLOSED ? Commands.ON : Commands.OFF);
} else {
throw new RFXComException("Can't convert " + type + " to Command");
}
break;
default:
throw new RFXComException("Can't convert " + type + " to " + valueSelector);
}
}
use of org.openhab.binding.rfxcom.internal.RFXComException in project openhab1-addons by openhab.
the class RFXComThermostat3Message method convertFromState.
@Override
public void convertFromState(RFXComValueSelector valueSelector, String id, Object subType, Type type, byte seqNumber) throws RFXComException {
this.subType = ((SubType) subType);
seqNbr = seqNumber;
String[] ids = id.split("\\.");
unitcode = Byte.parseByte(ids[0]);
switch(valueSelector) {
case COMMAND:
if (type instanceof OnOffType) {
command = (type == OnOffType.ON ? Commands.ON : Commands.OFF);
} else if (type instanceof OpenClosedType) {
command = (type == OpenClosedType.CLOSED ? Commands.ON : Commands.OFF);
} else {
throw new RFXComException("Can't convert " + type + " to Command");
}
break;
default:
throw new RFXComException("Can't convert " + type + " to " + valueSelector);
}
}
Aggregations