From 0f8f72dd2edf0c5ae8efe34f168d7a2f8ebefe4b Mon Sep 17 00:00:00 2001 From: lolodomo Date: Sun, 31 Jan 2021 22:49:46 +0100 Subject: [PATCH] [sonos] Add new channel for microphone (Arc, Beam, Move, One) (#9999) Signed-off-by: Laurent Garnier --- bundles/org.openhab.binding.sonos/README.md | 1 + .../sonos/internal/SonosBindingConstants.java | 1 + .../sonos/internal/handler/ZonePlayerHandler.java | 13 +++++++++++++ .../src/main/resources/OH-INF/thing/Arc.xml | 1 + .../src/main/resources/OH-INF/thing/Beam.xml | 1 + .../src/main/resources/OH-INF/thing/Move.xml | 1 + .../src/main/resources/OH-INF/thing/One.xml | 2 ++ .../src/main/resources/OH-INF/thing/channels.xml | 8 ++++++++ 8 files changed, 28 insertions(+) diff --git a/bundles/org.openhab.binding.sonos/README.md b/bundles/org.openhab.binding.sonos/README.md index b706f3260..fb19d071f 100644 --- a/bundles/org.openhab.binding.sonos/README.md +++ b/bundles/org.openhab.binding.sonos/README.md @@ -75,6 +75,7 @@ The devices support the following channels: | digitallinein | Switch | R | Indicator set to ON when the digital line-in of the Zone Player is connected | Amp | | localcoordinator | Switch | R | Indicator set to ON if the this Zone Player is the Zone Group Coordinator | all | | loudness | Switch | RW | Enable or disable the loudness | all | +| microphone | Switch | R | Indicator set to ON when the microphone is enabled | Arc, Beam, Move, One | | mute | Switch | RW | Set or get the mute state of the master volume of the Zone Player | all | | nightmode | Switch | RW | Enable or disable the night mode feature | PLAYBAR, PLAYBASE, Beam, Amp | | notificationsound | String | W | Play a notification sound by a given URI | all | diff --git a/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/SonosBindingConstants.java b/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/SonosBindingConstants.java index b437c0715..66797f1a0 100644 --- a/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/SonosBindingConstants.java +++ b/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/SonosBindingConstants.java @@ -103,6 +103,7 @@ public class SonosBindingConstants { public static final String DIGITALLINEIN = "digitallinein"; public static final String LOCALCOORDINATOR = "localcoordinator"; public static final String LOUDNESS = "loudness"; + public static final String MICROPHONE = "microphone"; public static final String MUTE = "mute"; public static final String NIGHTMODE = "nightmode"; public static final String NOTIFICATIONSOUND = "notificationsound"; diff --git a/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/handler/ZonePlayerHandler.java b/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/handler/ZonePlayerHandler.java index e4b59fbb4..5e8f0e06e 100644 --- a/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/handler/ZonePlayerHandler.java +++ b/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/handler/ZonePlayerHandler.java @@ -693,6 +693,9 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici updateChannel(BATTERYCHARGING); updateChannel(BATTERYLEVEL); break; + case "MicEnabled": + updateChannel(MICROPHONE); + break; default: break; } @@ -973,6 +976,12 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici newState = new DecimalType(value); } break; + case MICROPHONE: + value = getMicEnabled(); + if (value != null) { + newState = OnOffType.from(value); + } + break; default: newState = null; break; @@ -2143,6 +2152,10 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici return mode; } + public @Nullable String getMicEnabled() { + return stateMap.get("MicEnabled"); + } + protected void updatePlayMode(String playMode) { executeAction(SERVICE_AV_TRANSPORT, ACTION_SET_PLAY_MODE, Map.of("InstanceID", "0", "NewPlayMode", playMode)); } diff --git a/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/Arc.xml b/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/Arc.xml index a825d35c0..571c3ae23 100644 --- a/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/Arc.xml +++ b/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/Arc.xml @@ -58,6 +58,7 @@ + diff --git a/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/Beam.xml b/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/Beam.xml index ff6a77977..63eab8b1c 100644 --- a/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/Beam.xml +++ b/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/Beam.xml @@ -58,6 +58,7 @@ + diff --git a/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/Move.xml b/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/Move.xml index 1bca40910..28b1c9cf8 100644 --- a/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/Move.xml +++ b/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/Move.xml @@ -56,6 +56,7 @@ + diff --git a/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/One.xml b/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/One.xml index ccaa8a877..9cae3f68d 100644 --- a/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/One.xml +++ b/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/One.xml @@ -57,6 +57,8 @@ + + diff --git a/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/channels.xml b/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/channels.xml index 6fc4cd4e0..1409838e4 100644 --- a/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/channels.xml +++ b/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/channels.xml @@ -358,4 +358,12 @@ + + + Switch + + Indicator set to ON when the microphone is enabled + + +