Package org.openhab.binding.pulseaudio.internal.items

Examples of org.openhab.binding.pulseaudio.internal.items.AbstractAudioDeviceConfig


          itemName, serverId);
      return;
    }

    if (audioItemName != null && !audioItemName.isEmpty()) {
      AbstractAudioDeviceConfig audioItem = client
          .getGenericAudioItem(audioItemName);
      if (audioItem == null) {
        logger.warn(
            "no corresponding audio-item found [audioItemName={}]",
            audioItemName);
        return;
      }
      State updateState = UnDefType.UNDEF;

      if (command instanceof IncreaseDecreaseType) {
        int volume = audioItem.getVolume();
        logger.debug(audioItemName + " volume is " + volume);
        if (command.equals(IncreaseDecreaseType.INCREASE))
          volume = Math.min(100, volume + 5);
        if (command.equals(IncreaseDecreaseType.DECREASE))
          volume = Math.max(0, volume - 5);
View Full Code Here


          client.update();
          updatedClients.add(client);
        }

        State value = UnDefType.UNDEF;
        AbstractAudioDeviceConfig audioItem = client
            .getGenericAudioItem(audioItemName);

        if (audioItem != null) {
          // item found
          if (itemType.isAssignableFrom(DimmerItem.class)) {
            value = new PercentType(audioItem.getVolume());
          } else if (itemType.isAssignableFrom(NumberItem.class)) {
            if (commandType == null) {
              // when no other pulseaudioCommand specified, we use
              // VOLUME
              value = new DecimalType(audioItem.getVolume());
            } else {
              // NumberItems can only handle VOLUME, MODULE_ID and ID command types
              switch (commandType) {
              case VOLUME:
                value = new DecimalType(audioItem.getVolume());
                break;
              case ID:
                value = new DecimalType(audioItem.getId());
                break;
              case MODULE_ID:
                if (audioItem.getModule()!=null)
                  value = new DecimalType(audioItem.getModule().getId());
                break;
              }
            }
          } else if (itemType.isAssignableFrom(SwitchItem.class)) {
            if (commandType == null) {
              // Check if item is unmuted and running
              if (!audioItem.isMuted()
                  && audioItem.getState() != null
                  && audioItem.getState().equals(
                      AbstractAudioDeviceConfig.State.RUNNING)) {
                value = OnOffType.ON;
              } else {
                value = OnOffType.OFF;
              }
            } else {
              switch (commandType) {
              case EXISTS:
                value = OnOffType.ON;
                break;
              case MUTED:
                value = audioItem.isMuted() ? OnOffType.ON
                    : OnOffType.OFF;
                break;
              case RUNNING:
              case CORKED:
              case SUSPENDED:
              case IDLE:
                try {
                value = audioItem.getState() != null
                    && audioItem.getState().equals(
                        AbstractAudioDeviceConfig.State.valueOf(commandType.name())) ? OnOffType.ON
                    : OnOffType.OFF;
                }
                catch (IllegalArgumentException e) {
                  logger.warn("no corresponding AbstractAudioDeviceConfig.State found for "+commandType.name());
                }
                break;
              }
            }
          } else if (itemType.isAssignableFrom(StringItem.class)) {
            if (commandType == null) {
              value = new StringType(audioItem.toString());
            }
            else if (audioItem instanceof Sink) {
              Sink sink = (Sink)audioItem;
              switch (commandType) {
              case SLAVE_SINKS:
View Full Code Here

TOP

Related Classes of org.openhab.binding.pulseaudio.internal.items.AbstractAudioDeviceConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.