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

Signed-off-by: Ben Rosenblum <rosenblumb@gmail.com>
This commit is contained in:
morph166955 2021-07-25 13:29:35 -05:00 committed by GitHub
parent 24c1691c8b
commit 731e5cf73d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 79 additions and 0 deletions

View File

@ -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 |

View File

@ -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";

View File

@ -876,6 +876,7 @@ public class SonosXMLParser {
case "SurroundEnabled":
case "SurroundMode":
case "SurroundLevel":
case "HTAudioIn":
case "MusicSurroundLevel":
case "HeightChannelLevel":
val = attributes == null ? null : attributes.getValue("val");

View File

@ -598,6 +598,9 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici
case "SurroundLevel":
updateChannel(SURROUNDTVLEVEL);
break;
case "HTAudioIn":
updateChannel(CODEC);
break;
case "MusicSurroundLevel":
updateChannel(SURROUNDMUSICLEVEL);
break;
@ -881,6 +884,12 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici
newState = new DecimalType(value);
}
break;
case CODEC:
value = getCodec();
if (value != null) {
newState = new StringType(value);
}
break;
case HEIGHTLEVEL:
value = getHeightLevel();
if (value != null) {
@ -1468,6 +1477,47 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici
return stateMap.get("MusicSurroundLevel");
}
public @Nullable String getCodec() {
String codec = stateMap.get("HTAudioIn");
if (codec != null) {
switch (codec) {
case "0":
case "21":
codec = "noSignal";
break;
case "22":
case "33554454":
codec = "silence";
break;
case "32":
codec = "DTS";
break;
case "59":
case "63":
codec = "dolbyAtmos";
break;
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");
}

View File

@ -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"/>

View File

@ -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"/>

View File

@ -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"/>

View File

@ -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"/>

View File

@ -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"/>

View File

@ -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"/>

View File

@ -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>
<option value="noSignal">No Signal</option>
<option value="silence">Silence</option>
<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>
<limitToOptions>false</limitToOptions>
</state>
</channel-type>
<channel-type id="coordinator" advanced="true">
<item-type>String</item-type>
<label>Coordinator</label>