Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sonos] Add new channel codec for several models #10979

Merged
merged 9 commits into from
Jul 25, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bundles/org.openhab.binding.sonos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ The devices support the following channels:
| batterycharging | Switch | R | Indicator set to ON when the battery is charging | Move |
| batterylevel | Number | R | Current battery level | Move |
| clearqueue | Switch | W | Suppress all songs from the current queue | all |
| codec | String | R | Name of codec currently being decoded | Arc, Arc SL, PLAYBAR, PLAYBASE, Beam, Amp |
| control | Player | RW | Control the Zone Player, e.g. PLAY/PAUSE/NEXT/PREVIOUS | all |
| coordinator | String | R | UDN of the coordinator for the current group | all |
| currentalbum | String | R | Name of the album currently playing | all |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public class SonosBindingConstants {
public static final String BATTERYCHARGING = "batterycharging";
public static final String BATTERYLEVEL = "batterylevel";
public static final String CLEARQUEUE = "clearqueue";
public static final String CODEC = "codec";
public static final String CONTROL = "control";
public static final String COORDINATOR = "coordinator";
public static final String CURRENTALBUM = "currentalbum";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ public void startElement(@Nullable String uri, @Nullable String localName, @Null
case "SurroundEnabled":
case "SurroundMode":
case "SurroundLevel":
case "HTAudioIn":
case "MusicSurroundLevel":
case "HeightChannelLevel":
val = attributes == null ? null : attributes.getValue("val");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,9 @@ public void onValueReceived(@Nullable String variable, @Nullable String value, @
case "SurroundLevel":
updateChannel(SURROUNDTVLEVEL);
break;
case "HTAudioIn":
updateChannel(CODEC);
break;
case "MusicSurroundLevel":
updateChannel(SURROUNDMUSICLEVEL);
break;
Expand Down Expand Up @@ -881,6 +884,12 @@ protected void updateChannel(String channelId) {
newState = new DecimalType(value);
}
break;
case CODEC:
value = getCodec();
if (value != null) {
newState = new StringType(value);
}
break;
case HEIGHTLEVEL:
value = getHeightLevel();
if (value != null) {
Expand Down Expand Up @@ -1468,6 +1477,51 @@ public boolean isOutputLevelFixed() {
return stateMap.get("MusicSurroundLevel");
}

public @Nullable String getCodec() {
String codec = stateMap.get("HTAudioIn");
switch (codec) {
lolodomo marked this conversation as resolved.
Show resolved Hide resolved
morph166955 marked this conversation as resolved.
Show resolved Hide resolved
case "0":
codec = "noSignal";
break;
case "21":
codec = "noSignal";
break;
morph166955 marked this conversation as resolved.
Show resolved Hide resolved
case "22":
codec = "silence";
break;
case "32":
codec = "DTS";
break;
case "59":
codec = "dolbyAtmos";
break;
case "63":
codec = "dolbyAtmos";
break;
morph166955 marked this conversation as resolved.
Show resolved Hide resolved
case "33554454":
codec = "silence20";
break;
morph166955 marked this conversation as resolved.
Show resolved Hide resolved
case "33554434":
codec = "DD20";
break;
case "33554494":
codec = "PCM20";
break;
case "84934713":
codec = "DD51";
break;
case "84934714":
codec = "DDPlus51";
break;
case "84934718":
codec = "PCM51";
break;
default:
codec = "Unknown - " + codec;
}
return codec;
}

public @Nullable String getSubwooferEnabled() {
return stateMap.get("SubEnabled");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<channel id="currenttrackuri" typeId="currenttrackuri"/>
<!-- Extended SONOS channels -->
<channel id="analoglinein" typeId="linein"/>
<channel id="codec" typeId="codec"/>
<channel id="publicanalogaddress" typeId="publicaddress"/>
<channel id="digitallinein" typeId="linein"/>
<channel id="publicdigitaladdress" typeId="publicaddress"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<channel id="currenttransporturi" typeId="currenttransporturi"/>
<channel id="currenttrackuri" typeId="currenttrackuri"/>
<!-- Extended SONOS channels -->
<channel id="codec" typeId="codec"/>
<channel id="linein" typeId="linein"/>
<channel id="microphone" typeId="microphone"/>
<channel id="nightmode" typeId="nightmode"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<channel id="alarmproperties" typeId="alarmproperties"/>
<channel id="alarmrunning" typeId="alarmrunning"/>
<channel id="bass" typeId="bass"/>
<channel id="codec" typeId="codec"/>
lolodomo marked this conversation as resolved.
Show resolved Hide resolved
<channel id="control" typeId="system.media-control"/>
<channel id="currentalbum" typeId="currentalbum"/>
<channel id="currentalbumart" typeId="currentalbumart"/>
Expand Down Expand Up @@ -57,6 +58,7 @@
<channel id="currenttransporturi" typeId="currenttransporturi"/>
<channel id="currenttrackuri" typeId="currenttrackuri"/>
<!-- Extended SONOS channels -->
<channel id="codec" typeId="codec"/>
<channel id="linein" typeId="linein"/>
<channel id="nightmode" typeId="nightmode"/>
<channel id="speechenhancement" typeId="speechenhancement"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<channel id="currenttransporturi" typeId="currenttransporturi"/>
<channel id="currenttrackuri" typeId="currenttrackuri"/>
<!-- Extended SONOS channels -->
<channel id="codec" typeId="codec"/>
<channel id="linein" typeId="linein"/>
<channel id="microphone" typeId="microphone"/>
<channel id="nightmode" typeId="nightmode"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<channel id="currenttransporturi" typeId="currenttransporturi"/>
<channel id="currenttrackuri" typeId="currenttrackuri"/>
<!-- Extended SONOS channels -->
<channel id="codec" typeId="codec"/>
<channel id="linein" typeId="linein"/>
<channel id="nightmode" typeId="nightmode"/>
<channel id="speechenhancement" typeId="speechenhancement"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<channel id="currenttransporturi" typeId="currenttransporturi"/>
<channel id="currenttrackuri" typeId="currenttrackuri"/>
<!-- Extended SONOS channels -->
<channel id="codec" typeId="codec"/>
<channel id="linein" typeId="linein"/>
<channel id="nightmode" typeId="nightmode"/>
<channel id="speechenhancement" typeId="speechenhancement"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,26 @@
<description>Suppress all songs from the current queue</description>
</channel-type>

<channel-type id="codec" advanced="true">
<item-type>String</item-type>
<label>Codec</label>
<description>Name of codec currently being decoded</description>
<state readOnly="true">
<options>
morph166955 marked this conversation as resolved.
Show resolved Hide resolved
<option value="noSignal">No Signal</option>
<option value="silence">Silence</option>
<option value="silence20">Silence 2.0</option>
morph166955 marked this conversation as resolved.
Show resolved Hide resolved
<option value="DTS">DTS</option>
<option value="dolbyAtmos">Dolby Atmos</option>
<option value="DD20">Dolby Digital 2.0</option>
<option value="PCM20">Dolby Multichannel PCM 2.0</option>
<option value="DD51">Dolby Digital 5.1</option>
<option value="DDPlus51">Dolby Digital Plus 5.1</option>
<option value="PCM51">Dolby Multichannel PCM 5.1</option>
</options>
</state>
</channel-type>

<channel-type id="coordinator" advanced="true">
<item-type>String</item-type>
<label>Coordinator</label>
Expand Down