Java Code Examples for org.eclipse.smarthome.core.types.Command#equals()

The following examples show how to use org.eclipse.smarthome.core.types.Command#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommandExecutor.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Post PlayerControl on the device
 *
 * @param command the command is Type of Command
 */
public void postPlayerControl(Command command) {
    if (command.equals(PlayPauseType.PLAY)) {
        if (currentOperationMode == OperationModeType.STANDBY) {
            postRemoteKey(RemoteKeyType.POWER);
        } else {
            postRemoteKey(RemoteKeyType.PLAY);
        }
    } else if (command.equals(PlayPauseType.PAUSE)) {
        postRemoteKey(RemoteKeyType.PAUSE);
    } else if (command.equals(NextPreviousType.NEXT)) {
        postRemoteKey(RemoteKeyType.NEXT_TRACK);
    } else if (command.equals(NextPreviousType.PREVIOUS)) {
        postRemoteKey(RemoteKeyType.PREV_TRACK);
    }
}
 
Example 2
Source File: ZonePlayerHandler.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
public void setMute(Command command) {
    if (command != null) {
        if (command instanceof OnOffType || command instanceof OpenClosedType || command instanceof UpDownType) {
            Map<String, String> inputs = new HashMap<String, String>();
            inputs.put("Channel", "Master");

            if (command.equals(OnOffType.ON) || command.equals(UpDownType.UP)
                    || command.equals(OpenClosedType.OPEN)) {
                inputs.put("DesiredMute", "True");
            } else if (command.equals(OnOffType.OFF) || command.equals(UpDownType.DOWN)
                    || command.equals(OpenClosedType.CLOSED)) {
                inputs.put("DesiredMute", "False");
            }

            Map<String, String> result = service.invokeAction(this, "RenderingControl", "SetMute", inputs);

            for (String variable : result.keySet()) {
                this.onValueReceived(variable, result.get(variable), "RenderingControl");
            }
        }
    }
}
 
Example 3
Source File: ZonePlayerHandler.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
public void setLed(Command command) {
    if (command != null) {
        if (command instanceof OnOffType || command instanceof OpenClosedType || command instanceof UpDownType) {
            Map<String, String> inputs = new HashMap<String, String>();

            if (command.equals(OnOffType.ON) || command.equals(UpDownType.UP)
                    || command.equals(OpenClosedType.OPEN)) {
                inputs.put("DesiredLEDState", "On");
            } else if (command.equals(OnOffType.OFF) || command.equals(UpDownType.DOWN)
                    || command.equals(OpenClosedType.CLOSED)) {
                inputs.put("DesiredLEDState", "Off");
            }

            Map<String, String> result = service.invokeAction(this, "DeviceProperties", "SetLEDState", inputs);
            Map<String, String> result2 = service.invokeAction(this, "DeviceProperties", "GetLEDState", null);

            result.putAll(result2);

            for (String variable : result.keySet()) {
                this.onValueReceived(variable, result.get(variable), "DeviceProperties");
            }
        }
    }
}
 
Example 4
Source File: RuleTriggerManager.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
private void internalGetCommandRules(String name, Boolean isGroup,
        List<Class<? extends Command>> acceptedCommandTypes, Command command, List<Rule> result) {
    final String mapName = (isGroup) ? GROUP_NAME_PREFIX + name : name;
    for (Rule rule : getAllRules(COMMAND, mapName)) {
        for (final EventTrigger t : rule.getEventtrigger()) {
            String triggerCommandString = null;
            if ((!isGroup) && (t instanceof CommandEventTrigger)) {
                final CommandEventTrigger ct = (CommandEventTrigger) t;
                if (ct.getItem().equals(name)) {
                    triggerCommandString = ct.getCommand()!=null?ct.getCommand().getValue() : null;
                } else {
                    continue;
                }
            } else if ((isGroup) && (t instanceof GroupMemberCommandEventTrigger)) {
                final GroupMemberCommandEventTrigger gmct = (GroupMemberCommandEventTrigger) t;
                if (gmct.getGroup().equals(name)) {
                    triggerCommandString = gmct.getCommand() != null ? gmct.getCommand().getValue() : null;
                } else {
                    continue;
                }
            } else {
                continue;
            }
            if (triggerCommandString != null) {
                final Command triggerCommand = TypeParser.parseCommand(acceptedCommandTypes, triggerCommandString);
                if (!command.equals(triggerCommand)) {
                    continue;
                }
            }
            result.add(rule);
        }
    }
}
 
Example 5
Source File: ZonePlayerHandler.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
public void setShuffle(Command command) {
    if ((command != null) && (command instanceof OnOffType || command instanceof OpenClosedType
            || command instanceof UpDownType)) {
        try {
            ZonePlayerHandler coordinator = getCoordinatorHandler();

            if (command.equals(OnOffType.ON) || command.equals(UpDownType.UP)
                    || command.equals(OpenClosedType.OPEN)) {
                switch (coordinator.getRepeatMode()) {
                    case "ALL":
                        coordinator.updatePlayMode("SHUFFLE");
                        break;
                    case "ONE":
                        coordinator.updatePlayMode("SHUFFLE_REPEAT_ONE");
                        break;
                    case "OFF":
                        coordinator.updatePlayMode("SHUFFLE_NOREPEAT");
                        break;
                }
            } else if (command.equals(OnOffType.OFF) || command.equals(UpDownType.DOWN)
                    || command.equals(OpenClosedType.CLOSED)) {
                switch (coordinator.getRepeatMode()) {
                    case "ALL":
                        coordinator.updatePlayMode("REPEAT_ALL");
                        break;
                    case "ONE":
                        coordinator.updatePlayMode("REPEAT_ONE");
                        break;
                    case "OFF":
                        coordinator.updatePlayMode("NORMAL");
                        break;
                }
            }
        } catch (IllegalStateException e) {
            logger.debug("Cannot handle shuffle command ({})", e.getMessage());
        }
    }
}
 
Example 6
Source File: ZonePlayerHandler.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
public void setAlarm(Command command) {
    if (command instanceof OnOffType || command instanceof OpenClosedType || command instanceof UpDownType) {
        if (command.equals(OnOffType.ON) || command.equals(UpDownType.UP) || command.equals(OpenClosedType.OPEN)) {
            setAlarm(true);
        } else if (command.equals(OnOffType.OFF) || command.equals(UpDownType.DOWN)
                || command.equals(OpenClosedType.CLOSED)) {
            setAlarm(false);
        }
    }
}