Skip to content

Commit

Permalink
[Spotify] Added channel to display if track is explicit (openhab#7388)
Browse files Browse the repository at this point in the history
Closes openhab#7377

Signed-off-by: Hilbrand Bouwkamp <[email protected]>
  • Loading branch information
Hilbrand authored and LoungeFlyZ committed Jun 8, 2020
1 parent fbaeacf commit 67e96f3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public class SpotifyBindingConstants {
public static final String CHANNEL_PLAYED_TRACKNUMBER = "trackNumber";
public static final String CHANNEL_PLAYED_TRACKDISCNUMBER = "trackDiscNumber";
public static final String CHANNEL_PLAYED_TRACKPOPULARITY = "trackPopularity";
public static final String CHANNEL_PLAYED_TRACKEXPLICIT = "trackExplicit";
public static final String CHANNEL_PLAYED_TRACKDURATION_MS = "trackDurationMs";
public static final String CHANNEL_PLAYED_TRACKPROGRESS_MS = "trackProgressMs";
public static final String CHANNEL_PLAYED_TRACKDURATION_FMT = "trackDuration";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class Item {
private List<String> availableMarkets;
private Integer discNumber;
private long durationMs;
private Boolean explicit;
private boolean explicit;
private ExternalIds externalIds;
private ExternalUrl externalUrls;
private String href;
Expand Down Expand Up @@ -59,7 +59,7 @@ public long getDurationMs() {
return durationMs;
}

public Boolean getExplicit() {
public boolean isExplicit() {
return explicit;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ private void updatePlayerInfo(CurrentlyPlayingContext playerInfo, List<Playlist>
updateChannelState(CHANNEL_PLAYED_TRACKNUMBER, valueOrZero(item.getTrackNumber()));
updateChannelState(CHANNEL_PLAYED_TRACKDISCNUMBER, valueOrZero(item.getDiscNumber()));
updateChannelState(CHANNEL_PLAYED_TRACKPOPULARITY, valueOrZero(item.getPopularity()));
updateChannelState(CHANNEL_PLAYED_TRACKEXPLICIT, OnOffType.from(item.isExplicit()));

final boolean hasAlbum = hasItem && item.getAlbum() != null;
final Album album = hasAlbum ? item.getAlbum() : EMPTY_ALBUM;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ register a bridge for each account. Go to http://your openHAB address::8080/conn
<channel id="trackNumber" typeId="currentlyPlayedTrackNumber" />
<channel id="trackDiscNumber" typeId="currentlyPlayedTrackDiscNumber" />
<channel id="trackPopularity" typeId="currentlyPlayedTrackPopularity" />
<channel id="trackExplicit" typeId="currentlyPlayedTrackExplicit" />
<channel id="trackDurationMs" typeId="currentlyPlayedTrackDurationMs" />
<channel id="trackProgressMs" typeId="currentlyPlayedTrackProgressMs" />
<channel id="trackDuration" typeId="currentlyPlayedTrackDuration" />
Expand Down Expand Up @@ -245,7 +246,13 @@ bridge you have configured.</description>
<channel-type id="currentlyPlayedTrackPopularity" advanced="true">
<item-type>Number</item-type>
<label>Track Popularity</label>
<description>The populatiry of the currently played track</description>
<description>The popularity of the currently played track</description>
<state readOnly="true" />
</channel-type>
<channel-type id="currentlyPlayedTrackExplicit" advanced="true">
<item-type>Switch</item-type>
<label>Track Explicit</label>
<description>Whether or not the track has explicit lyrics (On it does; Off it does not OR unknown)</description>
<state readOnly="true" />
</channel-type>

Expand Down

0 comments on commit 67e96f3

Please sign in to comment.