String itemName = key.toString();
if(!itemName.startsWith("__")) { // all additional webapp params start with "__" and should be ignored
String commandName = req.getParameter(itemName);
try {
Item item = itemRegistry.getItem(itemName);
// we need a special treatment for the "TOGGLE" command of switches;
// this is no command officially supported and must be translated
// into real commands by the webapp.
if ((item instanceof SwitchItem || item instanceof GroupItem) && commandName.equals("TOGGLE")) {
commandName = OnOffType.ON.equals(item.getStateAs(OnOffType.class)) ? "OFF" : "ON";
}
Command command = TypeParser.parseCommand(item.getAcceptedCommandTypes(), commandName);
if(command!=null) {
eventPublisher.sendCommand(itemName, command);
} else {
logger.warn("Received unknown command '{}' for item '{}'", commandName, itemName);
}