import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
+import org.openhab.binding.yamahamusiccast.internal.dto.ActualVolume;
import org.openhab.binding.yamahamusiccast.internal.dto.DeviceInfo;
import org.openhab.binding.yamahamusiccast.internal.dto.DistributionInfo;
import org.openhab.binding.yamahamusiccast.internal.dto.Features;
import org.openhab.core.types.Command;
import org.openhab.core.types.RefreshType;
import org.openhab.core.types.StateOption;
+import org.openhab.core.types.UnDefType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private int volumeAbsValue = 0;
private @Nullable String responseCode = "";
private int volumeState = 0;
- private float volumeDbState = -80f; // -80.0 dB
private int maxVolumeState = 0;
private @Nullable String inputState = "";
private @Nullable String soundProgramState = "";
String muteState = "";
String inputState = "";
int volumeState = 0;
- float volumeDbState = -90f; // -90.0 dB
+ ActualVolume actualVolume = null;
int presetNumber = 0;
int playTime = 0;
String distInfoUpdated = "";
muteState = targetObject.getMain().getMute();
inputState = targetObject.getMain().getInput();
volumeState = targetObject.getMain().getVolume();
- volumeDbState = targetObject.getMain().getVolumeDb();
+ actualVolume = targetObject.getMain().getActualVolume();
statusUpdated = targetObject.getMain().getstatusUpdated();
break;
case "zone2":
muteState = targetObject.getZone2().getMute();
inputState = targetObject.getZone2().getInput();
volumeState = targetObject.getZone2().getVolume();
- volumeDbState = targetObject.getZone2().getVolumeDb();
+ actualVolume = targetObject.getZone2().getActualVolume();
statusUpdated = targetObject.getZone2().getstatusUpdated();
break;
case "zone3":
muteState = targetObject.getZone3().getMute();
inputState = targetObject.getZone3().getInput();
volumeState = targetObject.getZone3().getVolume();
- volumeDbState = targetObject.getZone3().getVolumeDb();
+ actualVolume = targetObject.getZone3().getActualVolume();
statusUpdated = targetObject.getZone3().getstatusUpdated();
break;
case "zone4":
muteState = targetObject.getZone4().getMute();
inputState = targetObject.getZone4().getInput();
volumeState = targetObject.getZone4().getVolume();
- volumeDbState = targetObject.getZone4().getVolumeDb();
+ actualVolume = targetObject.getZone4().getActualVolume();
statusUpdated = targetObject.getZone4().getstatusUpdated();
break;
case "netusb":
break;
}
+ if (logger.isTraceEnabled()) {
+ logger.trace("{} - Response: {}", zoneToUpdate, responseCode);
+ logger.trace("{} - Power: {}", zoneToUpdate, powerState);
+ logger.trace("{} - Mute: {}", zoneToUpdate, muteState);
+ logger.trace("{} - Volume: {}", zoneToUpdate, volumeState);
+ logger.trace("{} - Volume in dB: {}", zoneToUpdate, (actualVolume != null) ? actualVolume.getValue() : "");
+ logger.trace("{} - Max Volume: {}", zoneToUpdate, maxVolumeState);
+ logger.trace("{} - Input: {}", zoneToUpdate, inputState);
+ logger.trace("{} - Soundprogram: {}", zoneToUpdate, soundProgramState);
+ logger.trace("{} - Sleep: {}", zoneToUpdate, sleepState);
+ }
+
if (!powerState.isEmpty()) {
channel = new ChannelUID(getThing().getUID(), zoneToUpdate, CHANNEL_POWER);
if ("on".equals(powerState)) {
updateState(channel, new DecimalType(volumeState));
}
- if (volumeDbState != -90f) {
+ if (actualVolume != null) {
channel = new ChannelUID(getThing().getUID(), zoneToUpdate, CHANNEL_VOLUMEDB);
- updateState(channel, new QuantityType<>(volumeDbState, Units.DECIBEL));
+ updateState(channel, new QuantityType<>(actualVolume.getValue(), Units.DECIBEL));
}
if (presetNumber != 0) {
String powerState = targetObject.getPower();
String muteState = targetObject.getMute();
volumeState = targetObject.getVolume();
- volumeDbState = targetObject.getVolumeDb();
+ ActualVolume actualVolume = targetObject.getActualVolume();
maxVolumeState = targetObject.getMaxVolume();
inputState = targetObject.getInput();
soundProgramState = targetObject.getSoundProgram();
sleepState = targetObject.getSleep();
- logger.trace("{} - Response: {}", zoneToUpdate, responseCode);
- logger.trace("{} - Power: {}", zoneToUpdate, powerState);
- logger.trace("{} - Mute: {}", zoneToUpdate, muteState);
- logger.trace("{} - Volume: {}", zoneToUpdate, volumeState);
- logger.trace("{} - Volume in dB: {}", zoneToUpdate, volumeDbState);
- logger.trace("{} - Max Volume: {}", zoneToUpdate, maxVolumeState);
- logger.trace("{} - Input: {}", zoneToUpdate, inputState);
- logger.trace("{} - Soundprogram: {}", zoneToUpdate, soundProgramState);
- logger.trace("{} - Sleep: {}", zoneToUpdate, sleepState);
+ if (logger.isTraceEnabled()) {
+ logger.trace("{} - Response: {}", zoneToUpdate, responseCode);
+ logger.trace("{} - Power: {}", zoneToUpdate, powerState);
+ logger.trace("{} - Mute: {}", zoneToUpdate, muteState);
+ logger.trace("{} - Volume: {}", zoneToUpdate, volumeState);
+ logger.trace("{} - Volume in dB: {}", zoneToUpdate,
+ (actualVolume != null) ? actualVolume.getValue() : "");
+ logger.trace("{} - Max Volume: {}", zoneToUpdate, maxVolumeState);
+ logger.trace("{} - Input: {}", zoneToUpdate, inputState);
+ logger.trace("{} - Soundprogram: {}", zoneToUpdate, soundProgramState);
+ logger.trace("{} - Sleep: {}", zoneToUpdate, sleepState);
+ }
switch (responseCode) {
case "0":
break;
case CHANNEL_VOLUMEDB:
if (localZone.equals(zoneToUpdate)) {
- updateState(channelUID, new QuantityType<>(volumeDbState, Units.DECIBEL));
+ if (actualVolume != null) {
+ updateState(channelUID,
+ new QuantityType<>(actualVolume.getValue(), Units.DECIBEL));
+ } else {
+ updateState(channelUID, UnDefType.UNDEF);
+ }
}
break;
case CHANNEL_INPUT:
channel-type.yamahamusiccast.artist.label = Artist
channel-type.yamahamusiccast.artist.description = Artist
channel-type.yamahamusiccast.input.label = Input
-channel-type.yamahamusiccast.input.description = Input channel
+channel-type.yamahamusiccast.input.description = Input source
channel-type.yamahamusiccast.mclinkStatus.label = Status MusicCast
channel-type.yamahamusiccast.mclinkStatus.description = MusicCast Status
channel-type.yamahamusiccast.playTime.label = Play Time
channel-type.yamahamusiccast.playTime.description = Play Time
channel-type.yamahamusiccast.player.label = NetRadio/USB Player
-channel-type.yamahamusiccast.player.description = Player for Net Radio/USB channel
+channel-type.yamahamusiccast.player.description = Player for Net Radio/USB
channel-type.yamahamusiccast.recallScene.label = Scene Selection
channel-type.yamahamusiccast.recallScene.description = Scene selection (if available)
channel-type.yamahamusiccast.recallScene.state.option.1 = Scene 1
channel-type.yamahamusiccast.repeat.state.option.one = One
channel-type.yamahamusiccast.repeat.state.option.all = All
channel-type.yamahamusiccast.selectPreset.label = NetRadio/USB Preset
-channel-type.yamahamusiccast.selectPreset.description = Select Net Radio/USB Preset channel
+channel-type.yamahamusiccast.selectPreset.description = Select Net Radio/USB Preset
channel-type.yamahamusiccast.shuffle.label = Shuffle
channel-type.yamahamusiccast.shuffle.description = Shuffle mode
channel-type.yamahamusiccast.shuffle.state.option.off = Off
channel-type.yamahamusiccast.sleep.state.option.90 = 90 min
channel-type.yamahamusiccast.sleep.state.option.120 = 120 min
channel-type.yamahamusiccast.soundProgram.label = Sound Program
-channel-type.yamahamusiccast.soundProgram.description = SoundProgram channel
+channel-type.yamahamusiccast.soundProgram.description = SoundProgram
channel-type.yamahamusiccast.totalTime.label = Total Time
channel-type.yamahamusiccast.totalTime.description = Total Time
channel-type.yamahamusiccast.track.label = Track
channel-type.yamahamusiccast.track.description = Track
channel-type.yamahamusiccast.volumeAbs.label = Volume
-channel-type.yamahamusiccast.volumeAbs.description = Volume channel - Absolute value
+channel-type.yamahamusiccast.volumeAbs.description = Volume level - Absolute value
channel-type.yamahamusiccast.volumeDB.label = Volume in dB
-channel-type.yamahamusiccast.volumeDB.description = Volume channel - in decibel (dB) (-90 dB if not available)
+channel-type.yamahamusiccast.volumeDB.description = Volume level - decibel (dB)
<channel-type id="volumeAbs">
<item-type>Number</item-type>
<label>Volume</label>
- <description>Volume channel - Absolute value</description>
+ <description>Volume level - Absolute value</description>
<category>SoundVolume</category>
</channel-type>
<channel-type id="volumeDB">
<item-type>Number:Dimensionless</item-type>
<label>Volume in dB</label>
- <description>Volume channel - in decibel (dB) (-90 dB if not available)</description>
+ <description>Volume level - decibel (dB)</description>
<category>SoundVolume</category>
<state min="-80" max="12" step="0.5" pattern="%.1f %unit%"/>
</channel-type>
<channel-type id="input">
<item-type>String</item-type>
<label>Input</label>
- <description>Input channel</description>
+ <description>Input source</description>
</channel-type>
<channel-type id="soundProgram">
<item-type>String</item-type>
<label>Sound Program</label>
- <description>SoundProgram channel</description>
+ <description>SoundProgram</description>
</channel-type>
<channel-type id="selectPreset">
<item-type>String</item-type>
<label>NetRadio/USB Preset</label>
- <description>Select Net Radio/USB Preset channel</description>
+ <description>Select Net Radio/USB Preset</description>
</channel-type>
<channel-type id="player">
<item-type>Player</item-type>
<label>NetRadio/USB Player</label>
- <description>Player for Net Radio/USB channel</description>
+ <description>Player for Net Radio/USB</description>
</channel-type>
<channel-type id="sleep">
<item-type>Number</item-type>