]> git.basschouten.com Git - openhab-addons.git/commitdiff
[sonos] Add new channel codec for several models (#10979)
authormorph166955 <53797132+morph166955@users.noreply.github.com>
Sun, 25 Jul 2021 18:29:35 +0000 (13:29 -0500)
committerGitHub <noreply@github.com>
Sun, 25 Jul 2021 18:29:35 +0000 (20:29 +0200)
Signed-off-by: Ben Rosenblum <rosenblumb@gmail.com>
bundles/org.openhab.binding.sonos/README.md
bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/SonosBindingConstants.java
bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/SonosXMLParser.java
bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/handler/ZonePlayerHandler.java
bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/Amp.xml
bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/Arc.xml
bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/ArcSL.xml
bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/Beam.xml
bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/PLAYBAR.xml
bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/PLAYBASE.xml
bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/channels.xml

index ce04191f2e673a6e08aeb1c4f212ba65da9d38e8..bf7b8d92c763307beafef8f5cd48fd9bfa840c7f 100644 (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                                  |
index b54dcdf9e1864b02bc4bd2a73bb376ea7cffb23c..d1efabe517b2e72f5d0c4729116e2295b22865c5 100644 (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";
index 735a752586f0bc05ec0f937842164397ad8d7856..90f0358c7c263efed5120856e249ef82bf7b8e4a 100644 (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");
index 10a52c983d380873e62c571c6f2e16b8acbc91dc..822f09078fd0ff821c21260a02ea9012e4b9c76e 100644 (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");
     }
index 7709e906e74f0653ecf0d1392ae3c2611f8aa37a..1c30cd651c5c7e0455ef4008797ceb76d56eebd0 100644 (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"/>
index b3ac01b72ee5275dd41a19fe4258005761f9e454..0ddcc4444e4a057a2c86968c1ffc3b2d3385aedf 100644 (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"/>
index 790560447166f8b20a7163f7c8499fd1374f4041..2317fbd72e3970bea44d27d4d6acdc5690845478 100644 (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"/>
index 63eab8b1c3f9348e2a8c769c6873007e14b35b34..90f06a7c4287ce1ab6570e796da0b3534c54c2d1 100644 (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"/>
index f4e375ea8b0773bc431e64b352dcca49999edf85..0b5aedab8d9d7da47079205b5829fe0db6fe1741 100644 (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"/>
index 2e925d2808f90f4a1b9388ae6dc03c9182dd8b6d..a4d2692ad72bb0592b6afe3fd1edad0a48583631 100644 (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"/>
index 1f27fc47a0d4c93a5f5fa325027286fa7d602a5d..f8a6110dffaa2ffe92f8e6070735dcfd2e2e2f11 100644 (file)
                <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>