From 77ed54d338b83eeff03ee2656159ea4c9c83c6b6 Mon Sep 17 00:00:00 2001 From: lolodomo Date: Sat, 16 Apr 2022 14:23:20 +0200 Subject: [PATCH] [sonos] Support added for models Five and Roam SL (#12607) Fix #12596 Fix #12610 Signed-off-by: Laurent Garnier --- bundles/org.openhab.binding.sonos/README.md | 12 ++-- .../sonos/internal/SonosBindingConstants.java | 28 ++++---- .../ZonePlayerDiscoveryParticipant.java | 3 + .../resources/OH-INF/i18n/sonos.properties | 23 ++++-- .../src/main/resources/OH-INF/thing/Five.xml | 72 +++++++++++++++++++ .../main/resources/OH-INF/thing/RoamSL.xml | 69 ++++++++++++++++++ 6 files changed, 181 insertions(+), 26 deletions(-) create mode 100644 bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/Five.xml create mode 100644 bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/RoamSL.xml diff --git a/bundles/org.openhab.binding.sonos/README.md b/bundles/org.openhab.binding.sonos/README.md index bf7b8d92c..9c3f7a669 100644 --- a/bundles/org.openhab.binding.sonos/README.md +++ b/bundles/org.openhab.binding.sonos/README.md @@ -11,11 +11,11 @@ This happens because of a TTL=1 for ALIVE packets send by Sonos devices, resulti ## Supported Things All available Sonos (playback) devices are supported by this binding. -This includes the One, One SL, Move, Play:1, Play:3, Play:5, Connect, Connect:Amp, Port, Amp, SYMFONISK, Playbar, Playbase, Beam, Arc, Arc SL and Sub. +This includes the One, One SL, Move, Roam, Roam SL, Play:1, Play:3, Play:5, Five, Connect, Connect:Amp, Port, Amp, SYMFONISK, Playbar, Playbase, Beam, Arc, Arc SL and Sub. The Bridge and Boost are not supported, but these devices do only have an auxiliary role in the Sonos network and do not have any playback capability. All supported Sonos devices are registered as an audio sink in the framework. -When being defined in a \*.things file, the specific thing types One, OneSL, Move, PLAY1, PLAY3, PLAY5, SYMFONISK, PLAYBAR, PLAYBASE, Beam, Arc, ArcSL, CONNECT, CONNECTAMP, Port and Amp should be used. +When being defined in a \*.things file, the specific thing types One, OneSL, Move, Roam, RoamSL, PLAY1, PLAY3, PLAY5, Five, SYMFONISK, PLAYBAR, PLAYBASE, Beam, Arc, ArcSL, CONNECT, CONNECTAMP, Port and Amp should be used. Please note that these thing types are case sensitive (you need to define them **exactly as stated above**). @@ -55,8 +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 | +| batterycharging | Switch | R | Indicator set to ON when the battery is charging | Move, Roam, RoamSL | +| batterylevel | Number | R | Current battery level | Move, Roam, RoamSL | | 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 | @@ -72,12 +72,12 @@ The devices support the following channels: | 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 | +| linein | Switch | R | Indicator set to ON when the line-in of the Zone Player is connected | PLAY5, Five, 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 | | 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 | +| microphone | Switch | R | Indicator set to ON when the microphone is enabled | Arc, Beam, Move, One, Roam | | 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 f29780b00..e000f3895 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 @@ -14,8 +14,6 @@ package org.openhab.binding.sonos.internal; import java.util.HashSet; import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.core.thing.ThingTypeUID; @@ -41,6 +39,7 @@ public class SonosBindingConstants { public static final ThingTypeUID PLAY1_THING_TYPE_UID = new ThingTypeUID(BINDING_ID, "PLAY1"); public static final ThingTypeUID PLAY3_THING_TYPE_UID = new ThingTypeUID(BINDING_ID, "PLAY3"); public static final ThingTypeUID PLAY5_THING_TYPE_UID = new ThingTypeUID(BINDING_ID, "PLAY5"); + public static final ThingTypeUID FIVE_THING_TYPE_UID = new ThingTypeUID(BINDING_ID, "Five"); public static final ThingTypeUID PLAYBAR_THING_TYPE_UID = new ThingTypeUID(BINDING_ID, "PLAYBAR"); public static final ThingTypeUID PLAYBASE_THING_TYPE_UID = new ThingTypeUID(BINDING_ID, "PLAYBASE"); public static final ThingTypeUID BEAM_THING_TYPE_UID = new ThingTypeUID(BINDING_ID, "Beam"); @@ -53,25 +52,24 @@ public class SonosBindingConstants { public static final ThingTypeUID ARC_SL_THING_TYPE_UID = new ThingTypeUID(BINDING_ID, "ArcSL"); public static final ThingTypeUID MOVE_THING_TYPE_UID = new ThingTypeUID(BINDING_ID, "Move"); public static final ThingTypeUID ROAM_THING_TYPE_UID = new ThingTypeUID(BINDING_ID, "Roam"); + public static final ThingTypeUID ROAM_SL_THING_TYPE_UID = new ThingTypeUID(BINDING_ID, "RoamSL"); public static final ThingTypeUID ZONEPLAYER_THING_TYPE_UID = new ThingTypeUID(BINDING_ID, "zoneplayer"); - public static final Set WITH_LINEIN_THING_TYPES_UIDS = Stream.of(PLAY5_THING_TYPE_UID, - PLAYBAR_THING_TYPE_UID, PLAYBASE_THING_TYPE_UID, BEAM_THING_TYPE_UID, CONNECT_THING_TYPE_UID, - CONNECTAMP_THING_TYPE_UID, PORT_THING_TYPE_UID, ARC_THING_TYPE_UID, ARC_SL_THING_TYPE_UID) - .collect(Collectors.toSet()); + public static final Set WITH_LINEIN_THING_TYPES_UIDS = Set.of(PLAY5_THING_TYPE_UID, + FIVE_THING_TYPE_UID, PLAYBAR_THING_TYPE_UID, PLAYBASE_THING_TYPE_UID, BEAM_THING_TYPE_UID, + CONNECT_THING_TYPE_UID, CONNECTAMP_THING_TYPE_UID, PORT_THING_TYPE_UID, ARC_THING_TYPE_UID, + ARC_SL_THING_TYPE_UID); - public static final Set WITH_ANALOG_LINEIN_THING_TYPES_UIDS = Stream.of(AMP_THING_TYPE_UID) - .collect(Collectors.toSet()); + public static final Set WITH_ANALOG_LINEIN_THING_TYPES_UIDS = Set.of(AMP_THING_TYPE_UID); - public static final Set WITH_DIGITAL_LINEIN_THING_TYPES_UIDS = Stream.of(AMP_THING_TYPE_UID) - .collect(Collectors.toSet()); + public static final Set WITH_DIGITAL_LINEIN_THING_TYPES_UIDS = Set.of(AMP_THING_TYPE_UID); - public static final Set SUPPORTED_KNOWN_THING_TYPES_UIDS = Stream.of(ONE_THING_TYPE_UID, + public static final Set SUPPORTED_KNOWN_THING_TYPES_UIDS = Set.of(ONE_THING_TYPE_UID, ONE_SL_THING_TYPE_UID, PLAY1_THING_TYPE_UID, PLAY3_THING_TYPE_UID, PLAY5_THING_TYPE_UID, - PLAYBAR_THING_TYPE_UID, PLAYBASE_THING_TYPE_UID, BEAM_THING_TYPE_UID, CONNECT_THING_TYPE_UID, - CONNECTAMP_THING_TYPE_UID, PORT_THING_TYPE_UID, AMP_THING_TYPE_UID, SYMFONISK_THING_TYPE_UID, - ARC_THING_TYPE_UID, ARC_SL_THING_TYPE_UID, MOVE_THING_TYPE_UID, ROAM_THING_TYPE_UID) - .collect(Collectors.toSet()); + FIVE_THING_TYPE_UID, PLAYBAR_THING_TYPE_UID, PLAYBASE_THING_TYPE_UID, BEAM_THING_TYPE_UID, + CONNECT_THING_TYPE_UID, CONNECTAMP_THING_TYPE_UID, PORT_THING_TYPE_UID, AMP_THING_TYPE_UID, + SYMFONISK_THING_TYPE_UID, ARC_THING_TYPE_UID, ARC_SL_THING_TYPE_UID, MOVE_THING_TYPE_UID, + ROAM_THING_TYPE_UID, ROAM_SL_THING_TYPE_UID); public static final Set SUPPORTED_THING_TYPES_UIDS = new HashSet<>(SUPPORTED_KNOWN_THING_TYPES_UIDS); static { diff --git a/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/discovery/ZonePlayerDiscoveryParticipant.java b/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/discovery/ZonePlayerDiscoveryParticipant.java index 654a2ce6f..805bded37 100644 --- a/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/discovery/ZonePlayerDiscoveryParticipant.java +++ b/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/discovery/ZonePlayerDiscoveryParticipant.java @@ -95,6 +95,9 @@ public class ZonePlayerDiscoveryParticipant implements UpnpDiscoveryParticipant case "Arc SL": modelName = "ArcSL"; break; + case "Roam SL": + modelName = "RoamSL"; + break; case "Sub": // The Sonos Sub is ignored ignored = true; diff --git a/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/i18n/sonos.properties b/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/i18n/sonos.properties index 944f48f04..14c140686 100644 --- a/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/i18n/sonos.properties +++ b/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/i18n/sonos.properties @@ -1,12 +1,17 @@ # binding + binding.sonos.name = Sonos Binding binding.sonos.description = This is the binding for the Sonos multi-room audio system. -binding.config.sonos.opmlUrl.label = OPML Service URL -binding.config.sonos.opmlUrl.description = URL for the OPML/tunein.com service + +# binding config + binding.config.sonos.callbackUrl.label = Callback URL binding.config.sonos.callbackUrl.description = URL to use for playing notification sounds, e.g. http://192.168.0.2:8080 +binding.config.sonos.opmlUrl.label = OPML Service URL +binding.config.sonos.opmlUrl.description = URL for the OPML/tunein.com service # thing types + thing-type.sonos.Amp.label = Amp thing-type.sonos.Amp.description = Represents SONOS Amp amplifier thing-type.sonos.Arc.label = Arc @@ -19,6 +24,8 @@ thing-type.sonos.CONNECT.label = CONNECT thing-type.sonos.CONNECT.description = Represents SONOS CONNECT connector thing-type.sonos.CONNECTAMP.label = CONNECT AMP thing-type.sonos.CONNECTAMP.description = Represents SONOS CONNECT:AMP amplifier +thing-type.sonos.Five.label = Five +thing-type.sonos.Five.description = Represents SONOS Five speaker thing-type.sonos.Move.label = Move thing-type.sonos.Move.description = Represents SONOS Move speaker thing-type.sonos.One.label = One @@ -39,21 +46,26 @@ thing-type.sonos.Port.label = Port thing-type.sonos.Port.description = Represents SONOS Port connector thing-type.sonos.Roam.label = Roam thing-type.sonos.Roam.description = Represents SONOS Roam speaker +thing-type.sonos.RoamSL.label = Roam SL +thing-type.sonos.RoamSL.description = Represents SONOS Roam SL speaker thing-type.sonos.SYMFONISK.label = SYMFONISK thing-type.sonos.SYMFONISK.description = Represents IKEA SYMFONISK speaker thing-type.sonos.zoneplayer.label = Zone Player thing-type.sonos.zoneplayer.description = The Zone Player represents a Sonos Zone Player which is not known to this binding -thing-type.config.sonos.zoneplayer.udn.label = Unique Device Name -thing-type.config.sonos.zoneplayer.udn.description = The UDN identifies the Sonos device. +# thing types config + thing-type.config.sonos.zoneplayer.notificationTimeout.label = Notification Timeout thing-type.config.sonos.zoneplayer.notificationTimeout.description = Specifies the amount of time in seconds for which the notification sound will be played thing-type.config.sonos.zoneplayer.notificationVolume.label = Notification Sound Volume thing-type.config.sonos.zoneplayer.notificationVolume.description = Specifies the volume in percent applied to a notification sound thing-type.config.sonos.zoneplayer.refresh.label = Refresh Interval thing-type.config.sonos.zoneplayer.refresh.description = Specifies the refresh interval in seconds +thing-type.config.sonos.zoneplayer.udn.label = Unique Device Name +thing-type.config.sonos.zoneplayer.udn.description = The UDN identifies the Sonos device. # channel types + channel-type.sonos.add.label = Add channel-type.sonos.add.description = Add the given Sonos device to the group of this Sonos device channel-type.sonos.alarm.label = Set Alarm @@ -181,7 +193,8 @@ channel-type.sonos.batterycharging.description = Indicator set to ON when the ba channel-type.sonos.microphone.label = Microphone channel-type.sonos.microphone.description = Indicator set to ON when the microphone is enabled -# Thing status descriptions +# thing status descriptions + offline.conf-error-missing-udn = The parameter "Unique Device Name" must be configured. offline.upnp-device-not-registered = The UPnP device {0} is not yet registered. offline.not-available-on-network = The Sonos player {0} is not available in local network. diff --git a/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/Five.xml b/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/Five.xml new file mode 100644 index 000000000..ece79fcc1 --- /dev/null +++ b/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/Five.xml @@ -0,0 +1,72 @@ + + + + + + + Represents SONOS Five speaker + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SONOS + Five + + + udn + + + + diff --git a/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/RoamSL.xml b/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/RoamSL.xml new file mode 100644 index 000000000..9bc6853a4 --- /dev/null +++ b/bundles/org.openhab.binding.sonos/src/main/resources/OH-INF/thing/RoamSL.xml @@ -0,0 +1,69 @@ + + + + + + + Represents SONOS Roam SL speaker + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SONOS + Roam SL + + + udn + + + +