[sonos] Add new channel heightlevel for Sonos ARC / ARC SL (#10759)

Fix #9874

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
lolodomo 2021-05-28 15:04:14 +02:00 committed by GitHub
parent a736a2cafd
commit 9bf194ad39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 34 additions and 0 deletions

View File

@ -69,6 +69,7 @@ The devices support the following channels:
| currenttrackuri | String | R | URI of the current track | all | | currenttrackuri | String | R | URI of the current track | all |
| currenttransporturi | String | R | URI of the current AV transport | 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 | | 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 | | 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 | | 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 | | analoglinein | Switch | R | Indicator set to ON when the analog line-in of the Zone Player is connected | Amp |

View File

@ -98,6 +98,7 @@ public class SonosBindingConstants {
public static final String CURRENTTRACKURI = "currenttrackuri"; public static final String CURRENTTRACKURI = "currenttrackuri";
public static final String CURRENTTRANSPORTURI = "currenttransporturi"; public static final String CURRENTTRANSPORTURI = "currenttransporturi";
public static final String FAVORITE = "favorite"; public static final String FAVORITE = "favorite";
public static final String HEIGHTLEVEL = "heightlevel";
public static final String LED = "led"; public static final String LED = "led";
public static final String LINEIN = "linein"; public static final String LINEIN = "linein";
public static final String ANALOGLINEIN = "analoglinein"; public static final String ANALOGLINEIN = "analoglinein";

View File

@ -877,6 +877,7 @@ public class SonosXMLParser {
case "SurroundMode": case "SurroundMode":
case "SurroundLevel": case "SurroundLevel":
case "MusicSurroundLevel": case "MusicSurroundLevel":
case "HeightChannelLevel":
val = attributes == null ? null : attributes.getValue("val"); val = attributes == null ? null : attributes.getValue("val");
if (val != null) { if (val != null) {
changes.put(qName, val); changes.put(qName, val);

View File

@ -162,6 +162,8 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici
private static final int MAX_SUBWOOFER_GAIN = 15; private static final int MAX_SUBWOOFER_GAIN = 15;
private static final int MIN_SURROUND_LEVEL = -15; private static final int MIN_SURROUND_LEVEL = -15;
private static final int MAX_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); private final Logger logger = LoggerFactory.getLogger(ZonePlayerHandler.class);
@ -338,6 +340,9 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici
case SURROUNDTVLEVEL: case SURROUNDTVLEVEL:
setSurroundTvLevel(command); setSurroundTvLevel(command);
break; break;
case HEIGHTLEVEL:
setHeightLevel(command);
break;
case ADD: case ADD:
addMember(command); addMember(command);
break; break;
@ -596,6 +601,9 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici
case "MusicSurroundLevel": case "MusicSurroundLevel":
updateChannel(SURROUNDMUSICLEVEL); updateChannel(SURROUNDMUSICLEVEL);
break; break;
case "HeightChannelLevel":
updateChannel(HEIGHTLEVEL);
break;
case "NightMode": case "NightMode":
updateChannel(NIGHTMODE); updateChannel(NIGHTMODE);
break; break;
@ -873,6 +881,12 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici
newState = new DecimalType(value); newState = new DecimalType(value);
} }
break; break;
case HEIGHTLEVEL:
value = getHeightLevel();
if (value != null) {
newState = new DecimalType(value);
}
break;
case NIGHTMODE: case NIGHTMODE:
value = getNightMode(); value = getNightMode();
if (value != null) { if (value != null) {
@ -1462,6 +1476,10 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici
return stateMap.get("SubGain"); return stateMap.get("SubGain");
} }
public @Nullable String getHeightLevel() {
return stateMap.get("HeightChannelLevel");
}
public @Nullable String getTransportState() { public @Nullable String getTransportState() {
return stateMap.get("TransportState"); return stateMap.get("TransportState");
} }
@ -2079,6 +2097,10 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici
MAX_SURROUND_LEVEL); MAX_SURROUND_LEVEL);
} }
public void setHeightLevel(Command command) {
setEqualizerNumericSetting(command, "HeightChannelLevel", getHeightLevel(), MIN_HEIGHT_LEVEL, MAX_HEIGHT_LEVEL);
}
public void setNightMode(Command command) { public void setNightMode(Command command) {
setEqualizerBooleanSetting(command, "NightMode"); setEqualizerBooleanSetting(command, "NightMode");
} }

View File

@ -67,6 +67,7 @@
<channel id="surroundmusicmode" typeId="surroundmusicmode"/> <channel id="surroundmusicmode" typeId="surroundmusicmode"/>
<channel id="surroundmusiclevel" typeId="surroundmusiclevel"/> <channel id="surroundmusiclevel" typeId="surroundmusiclevel"/>
<channel id="surroundtvlevel" typeId="surroundtvlevel"/> <channel id="surroundtvlevel" typeId="surroundtvlevel"/>
<channel id="heightlevel" typeId="heightlevel"/>
</channels> </channels>
<properties> <properties>

View File

@ -66,6 +66,7 @@
<channel id="surroundmusicmode" typeId="surroundmusicmode"/> <channel id="surroundmusicmode" typeId="surroundmusicmode"/>
<channel id="surroundmusiclevel" typeId="surroundmusiclevel"/> <channel id="surroundmusiclevel" typeId="surroundmusiclevel"/>
<channel id="surroundtvlevel" typeId="surroundtvlevel"/> <channel id="surroundtvlevel" typeId="surroundtvlevel"/>
<channel id="heightlevel" typeId="heightlevel"/>
</channels> </channels>
<properties> <properties>

View File

@ -100,6 +100,13 @@
<description>Play the given favorite entry. The favorite entry has to be predefined in the Sonos Controller app</description> <description>Play the given favorite entry. The favorite entry has to be predefined in the Sonos Controller app</description>
</channel-type> </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"> <channel-type id="led" advanced="true">
<item-type>Switch</item-type> <item-type>Switch</item-type>
<label>Led</label> <label>Led</label>