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: