// Dimmer item extends SwitchItem, so it need to be handled before
// SwitchItem
if (value.getClass() == WSIntegerValue.class) {
state = new PercentType(((WSIntegerValue) value).getInteger());
} else {
throw new NumberFormatException("Can't convert "
+ value.getClass().toString() + " to NumberItem");
}
} else if (itemType == SwitchItem.class) {
if (value.getClass() == WSBooleanValue.class) {
if (((WSBooleanValue) value).isValue()) {
state = OnOffType.ON;
} else {
state = OnOffType.OFF;
}
} else {
throw new NumberFormatException("Can't convert "
+ value.getClass().toString() + " to SwitchItem");
}
} else if (itemType == ContactItem.class) {
if (value.getClass() == WSBooleanValue.class) {
if (((WSBooleanValue) value).isValue()) {
state = OpenClosedType.OPEN;
} else {
state = OpenClosedType.CLOSED;
}
} else {
throw new NumberFormatException("Can't convert "
+ value.getClass().toString() + " to ContactItem");
}
} else if (itemType == DateTimeItem.class) {
if (value.getClass() == WSDateValue.class) {
Calendar cal = WSDateTimeToCalendar((WSDateValue) value, null);
state = new DateTimeType(cal);
} else if (value.getClass() == WSTimeValue.class) {
Calendar cal = WSDateTimeToCalendar(null, (WSTimeValue) value);
state = new DateTimeType(cal);
} else {
throw new NumberFormatException("Can't convert "
+ value.getClass().toString() + " to DateTimeItem");
}
} else if (itemType == StringItem.class) {
if (value.getClass() == WSEnumValue.class) {
state = new StringType(((WSEnumValue) value).getEnumName());
} else {
throw new NumberFormatException("Can't convert "
+ value.getClass().toString() + " to StringItem");
}
} else if (itemType == RollershutterItem.class) {
if (value.getClass() == WSIntegerValue.class)
state = new PercentType(((WSIntegerValue) value).getInteger());
else
throw new NumberFormatException("Can't convert "
+ value.getClass().toString() + " to NumberItem");