things/benq.things:
```
-//serial port connection
+// serial port connection
benqprojector:projector-serial:hometheater "Projector" [ serialPort="COM5", pollingInterval=10 ]
-// serial over IP connection
+// direct IP or serial over IP connection
benqprojector:projector-tcp:hometheater "Projector" [ host="192.168.0.10", port=8000, pollingInterval=10 ]
```
sitemaps/benq.sitemap
```
-sitemap benq label="BenQ Projector Demo" {
+sitemap benq label="BenQ Projector" {
Frame label="Controls" {
Switch item=benqPower label="Power"
Selection item=benqSource label="Source" mappings=["hdmi"="HDMI", "hdmi2"="HDMI2", "ypbr"="Component", "RGB"="Computer", "vid"="Video", "svid"="S-Video"]
*/
package org.openhab.binding.benqprojector.internal;
-import java.io.InvalidClassException;
-
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.items.Item;
import org.openhab.core.library.items.NumberItem;
*/
@NonNullByDefault
public enum BenqProjectorCommandType {
- POWER("Power", SwitchItem.class),
- SOURCE("Source", StringItem.class),
- PICTURE_MODE("PictureMode", StringItem.class),
- ASPECT_RATIO("AspectRatio", StringItem.class),
- FREEZE("Freeze", SwitchItem.class),
- BLANK("Blank", SwitchItem.class),
- DIRECTCMD("DirectCmd", StringItem.class),
- LAMP_TIME("LampTime", NumberItem.class);
+ POWER("power", SwitchItem.class),
+ SOURCE("source", StringItem.class),
+ PICTURE_MODE("picturemode", StringItem.class),
+ ASPECT_RATIO("aspectratio", StringItem.class),
+ FREEZE("freeze", SwitchItem.class),
+ BLANK("blank", SwitchItem.class),
+ DIRECTCMD("directcmd", StringItem.class),
+ LAMP_TIME("lamptime", NumberItem.class);
private final String text;
private Class<? extends Item> itemClass;
return itemClass;
}
- /**
- * Procedure to validate command type string.
- *
- * @param commandTypeText
- * command string e.g. RawData, Command, Brightness
- * @return true if item is valid.
- * @throws IllegalArgumentException
- * Not valid command type.
- * @throws InvalidClassException
- * Not valid class for command type.
- */
- public static boolean validateBinding(String commandTypeText, Class<? extends Item> itemClass)
- throws IllegalArgumentException, InvalidClassException {
- for (BenqProjectorCommandType c : BenqProjectorCommandType.values()) {
- if (c.text.equalsIgnoreCase(commandTypeText)) {
- if (c.getItemClass().equals(itemClass)) {
- return true;
- } else {
- throw new InvalidClassException("Not valid class for command type");
- }
- }
- }
-
- throw new IllegalArgumentException("Not valid command type");
- }
-
/**
* Procedure to convert command type string to command type class.
*
* @param commandTypeText
* command string e.g. RawData, Command, Brightness
* @return corresponding command type.
- * @throws InvalidClassException
- * Not valid class for command type.
+ * @throws IllegalArgumentException
+ * No valid class for command type.
*/
public static BenqProjectorCommandType getCommandType(String commandTypeText) throws IllegalArgumentException {
for (BenqProjectorCommandType c : BenqProjectorCommandType.values()) {
- if (c.text.equalsIgnoreCase(commandTypeText)) {
+ if (c.text.equals(commandTypeText)) {
return c;
}
}
- throw new IllegalArgumentException("Not valid command type");
+ throw new IllegalArgumentException("Not valid command type: " + commandTypeText);
}
}