Skip to content

Commit

Permalink
[squeezebox] Add LMS favorites channels to server and player (#3190)
Browse files Browse the repository at this point in the history
* Add favoriteList/favoritesPlay channel to Server/Player
* Pass favorites list to players
* Update state options when favorites updated

Signed-off-by: Mark Hilbush <[email protected]>
  • Loading branch information
mhilbush authored and martinvw committed Feb 6, 2018
1 parent 0267561 commit d449969
Show file tree
Hide file tree
Showing 12 changed files with 416 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@

<bridge-type id="squeezeboxserver">
<label>SqueezeBox Server</label>
<description>This is a SqueezeBox Server instance.
</description>
<description>This is a SqueezeBox Server instance.</description>

<channels>
<channel id="favoritesList" typeId="favoritesList" />
</channels>

<config-description>
<parameter name="ipAddress" type="text" required="true">
<label>IP or Host Name</label>
Expand Down Expand Up @@ -44,8 +48,10 @@
<supported-bridge-type-refs>
<bridge-type-ref id="squeezeboxserver" />
</supported-bridge-type-refs>

<label>SqueezeBox Player</label>
<description>This is a SqueezeBox Player instance</description>

<channels>
<channel id="power" typeId="power" />
<channel id="mute" typeId="mute" />
Expand Down Expand Up @@ -73,14 +79,17 @@
<channel id="ircode" typeId="ircode" />
<channel id="numberPlaylistTracks" typeId="numberPlaylistTracks" />
<channel id="notificationSoundVolume" typeId="notificationVolume" />
<channel id="playFavorite" typeId="playFavorite" />
</channels>

<properties>
<property name="vendor">Logitech</property>
<property name="modelId"></property>
<property name="name"></property>
<property name="uid"></property>
<property name="ip"></property>
</properties>

<config-description>
<parameter name="mac" type="text" required="true">
<label>MAC Address</label>
Expand All @@ -89,6 +98,27 @@
</config-description>
</thing-type>

<!-- Favorites -->
<channel-type id="favoritesList">
<item-type>String</item-type>
<label>Favorites List</label>
<description>Comma-separated list of favorites of form favoriteId=favoriteName</description>
<state readOnly="true" pattern="%s"></state>
<config-description>
<parameter name="quoteList" type="boolean" required="true">
<label>Quote Favorites</label>
<description>Wrap the right hand side of the favorites in quotes</description>
<default>false</default>
</parameter>
</config-description>
</channel-type>
<channel-type id="playFavorite">
<item-type>String</item-type>
<label>Play a Favorite</label>
<description>Play favorite by sending command with favoriteId</description>
<state pattern="%s"></state>
</channel-type>

<!-- Commands -->
<channel-type id="power" advanced="true">
<item-type>Switch</item-type>
Expand Down
83 changes: 42 additions & 41 deletions addons/binding/org.openhab.binding.squeezebox/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,41 +1,42 @@
Manifest-Version: 1.0
Bundle-ClassPath: .
Bundle-ManifestVersion: 2
Bundle-Name: SqueezeBox Binding
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-SymbolicName: org.openhab.binding.squeezebox;singleton:=true
Bundle-Vendor: openHAB
Bundle-Version: 2.3.0.qualifier
Export-Package:
org.openhab.binding.squeezebox,
org.openhab.binding.squeezebox.handler
Import-Package:
com.google.gson,
org.apache.commons.lang,
org.eclipse.jdt.annotation;resolution:=optional,
org.eclipse.jetty.client,
org.eclipse.jetty.client.api,
org.eclipse.jetty.client.util,
org.eclipse.jetty.http,
org.eclipse.jetty.util.component,
org.eclipse.smarthome.config.core,
org.eclipse.smarthome.config.discovery,
org.eclipse.smarthome.core.audio,
org.eclipse.smarthome.core.audio.utils,
org.eclipse.smarthome.core.cache,
org.eclipse.smarthome.core.library.types,
org.eclipse.smarthome.core.net,
org.eclipse.smarthome.core.thing,
org.eclipse.smarthome.core.thing.binding,
org.eclipse.smarthome.core.types,
org.eclipse.smarthome.io.net.http,
org.eclipse.smarthome.io.transport.upnp,
org.jupnp,
org.jupnp.model,
org.jupnp.model.meta,
org.jupnp.model.types,
org.openhab.binding.squeezebox,
org.openhab.binding.squeezebox.handler,
org.osgi.framework,
org.slf4j
Service-Component: OSGI-INF/*.xml
Manifest-Version: 1.0
Bundle-ClassPath: .
Bundle-ManifestVersion: 2
Bundle-Name: SqueezeBox Binding
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-SymbolicName: org.openhab.binding.squeezebox;singleton:=true
Bundle-Vendor: openHAB
Bundle-Version: 2.3.0.qualifier
Export-Package:
org.openhab.binding.squeezebox,
org.openhab.binding.squeezebox.handler
Import-Package:
com.google.gson,
org.apache.commons.lang,
org.eclipse.jdt.annotation;resolution:=optional,
org.eclipse.jetty.client,
org.eclipse.jetty.client.api,
org.eclipse.jetty.client.util,
org.eclipse.jetty.http,
org.eclipse.jetty.util.component,
org.eclipse.smarthome.config.core,
org.eclipse.smarthome.config.discovery,
org.eclipse.smarthome.core.audio,
org.eclipse.smarthome.core.audio.utils,
org.eclipse.smarthome.core.cache,
org.eclipse.smarthome.core.library.types,
org.eclipse.smarthome.core.net,
org.eclipse.smarthome.core.thing,
org.eclipse.smarthome.core.thing.binding,
org.eclipse.smarthome.core.thing.type,
org.eclipse.smarthome.core.types,
org.eclipse.smarthome.io.net.http,
org.eclipse.smarthome.io.transport.upnp,
org.jupnp,
org.jupnp.model,
org.jupnp.model.meta,
org.jupnp.model.types,
org.openhab.binding.squeezebox,
org.openhab.binding.squeezebox.handler,
org.osgi.framework,
org.slf4j
Service-Component: OSGI-INF/*.xml
67 changes: 43 additions & 24 deletions addons/binding/org.openhab.binding.squeezebox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,33 +54,50 @@ Bridge squeezebox:squeezeboxserver:myServer [ ipAddress="192.168.1.10", webport=
}
```

## Channels
## Server Channels

The Squeezebox server supports the following channel:

| Channel Type ID | Item Type | Description |
|-------------------------|-----------|----------------------------------------------------------------------------------------|
| favoritesList | String | Comma-separated list of favorite IDs & names, updated whenever list changes on server |

## Player Channels

All devices support some of the following channels:

| Channel Type ID | Item Type | Description | | |
|-------------------------|-----------|----------------------------------------------------------------------------------------|----------------------|---|
| power | Switch | Power on/off your device | | |
| mute | Switch | Mute/unmute your device | | |
| volume | Dimmer | Volume of your device | | |
| stop | Switch | Stop the current title | | |
| control | Player | Control the Zone Player, e.g. play/pause/next/previous/ffward/rewind | | |
| stream | String | Play the given HTTP or file stream (file:// or http://) | | |
| sync | String | Add another player to your device for synchronized playback (other player mac address) | | |
| playListIndex | Number | Playlist Index | | |
| currentPlayingTime | | Number | Current Playing Time | |
| currentPlaylistShuffle | Number | Current playlist shuffle mode (0 No Shuffle, 1 Shuffle Songs, 2 Shuffle Albums) | | |
| currentPlaylistRepeat | Number | Current playlist repeat Mode (0 No Repeat, 1 Repeat Song, 2 Repeat Playlist) | | |
| title | String | Title of the current song | | |
| remotetitle | String | Remote Title (Radio) of the current song | | |
| album | String | Album name of the current song | | |
| artist | String | Artist name of the current song | | |
| year | String | Release year of the current song | | |
| genre | String | Genre name of the current song | | |
| coverartdata | Image | Image data of cover art of the current song | | |
| ircode | String | Received IR code | | |
| numberPlaylistTracks | Number | Number of playlist tracks | | |
| notificationSoundVolume | Dimmer | Volume for playing notifications | | |
| Channel Type ID | Item Type | Description |
|-------------------------|-----------|----------------------------------------------------------------------------------------|
| power | Switch | Power on/off your device |
| mute | Switch | Mute/unmute your device |
| volume | Dimmer | Volume of your device |
| stop | Switch | Stop the current title |
| control | Player | Control the Zone Player, e.g. play/pause/next/previous/ffward/rewind |
| stream | String | Play the given HTTP or file stream (file:// or http://) |
| sync | String | Add another player to your device for synchronized playback (other player mac address) |
| playListIndex | Number | Playlist Index |
| currentPlayingTime | Number | Current Playing Time |
| currentPlaylistShuffle | Number | Current playlist shuffle mode (0 No Shuffle, 1 Shuffle Songs, 2 Shuffle Albums) |
| currentPlaylistRepeat | Number | Current playlist repeat Mode (0 No Repeat, 1 Repeat Song, 2 Repeat Playlist) |
| title | String | Title of the current song |
| remotetitle | String | Remote Title (Radio) of the current song |
| album | String | Album name of the current song |
| artist | String | Artist name of the current song |
| year | String | Release year of the current song |
| genre | String | Genre name of the current song |
| coverartdata | Image | Image data of cover art of the current song |
| ircode | String | Received IR code |
| numberPlaylistTracks | Number | Number of playlist tracks |
| notificationSoundVolume | Dimmer | Volume for playing notifications |
| playFavorite | String | ID of Favorite to play (channel's state options contains available favorites) |

## Playing Favorites

Using the **playFavorite** channel, you can play a favorite from the *Favorites* list on the Logitech Media Server (LMS).
The favorites from the LMS will be populated into the state options of the **playFavorite** channel.
The Selection widget in HABpanel can be used to present the favorites as a choice list.
Selecting from that choice list will play the favorite on the SqueezeBox player.
Currently, only favorites from the root level of the LMS favorites list are exposed on the **playFavorite** channel.

## Notifications

Expand Down Expand Up @@ -137,3 +154,5 @@ end
- There are some versions of squeezelite that will not correctly play very short duration mp3 files. Versions of squeezelite after v1.7 and before v1.8.6 will not play very short duration mp3 files reliably. For example, if you're using piCorePlayer (which uses squeezelite), please check your version of squeezelite if you're having trouble playing notifications. This bug has been fixed in squeezelite version 1.8.6-985, which is included in piCorePlayer version 3.20.

- When streaming from a remote service (such as Pandora or Spotify), after the notification plays, the Squeezebox Server starts playing a new track, instead of picking up from where it left off on the currently playing track.

- There have been reports that notifications do not play reliably, or do not play at all, when using Logitech Media Server (LMS) version 7.7.5. Therefore, it is recommended that the LMS be on a more current version than 7.7.5.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ public class SqueezeBoxBindingConstants {
public static final ThingTypeUID SQUEEZEBOXPLAYER_THING_TYPE = new ThingTypeUID(BINDING_ID, "squeezeboxplayer");
public static final ThingTypeUID SQUEEZEBOXSERVER_THING_TYPE = new ThingTypeUID(BINDING_ID, "squeezeboxserver");

// List of all Channel ids
// List of all Server Channel Ids
public static final String CHANNEL_FAVORITES_LIST = "favoritesList";

// List of all Player Channel Ids
public static final String CHANNEL_POWER = "power";
public static final String CHANNEL_MUTE = "mute";
public static final String CHANNEL_VOLUME = "volume";
Expand Down Expand Up @@ -57,4 +60,5 @@ public class SqueezeBoxBindingConstants {
public static final String CHANNEL_NAME = "name";
public static final String CHANNEL_MODEL = "model";
public static final String CHANNEL_NOTIFICATION_SOUND_VOLUME = "notificationSoundVolume";
public static final String CHANNEL_FAVORITES_PLAY = "playFavorite";
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
*/
package org.openhab.binding.squeezebox.handler;

import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

import org.openhab.binding.squeezebox.internal.model.Favorite;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -19,6 +21,7 @@
* that's used to monitor certain events related to the notification functionality.
*
* @author Mark Hilbush - Implement AudioSink and notifications
* @author Mark Hilbush - Added event to update favorites list
*/
public final class SqueezeBoxNotificationListener implements SqueezeBoxPlayerEventListener {
private Logger logger = LoggerFactory.getLogger(SqueezeBoxNotificationListener.class);
Expand Down Expand Up @@ -201,4 +204,8 @@ public void remoteTitleChangeEvent(String mac, String title) {
@Override
public void irCodeChangeEvent(String mac, String ircode) {
}

@Override
public void updateFavoritesListEvent(List<Favorite> favorites) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@
*/
package org.openhab.binding.squeezebox.handler;

import java.util.List;

import org.openhab.binding.squeezebox.internal.model.Favorite;

/**
* @author Markus Wolters
* @author Ben Jones
* @author Dan Cunningham (OH2 Port)
* @author Mark Hilbush added durationEvent
* @author Mark Hilbush - Added event to update favorites list
*/
public interface SqueezeBoxPlayerEventListener {

Expand All @@ -24,15 +29,15 @@ public interface SqueezeBoxPlayerEventListener {

/**
* Reports a new absolute volume for a given player.
*
*
* @param mac
* @param volume
*/
void absoluteVolumeChangeEvent(String mac, int volume);

/**
* Reports a relative volume change for a given player.
*
*
* @param mac
* @param volumeChange
*/
Expand Down Expand Up @@ -67,4 +72,6 @@ public interface SqueezeBoxPlayerEventListener {
void remoteTitleChangeEvent(String mac, String title);

void irCodeChangeEvent(String mac, String ircode);

void updateFavoritesListEvent(List<Favorite> favorites);
}
Loading

0 comments on commit d449969

Please sign in to comment.