]> git.basschouten.com Git - openhab-addons.git/commitdiff
[sonos] Add new channel heightlevel for Sonos ARC / ARC SL (#10759)
authorlolodomo <lg.hc@free.fr>
Fri, 28 May 2021 13:04:14 +0000 (15:04 +0200)
committerGitHub <noreply@github.com>
Fri, 28 May 2021 13:04:14 +0000 (15:04 +0200)
Fix #9874

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
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/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/channels.xml

index fb19d071fbe45575dd5dff6d90595c07af8827ba..ce04191f2e673a6e08aeb1c4f212ba65da9d38e8 100644 (file)
@@ -69,6 +69,7 @@ The devices support the following channels:
 | currenttrackuri     | String    | R           | URI of the current track                                                                                                                                  | all                                  |
 | currenttransporturi | String    | R           | URI of the current AV transport                                                                                                                           | all                                  |
 | favorite            | String    | W           | Play the given favorite entry. The favorite entry has to be predefined in the Sonos Controller app                                                        | all                                  |
+| heightlevel         | Number    | RW          | Set or get the height level adjustment (value in range -10 / 10)                                                                                          | Arc, Arc SL                          |
 | led                 | Switch    | RW          | Set or get the status of the white LED on the front of the Zone Player                                                                                    | all                                  |
 | linein              | Switch    | R           | Indicator set to ON when the line-in of the Zone Player is connected                                                                                      | PLAY5, CONNECT, CONNECTAMP, PLAYBAR, PLAYBASE, Beam, Port |
 | analoglinein        | Switch    | R           | Indicator set to ON when the analog line-in of the Zone Player is connected                                                                               | Amp                                  |
index bdde548775fe5335928fd8ed25acf7d35d36875b..b54dcdf9e1864b02bc4bd2a73bb376ea7cffb23c 100644 (file)
@@ -98,6 +98,7 @@ public class SonosBindingConstants {
     public static final String CURRENTTRACKURI = "currenttrackuri";
     public static final String CURRENTTRANSPORTURI = "currenttransporturi";
     public static final String FAVORITE = "favorite";
+    public static final String HEIGHTLEVEL = "heightlevel";
     public static final String LED = "led";
     public static final String LINEIN = "linein";
     public static final String ANALOGLINEIN = "analoglinein";
index c152c59b5bd3bd556ae9257ec21d63ac2ba552e7..735a752586f0bc05ec0f937842164397ad8d7856 100644 (file)
@@ -877,6 +877,7 @@ public class SonosXMLParser {
                 case "SurroundMode":
                 case "SurroundLevel":
                 case "MusicSurroundLevel":
+                case "HeightChannelLevel":
                     val = attributes == null ? null : attributes.getValue("val");
                     if (val != null) {
                         changes.put(qName, val);
index e0043c2085cb0afc939d98df019e243dfd5f9ac1..10a52c983d380873e62c571c6f2e16b8acbc91dc 100644 (file)
@@ -162,6 +162,8 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici
     private static final int MAX_SUBWOOFER_GAIN = 15;
     private static final int MIN_SURROUND_LEVEL = -15;
     private static final int MAX_SURROUND_LEVEL = 15;
+    private static final int MIN_HEIGHT_LEVEL = -10;
+    private static final int MAX_HEIGHT_LEVEL = 10;
 
     private final Logger logger = LoggerFactory.getLogger(ZonePlayerHandler.class);
 
@@ -338,6 +340,9 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici
                 case SURROUNDTVLEVEL:
                     setSurroundTvLevel(command);
                     break;
+                case HEIGHTLEVEL:
+                    setHeightLevel(command);
+                    break;
                 case ADD:
                     addMember(command);
                     break;
@@ -596,6 +601,9 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici
                 case "MusicSurroundLevel":
                     updateChannel(SURROUNDMUSICLEVEL);
                     break;
+                case "HeightChannelLevel":
+                    updateChannel(HEIGHTLEVEL);
+                    break;
                 case "NightMode":
                     updateChannel(NIGHTMODE);
                     break;
@@ -873,6 +881,12 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici
                     newState = new DecimalType(value);
                 }
                 break;
+            case HEIGHTLEVEL:
+                value = getHeightLevel();
+                if (value != null) {
+                    newState = new DecimalType(value);
+                }
+                break;
             case NIGHTMODE:
                 value = getNightMode();
                 if (value != null) {
@@ -1462,6 +1476,10 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici
         return stateMap.get("SubGain");
     }
 
+    public @Nullable String getHeightLevel() {
+        return stateMap.get("HeightChannelLevel");
+    }
+
     public @Nullable String getTransportState() {
         return stateMap.get("TransportState");
     }
@@ -2079,6 +2097,10 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici
                 MAX_SURROUND_LEVEL);
     }
 
+    public void setHeightLevel(Command command) {
+        setEqualizerNumericSetting(command, "HeightChannelLevel", getHeightLevel(), MIN_HEIGHT_LEVEL, MAX_HEIGHT_LEVEL);
+    }
+
     public void setNightMode(Command command) {
         setEqualizerBooleanSetting(command, "NightMode");
     }
index 571c3ae23ce4c13b92231a1a14caf65b84f8c43d..b3ac01b72ee5275dd41a19fe4258005761f9e454 100644 (file)
@@ -67,6 +67,7 @@
                        <channel id="surroundmusicmode" typeId="surroundmusicmode"/>
                        <channel id="surroundmusiclevel" typeId="surroundmusiclevel"/>
                        <channel id="surroundtvlevel" typeId="surroundtvlevel"/>
+                       <channel id="heightlevel" typeId="heightlevel"/>
                </channels>
 
                <properties>
index 38103bf8ae4e6b741f195edba8a5f9c042fc9624..790560447166f8b20a7163f7c8499fd1374f4041 100644 (file)
@@ -66,6 +66,7 @@
                        <channel id="surroundmusicmode" typeId="surroundmusicmode"/>
                        <channel id="surroundmusiclevel" typeId="surroundmusiclevel"/>
                        <channel id="surroundtvlevel" typeId="surroundtvlevel"/>
+                       <channel id="heightlevel" typeId="heightlevel"/>
                </channels>
 
                <properties>
index 1409838e48d86b6e1c0bb9a166143a2d188e0694..1f27fc47a0d4c93a5f5fa325027286fa7d602a5d 100644 (file)
                <description>Play the given favorite entry. The favorite entry has to be predefined in the Sonos Controller app</description>
        </channel-type>
 
+       <channel-type id="heightlevel" advanced="true">
+               <item-type>Number</item-type>
+               <label>Height Level</label>
+               <description>Set or get the height level adjustment</description>
+               <state min="-10" max="10" step="1" readOnly="false" pattern="%d"/>
+       </channel-type>
+
        <channel-type id="led" advanced="true">
                <item-type>Switch</item-type>
                <label>Led</label>