Skip to content

Commit 6c77b16

Browse files
authored
[kaleidescape] Add movie end time and music title channels (openhab#17423)
* Add movie end time and music end title channels Signed-off-by: Michael Lobstein <[email protected]>
1 parent 438541a commit 6c77b16

File tree

7 files changed

+93
-8
lines changed

7 files changed

+93
-8
lines changed

bundles/org.openhab.binding.kaleidescape/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ The following channels are available:
7171
| ui#title_num | Number | The current movie title number that is playing |
7272
| ui#title_length | Number:Time | The total running time of the currently playing movie (seconds) |
7373
| ui#title_loc | Number:Time | The running time elapsed of the currently playing movie (seconds) |
74+
| ui#endtime | DateTime | The date/time when the currently playing movie will end (timestamp) |
7475
| ui#chapter_num | Number | The current chapter number of the movie that is playing |
7576
| ui#chapter_length | Number:Time | The total running time of the current chapter (seconds) |
7677
| ui#chapter_loc | Number:Time | The running time elapsed of the current chapter |
@@ -105,6 +106,7 @@ The following channels are available:
105106
| music#track | String | The name of the currently playing track |
106107
| music#artist | String | The name of the currently playing artist |
107108
| music#album | String | The name of the currently playing album |
109+
| music#title | String | The raw output from the MUSIC_TITLE api response for use in rules that require track, artist and album changes in one update |
108110
| music#play_mode | String | The current playback mode of the music |
109111
| music#play_speed | String | The speed of playback scanning |
110112
| music#track_length | Number:Time | The total running time of the current playing track (seconds) |
@@ -162,6 +164,7 @@ String z1_Ui_PlaySpeed "Play Speed: [%s]" { channel="kaleidescape:player:myzone1
162164
Number z1_Ui_TitleNum "Title Number: [%s]" { channel="kaleidescape:player:myzone1:ui#title_num" }
163165
Number:Time z1_Ui_TitleLength "Title Length: [JS(ksecondsformat.js):%s]" { channel="kaleidescape:player:myzone1:ui#title_length" }
164166
Number:Time z1_Ui_TitleLoc "Title Location: [JS(ksecondsformat.js):%s]" { channel="kaleidescape:player:myzone1:ui#title_loc" }
167+
DateTime z1_Ui_TitleEndTime "Title End Time: [%s]" { channel="kaleidescape:player:myzone1:ui#endtime" }
165168
Number z1_Ui_ChapterNum "Chapter Number: [%s]" { channel="kaleidescape:player:myzone1:ui#chapter_num" }
166169
Number:Time z1_Ui_ChapterLength "Chapter Length: [JS(ksecondsformat.js):%s]" { channel="kaleidescape:player:myzone1:ui#chapter_length" }
167170
Number:Time z1_Ui_ChapterLoc "Chapter Location: [JS(ksecondsformat.js):%s]" { channel="kaleidescape:player:myzone1:ui#chapter_loc" }
@@ -203,6 +206,7 @@ String z1_Music_PlaySpeed "Play Speed: [%s]" { channel="kaleidescape:player:myzo
203206
Number:Time z1_Music_TrackLength "Track Length: [JS(ksecondsformat.js):%s]" { channel="kaleidescape:player:myzone1:music#track_length" }
204207
Number:Time z1_Music_TrackPosition "Track Position: [JS(ksecondsformat.js):%s]" { channel="kaleidescape:player:myzone1:music#track_position" }
205208
Number z1_Music_TrackProgress "Track Progress: [%s %%]" { channel="kaleidescape:player:myzone1:music#track_progress" }
209+
String z1_Music_Title "Music Title Raw: [%s]" { channel="kaleidescape:player:myzone1:music#title" }
206210
String z1_Music_TrackHandle "Track Handle: [%s]" { channel="kaleidescape:player:myzone1:music#track_handle" }
207211
String z1_Music_AlbumHandle "Album Handle: [%s]" { channel="kaleidescape:player:myzone1:music#album_handle" }
208212
String z1_Music_NowplayHandle "Now Playing Handle: [%s]" { channel="kaleidescape:player:myzone1:music#nowplay_handle" }
@@ -291,6 +295,7 @@ sitemap kaleidescape label="Kaleidescape" {
291295
Text item=z1_Ui_TitleNum icon="video"
292296
Text item=z1_Ui_TitleLength icon="time"
293297
Text item=z1_Ui_TitleLoc icon="time"
298+
Text item=z1_Ui_TitleEndTime icon="time"
294299
Text item=z1_Ui_MovieMediaType icon="colorwheel"
295300
Text item=z1_Ui_ChapterNum icon="video"
296301
Text item=z1_Ui_ChapterLength icon="time"
@@ -334,6 +339,7 @@ sitemap kaleidescape label="Kaleidescape" {
334339
Text item=z1_Music_TrackLength icon="time"
335340
Text item=z1_Music_TrackPosition icon="time"
336341
Text item=z1_Music_TrackProgress icon="time"
342+
Text item=z1_Music_Title icon="zoom"
337343
Text item=z1_Music_TrackHandle icon="zoom"
338344
Text item=z1_Music_AlbumHandle icon="zoom"
339345
Text item=z1_Music_NowplayHandle icon="zoom"

bundles/org.openhab.binding.kaleidescape/src/main/java/org/openhab/binding/kaleidescape/internal/KaleidescapeBindingConstants.java

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public class KaleidescapeBindingConstants {
5656
public static final String TITLE_NUM = "ui#title_num";
5757
public static final String TITLE_LENGTH = "ui#title_length";
5858
public static final String TITLE_LOC = "ui#title_loc";
59+
public static final String ENDTIME = "ui#endtime";
5960
public static final String CHAPTER_NUM = "ui#chapter_num";
6061
public static final String CHAPTER_LENGTH = "ui#chapter_length";
6162
public static final String CHAPTER_LOC = "ui#chapter_loc";
@@ -91,6 +92,7 @@ public class KaleidescapeBindingConstants {
9192
public static final String MUSIC_TRACK = "music#track";
9293
public static final String MUSIC_ARTIST = "music#artist";
9394
public static final String MUSIC_ALBUM = "music#album";
95+
public static final String MUSIC_TITLE_RAW = "music#title";
9496
public static final String MUSIC_PLAY_MODE = "music#play_mode";
9597
public static final String MUSIC_PLAY_SPEED = "music#play_speed";
9698
public static final String MUSIC_TRACK_LENGTH = "music#track_length";

bundles/org.openhab.binding.kaleidescape/src/main/java/org/openhab/binding/kaleidescape/internal/handler/KaleidescapeHandler.java

+2
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ private void handleRefresh(String channel) throws KaleidescapeException {
500500
case TITLE_NUM:
501501
case TITLE_LENGTH:
502502
case TITLE_LOC:
503+
case ENDTIME:
503504
case CHAPTER_NUM:
504505
case CHAPTER_LENGTH:
505506
case CHAPTER_LOC:
@@ -565,6 +566,7 @@ private void handleRefresh(String channel) throws KaleidescapeException {
565566
case MUSIC_TRACK:
566567
case MUSIC_ARTIST:
567568
case MUSIC_ALBUM:
569+
case MUSIC_TITLE_RAW:
568570
case MUSIC_TRACK_HANDLE:
569571
case MUSIC_ALBUM_HANDLE:
570572
case MUSIC_NOWPLAY_HANDLE:

bundles/org.openhab.binding.kaleidescape/src/main/java/org/openhab/binding/kaleidescape/internal/handler/KaleidescapeMessageHandler.java

+14-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import static org.openhab.binding.kaleidescape.internal.KaleidescapeBindingConstants.*;
1818

1919
import java.math.BigDecimal;
20+
import java.time.ZonedDateTime;
2021
import java.util.concurrent.ExecutionException;
2122
import java.util.concurrent.TimeUnit;
2223
import java.util.concurrent.TimeoutException;
@@ -29,6 +30,7 @@
2930
import org.openhab.binding.kaleidescape.internal.KaleidescapeException;
3031
import org.openhab.binding.kaleidescape.internal.communication.KaleidescapeFormatter;
3132
import org.openhab.binding.kaleidescape.internal.communication.KaleidescapeStatusCodes;
33+
import org.openhab.core.library.types.DateTimeType;
3234
import org.openhab.core.library.types.DecimalType;
3335
import org.openhab.core.library.types.OnOffType;
3436
import org.openhab.core.library.types.PercentType;
@@ -116,11 +118,15 @@ public void handleMessage(String message, KaleidescapeHandler handler) {
116118

117119
handler.updateChannel(TITLE_NUM, new DecimalType(Integer.parseInt(matcher.group(3))));
118120

119-
handler.updateChannel(TITLE_LENGTH,
120-
new QuantityType<>(Integer.parseInt(matcher.group(4)), handler.apiSecondUnit));
121+
final int titleLength = Integer.parseInt(matcher.group(4));
122+
final int titleLoc = Integer.parseInt(matcher.group(5));
123+
124+
handler.updateChannel(TITLE_LENGTH, new QuantityType<>(titleLength, handler.apiSecondUnit));
121125

122-
handler.updateChannel(TITLE_LOC,
123-
new QuantityType<>(Integer.parseInt(matcher.group(5)), handler.apiSecondUnit));
126+
handler.updateChannel(TITLE_LOC, new QuantityType<>(titleLoc, handler.apiSecondUnit));
127+
128+
handler.updateChannel(ENDTIME, titleLength < 1 ? UnDefType.UNDEF
129+
: new DateTimeType(ZonedDateTime.now().plusSeconds(titleLength - titleLoc)));
124130

125131
handler.updateChannel(CHAPTER_NUM, new DecimalType(Integer.parseInt(matcher.group(6))));
126132

@@ -270,6 +276,10 @@ public void handleMessage(String message, KaleidescapeHandler handler) {
270276
// first replace delimited : in track/artist/album name with ||, fix it later in formatString()
271277
Matcher matcher = p.matcher(message.replace("\\:", "||"));
272278
if (matcher.find()) {
279+
// if not an empty message, the colon delimiters in raw MUSIC_TITLE message are changed to pipe
280+
handler.updateChannel(MUSIC_TITLE_RAW, ":::::".equals(matcher.group(0)) ? UnDefType.NULL
281+
: new StringType(KaleidescapeFormatter.formatString(matcher.group(0).replace(":", "|"))));
282+
273283
handler.updateChannel(MUSIC_TRACK,
274284
new StringType(KaleidescapeFormatter.formatString(matcher.group(1))));
275285

bundles/org.openhab.binding.kaleidescape/src/main/resources/OH-INF/i18n/kaleidescape.properties

+4
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ channel-type.kaleidescape.directors.label = Directors
116116
channel-type.kaleidescape.directors.description = A list of directors of the selected Movie
117117
channel-type.kaleidescape.disc_location.label = Disc Location
118118
channel-type.kaleidescape.disc_location.description = Indicates where the disc for the selected item is currently residing in the system (ie Vault, Tray, etc.)
119+
channel-type.kaleidescape.endtime.label = Title End Time
120+
channel-type.kaleidescape.endtime.description = The date/time when the currently playing movie will end
119121
channel-type.kaleidescape.genres.label = Genres
120122
channel-type.kaleidescape.genres.description = A list of genres of the selected item
121123
channel-type.kaleidescape.highlighted_selection.label = Highlighted Selection
@@ -138,6 +140,8 @@ channel-type.kaleidescape.music_play_mode.label = Play Mode
138140
channel-type.kaleidescape.music_play_mode.description = The current playback mode of the music
139141
channel-type.kaleidescape.music_play_speed.label = Play Speed
140142
channel-type.kaleidescape.music_play_speed.description = The speed of playback scanning
143+
channel-type.kaleidescape.music_title.label = Music Title
144+
channel-type.kaleidescape.music_title.description = The raw output from the MUSIC_TITLE api response
141145
channel-type.kaleidescape.nowplay_handle.label = Now Playing Handle
142146
channel-type.kaleidescape.nowplay_handle.description = The handle of the current now playing list
143147
channel-type.kaleidescape.random.label = Random

bundles/org.openhab.binding.kaleidescape/src/main/resources/OH-INF/thing/channels.xml

+27-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<property name="Control Protocol ID">unknown</property>
3434
<property name="System Version">unknown</property>
3535
<property name="Protocol Version">unknown</property>
36-
<property name="thingTypeVersion">1</property>
36+
<property name="thingTypeVersion">2</property>
3737
</properties>
3838

3939
<config-description-ref uri="thing-type:kaleidescape:kaleidescapedevice"/>
@@ -68,7 +68,7 @@
6868
<property name="Control Protocol ID">unknown</property>
6969
<property name="System Version">unknown</property>
7070
<property name="Protocol Version">unknown</property>
71-
<property name="thingTypeVersion">1</property>
71+
<property name="thingTypeVersion">2</property>
7272
</properties>
7373

7474
<config-description-ref uri="thing-type:kaleidescape:kaleidescapedevice"/>
@@ -99,7 +99,7 @@
9999
<property name="Control Protocol ID">unknown</property>
100100
<property name="System Version">unknown</property>
101101
<property name="Protocol Version">unknown</property>
102-
<property name="thingTypeVersion">1</property>
102+
<property name="thingTypeVersion">2</property>
103103
</properties>
104104

105105
<config-description-ref uri="thing-type:kaleidescape:kaleidescapedevice"/>
@@ -130,7 +130,7 @@
130130
<property name="Control Protocol ID">unknown</property>
131131
<property name="System Version">unknown</property>
132132
<property name="Protocol Version">unknown</property>
133-
<property name="thingTypeVersion">1</property>
133+
<property name="thingTypeVersion">2</property>
134134
</properties>
135135

136136
<config-description-ref uri="thing-type:kaleidescape:kaleidescapedevice"/>
@@ -150,6 +150,7 @@
150150
<channel id="title_num" typeId="title_num"/>
151151
<channel id="title_length" typeId="title_length"/>
152152
<channel id="title_loc" typeId="title_loc"/>
153+
<channel id="endtime" typeId="endtime"/>
153154
<channel id="chapter_num" typeId="chapter_num"/>
154155
<channel id="chapter_length" typeId="chapter_length"/>
155156
<channel id="chapter_loc" typeId="chapter_loc"/>
@@ -190,6 +191,7 @@
190191
<channel id="title_num" typeId="title_num"/>
191192
<channel id="title_length" typeId="title_length"/>
192193
<channel id="title_loc" typeId="title_loc"/>
194+
<channel id="endtime" typeId="endtime"/>
193195
<channel id="chapter_num" typeId="chapter_num"/>
194196
<channel id="chapter_length" typeId="chapter_length"/>
195197
<channel id="chapter_loc" typeId="chapter_loc"/>
@@ -229,6 +231,7 @@
229231
<channel id="title_num" typeId="title_num"/>
230232
<channel id="title_length" typeId="title_length"/>
231233
<channel id="title_loc" typeId="title_loc"/>
234+
<channel id="endtime" typeId="endtime"/>
232235
<channel id="chapter_num" typeId="chapter_num"/>
233236
<channel id="chapter_length" typeId="chapter_length"/>
234237
<channel id="chapter_loc" typeId="chapter_loc"/>
@@ -267,6 +270,7 @@
267270
<channel id="track" typeId="track"/>
268271
<channel id="artist" typeId="artist"/>
269272
<channel id="album" typeId="album"/>
273+
<channel id="title" typeId="music_title"/>
270274
<channel id="play_mode" typeId="music_play_mode"/>
271275
<channel id="play_speed" typeId="music_play_speed"/>
272276
<channel id="track_length" typeId="track_length"/>
@@ -376,6 +380,18 @@
376380
<state readOnly="true" pattern="%d %unit%"/>
377381
</channel-type>
378382

383+
<channel-type id="endtime">
384+
<item-type>DateTime</item-type>
385+
<label>Title End Time</label>
386+
<description>The date/time when the currently playing movie will end</description>
387+
<category>Time</category>
388+
<tags>
389+
<tag>Status</tag>
390+
<tag>Timestamp</tag>
391+
</tags>
392+
<state readOnly="true"/>
393+
</channel-type>
394+
379395
<channel-type id="chapter_num">
380396
<item-type>Number</item-type>
381397
<label>Chapter Number</label>
@@ -602,6 +618,13 @@
602618
<state readOnly="true"/>
603619
</channel-type>
604620

621+
<channel-type id="music_title" advanced="true">
622+
<item-type>String</item-type>
623+
<label>Music Title</label>
624+
<description>The raw output from the MUSIC_TITLE api response</description>
625+
<state readOnly="true"/>
626+
</channel-type>
627+
605628
<channel-type id="music_play_mode">
606629
<item-type>String</item-type>
607630
<label>Play Mode</label>

bundles/org.openhab.binding.kaleidescape/src/main/resources/OH-INF/update/instructions.xml

+38
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,42 @@
3535
</instruction-set>
3636
</thing-type>
3737

38+
<thing-type uid="kaleidescape:player">
39+
<instruction-set targetVersion="2">
40+
<add-channel id="endtime" groupIds="ui">
41+
<type>kaleidescape:endtime</type>
42+
</add-channel>
43+
<add-channel id="title" groupIds="music">
44+
<type>kaleidescape:music_title</type>
45+
</add-channel>
46+
</instruction-set>
47+
</thing-type>
48+
49+
<thing-type uid="kaleidescape:cinemaone">
50+
<instruction-set targetVersion="2">
51+
<add-channel id="endtime" groupIds="c1-alto_ui">
52+
<type>kaleidescape:endtime</type>
53+
</add-channel>
54+
<add-channel id="title" groupIds="music">
55+
<type>kaleidescape:music_title</type>
56+
</add-channel>
57+
</instruction-set>
58+
</thing-type>
59+
60+
<thing-type uid="kaleidescape:alto">
61+
<instruction-set targetVersion="2">
62+
<add-channel id="endtime" groupIds="c1-alto_ui">
63+
<type>kaleidescape:endtime</type>
64+
</add-channel>
65+
</instruction-set>
66+
</thing-type>
67+
68+
<thing-type uid="kaleidescape:strato">
69+
<instruction-set targetVersion="2">
70+
<add-channel id="endtime" groupIds="strato_ui">
71+
<type>kaleidescape:endtime</type>
72+
</add-channel>
73+
</instruction-set>
74+
</thing-type>
75+
3876
</update:update-descriptions>

0 commit comments

Comments
 (0)