mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +01:00
[sonos] Add new channels for battery (Sonos Move) (#9998)
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
parent
fd1caea5aa
commit
024b36a814
@ -55,6 +55,8 @@ The devices support the following channels:
|
||||
| alarmproperties | String | R | Properties of the alarm currently running | all |
|
||||
| alarmrunning | Switch | R | Set to ON if the alarm was triggered | all |
|
||||
| bass | Number | RW | Set or get the bass level adjustment (value in range -10 / 10) | all |
|
||||
| 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 |
|
||||
| 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 |
|
||||
|
@ -83,6 +83,8 @@ public class SonosBindingConstants {
|
||||
public static final String ALARMPROPERTIES = "alarmproperties";
|
||||
public static final String ALARMRUNNING = "alarmrunning";
|
||||
public static final String BASS = "bass";
|
||||
public static final String BATTERYCHARGING = "batterycharging";
|
||||
public static final String BATTERYLEVEL = "batterylevel";
|
||||
public static final String CLEARQUEUE = "clearqueue";
|
||||
public static final String CONTROL = "control";
|
||||
public static final String COORDINATOR = "coordinator";
|
||||
|
@ -689,6 +689,10 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici
|
||||
stateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), RADIO), options);
|
||||
}
|
||||
break;
|
||||
case "MoreInfo":
|
||||
updateChannel(BATTERYCHARGING);
|
||||
updateChannel(BATTERYLEVEL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -957,6 +961,18 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici
|
||||
newState = new StringType(value);
|
||||
}
|
||||
break;
|
||||
case BATTERYCHARGING:
|
||||
value = extractInfoFromMoreInfo("BattChg");
|
||||
if (value != null) {
|
||||
newState = OnOffType.from("CHARGING".equalsIgnoreCase(value));
|
||||
}
|
||||
break;
|
||||
case BATTERYLEVEL:
|
||||
value = extractInfoFromMoreInfo("RawBattPct");
|
||||
if (value != null) {
|
||||
newState = new DecimalType(value);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
newState = null;
|
||||
break;
|
||||
@ -3225,4 +3241,18 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici
|
||||
int seconds = Integer.parseInt(units[2]);
|
||||
return 3600 * hours + 60 * minutes + seconds;
|
||||
}
|
||||
|
||||
private @Nullable String extractInfoFromMoreInfo(String searchedInfo) {
|
||||
String value = stateMap.get("MoreInfo");
|
||||
if (value != null) {
|
||||
String[] fields = value.split(",");
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
String[] pair = fields[i].trim().split(":");
|
||||
if (pair.length == 2 && searchedInfo.equalsIgnoreCase(pair[0].trim())) {
|
||||
return pair[1].trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,9 @@
|
||||
<channel id="sleeptimer" typeId="sleeptimer"/>
|
||||
<channel id="currenttransporturi" typeId="currenttransporturi"/>
|
||||
<channel id="currenttrackuri" typeId="currenttrackuri"/>
|
||||
<!-- Extended SONOS channels -->
|
||||
<channel id="batterycharging" typeId="batterycharging"/>
|
||||
<channel id="batterylevel" typeId="system.battery-level"/>
|
||||
</channels>
|
||||
|
||||
<properties>
|
||||
|
@ -350,4 +350,12 @@
|
||||
<description>Play the line-in of the the Zone Player corresponding to the given UIN</description>
|
||||
</channel-type>
|
||||
|
||||
<!-- Extended channels (for SONOS Move only) -->
|
||||
<channel-type id="batterycharging" advanced="true">
|
||||
<item-type>Switch</item-type>
|
||||
<label>Battery Charging</label>
|
||||
<description>Indicator set to ON when the battery is charging</description>
|
||||
<state readOnly="true"/>
|
||||
</channel-type>
|
||||
|
||||
</thing:thing-descriptions>
|
||||
|
Loading…
Reference in New Issue
Block a user