@Override public void internalReceiveCommand(OpenhabCommandType.OpenhabCommand command) throws CouldNotPerformException { try { if (!command.hasOnOff() || !command.getOnOff().hasState()) { throw new CouldNotPerformException("Command does not have an onOff value required for apps"); } logger.debug("Received command for app [" + command.getItem() + "] from openhab"); appRegistry.get(getIdFromOpenHABItem(command)).setActivationState(ActivationStateTransformer.transform(command.getOnOff().getState())); } catch (CouldNotPerformException ex) { throw new CouldNotPerformException("Skip item update [" + command.getItem() + " = " + command.getOnOff() + "]!", ex); } }
@Override public void internalReceiveCommand(OpenhabCommandType.OpenhabCommand command) throws CouldNotPerformException { try { if (!command.hasOnOff() || !command.getOnOff().hasState()) { throw new CouldNotPerformException("Command does not have an onOff value required for scenes"); } logger.debug("Received command for scene [" + command.getItem() + "] from openhab"); sceneRegistry.get(getSceneIdFromOpenHABItem(command)).setActivationState(ActivationStateTransformer.transform(command.getOnOff().getState())); } catch (CouldNotPerformException ex) { throw new CouldNotPerformException("Skip item update [" + command.getItem() + " = " + command.getOnOff() + "]!", ex); } }
public static Object getCommandData(final OpenhabCommand command) throws CouldNotPerformException { switch (command.getType()) { case DECIMAL: return command.getDecimal(); case HSB: return command.getHsb(); case INCREASEDECREASE: return command.getIncreaseDecrease(); case ONOFF: return command.getOnOff(); case OPENCLOSED: return command.getOpenClosed(); case PERCENT: return command.getPercent(); case STOPMOVE: return command.getStopMove(); case STRING: return command.getText(); case UPDOWN: return command.getUpDown(); default: throw new CouldNotTransformException("No corresponding data found for " + command + "."); } } }