use of org.openhab.binding.mochadx10.commands.MochadX10OffCommand in project openhab1-addons by openhab.
the class MochadX10CommandParser method parseCommand.
/**
* Parse the command part of the received message.
*
* @param address The X10 address of the command
* @param commandString The string containing the X10 command
* @return A MochadX10Command if parsing was successful, otherwise null
*/
private MochadX10Command parseCommand(MochadX10Address address, String commandString) {
if (commandString != null) {
String command = commandString.toLowerCase();
Matcher matcher;
if (command.equals("on")) {
return new MochadX10OnCommand(eventPublisher, address);
} else if (command.equals("off")) {
return new MochadX10OffCommand(eventPublisher, address);
} else if (command.contains("dim")) {
matcher = DIM_PATTERN.matcher(command);
if (matcher.matches()) {
int level = matcher.group("value") == null ? -1 : Integer.parseInt(matcher.group("value"));
return new MochadX10DimCommand(eventPublisher, address, level);
}
} else if (command.contains("bright")) {
matcher = BRIGHT_PATTERN.matcher(command);
if (matcher.matches()) {
int level = matcher.group("value") == null ? -1 : Integer.parseInt(matcher.group("value"));
return new MochadX10BrightCommand(eventPublisher, address, level);
}
}
}
return null;
}
Aggregations