-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdiPlayer
245 lines (213 loc) · 8.39 KB
/
diPlayer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
/**
* Copyright 2017 SMBoards
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
*/
/**
* READ ME
*
* This virtual device handler allow play/pause control of a Logitech Squeezebox server located in the same LAN than Hub.
* Additionally you can play 12 different DI.fm channels (currently the channel list and icons are hardcoded)
* Premium DI.fm account is needed because hardware players can't access free channels any more, also di.fm app needs to be installed to SqueezeBox
* Go to your SqueezeServer web interface to find out the URL for di.fm channels and extract the key
*
* If you use integration with Alexa then there are some tricks to know to get along. This is because Alexa has very limited command capabilities.
* Assuming you have named your device SqueezeBox, say "Alexa, turn on the squeezebox" to start music and "Alexa, turn off the squeezebox" to pause
* Say something like "Alexa, set squeezebox level to 4" to directly access your saved presets.
* It seems like it is not a good idea to name the device Player as this confuses Alexa
*/
preferences {
input("setting_server", "string", title:"Enter Logitech Media Server IP address",defaultValue:"192.168.1.111", required:false, displayDuringSetup:true)
input("setting_port", "string", title:"Enter server port",defaultValue:"9000", required:false, displayDuringSetup:true)
input("setting_key", "string", title:"Enter DI listening key",defaultValue:"", required:false, displayDuringSetup:true)
}
metadata {
definition (name: "DI Player", namespace: "smboards", author: "smboards") {
capability "Actuator"
capability "Configuration"
capability "Switch"
capability "musicPlayer"
capability "switchLevel"
command "on"
command "off"
command "pause"
command "play"
command "setLevel",["number","number"]
command "push1"
command "push2"
command "push3"
command "push4"
command "push5"
command "push6"
command "push7"
command "push8"
command "push9"
command "push10"
command "push11"
command "push12"
}
def channels=["","Chillout","Chillout Dreams","Lounge","GoaPsy","Progressive","Progressive Psy","Classic Trance","Trance","Minimal","Tribal House","Deep Techno","Deep House"]
def icons=[""
,"http://static.audioaddict.com/f/d/9/6/c/a/fd96ca5c52508a2755a266ebf506f162.png"
,"http://static.audioaddict.com/1/d/4/f/3/3/1d4f3310f94769b4e2f55ee0887eead3.png"
,"http://static.audioaddict.com/f/6/e/f/f/3/f6eff3e9c3ecf1252201afd1215b55f0.png"
,"http://static.audioaddict.com/4/e/e/e/4/4/4eee448424df2768055ee7503f0251e9.png"
,"http://static.audioaddict.com/3/3/5/5/3/1/3355314492d633a5330c659cfe98fc1b.png"
,"http://static.audioaddict.com/5/f/a/5/6/5/5fa5659badbaf1a4ff817323ee5e998a.png"
,"http://static.audioaddict.com/4/6/8/0/a/3/4680a3fd0e35f0b2f9bf60c9889d4343.png"
,"http://static.audioaddict.com/b/1/0/5/6/7/b10567777ad265dcc63816fa32396654.png"
,"http://static.audioaddict.com/a/9/1/b/1/4/a91b1414a8712794672e3ea1324ffe92.png"
,"http://static.audioaddict.com/5/9/d/5/b/0/59d5b064c1bc9e165850a8d9371d32a5.png"
,"http://static.audioaddict.com/d/3/2/1/7/5/d32175a432f823ce84261c01d4b53f57.png"
,"http://static.audioaddict.com/9/a/1/b/4/6/9a1b469ae251c084465096038312d506.png"]
tiles {
standardTile("status", "device.status", width: 2, height: 2, canChangeIcon: true) {
state "playing", label:'Playing', action:"music Player.pause", icon:"st.Electronics.electronics16", nextState:"paused", backgroundColor:"#79b821"
state "paused", label:'Paused', action:"music Player.play", icon:"st.Electronics.electronics16", nextState:"playing", backgroundColor:"#FFA500"
}
standardTile("push1", "device.button", width: 1, height: 1, decoration: "flat") {
state "default", label: channels[1], backgroundColor: "#ffffff", action: "push1", icon: icons[1]
}
standardTile("push2", "device.button", width: 1, height: 1, decoration: "flat") {
state "default", label: channels[2], backgroundColor: "#ffffff", action: "push2", icon: icons[2]
}
standardTile("push3", "device.button", width: 1, height: 1, decoration: "flat") {
state "default", label: channels[3], backgroundColor: "#ffffff", action: "push3", icon: icons[3]
}
standardTile("push4", "device.button", width: 1, height: 1, decoration: "flat") {
state "default", label: channels[4], backgroundColor: "#ffffff", action: "push4", icon: icons[4]
}
standardTile("push5", "device.button", width: 1, height: 1, decoration: "flat") {
state "default", label: channels[5], backgroundColor: "#ffffff", action: "push5", icon: icons[5]
}
standardTile("push6", "device.button", width: 1, height: 1, decoration: "flat") {
state "default", label: channels[6], backgroundColor: "#ffffff", action: "push6", icon: icons[6]
}
standardTile("push7", "device.button", width: 1, height: 1, decoration: "flat") {
state "default", label: channels[7], backgroundColor: "#ffffff", action: "push7", icon: icons[7]
}
standardTile("push8", "device.button", width: 1, height: 1, decoration: "flat") {
state "default", label: channels[8], backgroundColor: "#ffffff", action: "push8", icon: icons[8]
}
standardTile("push9", "device.button", width: 1, height: 1, decoration: "flat") {
state "default", label: channels[9], backgroundColor: "#ffffff", action: "push9", icon: icons[9]
}
standardTile("push10", "device.button", width: 1, height: 1, decoration: "flat") {
state "default", label: channels[10], backgroundColor: "#ffffff", action: "push10", icon: icons[10]
}
standardTile("push11", "device.button", width: 1, height: 1, decoration: "flat") {
state "default", label: channels[11], backgroundColor: "#ffffff", action: "push11", icon: icons[11]
}
standardTile("push12", "device.button", width: 1, height: 1, decoration: "flat") {
state "default", label: channels[12], backgroundColor: "#ffffff", action: "push12", icon: icons[12]
}
main "status"
details("push1","push2","push3","push4","push5","push6","push7","push8","push9","push10","push11","push12",)
}
}
def parse(description) {
}
def push1() {
push(1)
}
def push2() {
push(2)
}
def push3() {
push(3)
}
def push4() {
push(4)
}
def push5() {
push(5)
}
def push6() {
push(6)
}
def push7() {
push(7)
}
def push8() {
push(8)
}
def push9() {
push(9)
}
def push10() {
push(10)
}
def push11() {
push(11)
}
def push12() {
push(12)
}
private push(button) {
def channels=["","chillout","chilloutdreams","lounge","goapsy","progressive","progressivepsy","classictrance","trance","minimal","tribalhouse","deeptech","deephouse"]
log.debug "$device.displayName button $button was pushed"
// log.debug "$device.displayName /status.html?p0=playlist&p1=play&p2=http://api.audioaddict.com/v1/di/listen/premium_high/${channels[button]}.pls?listen_key=${setting_key}"
def ha = new physicalgraph.device.HubAction
(
method: "GET",
path: "/status.html?p0=playlist&p1=play&p2=http://api.audioaddict.com/v1/di/listen/premium_high/${channels[button]}.pls?listen_key=${setting_key}",
headers: [HOST: "${setting_server}:${setting_port}"]
)
return(ha)
}
// command handlers
def on() {
def ha = new physicalgraph.device.HubAction
(
method: "GET",
path: "/status.html?p0=play",
headers: [HOST: "${setting_server}:${setting_port}"]
)
ha
}
def off() {
def ha = new physicalgraph.device.HubAction
(
method: "GET",
path: "/status.html?p0=pause",
headers: [HOST: "${setting_server}:${setting_port}"]
)
ha
}
def pause()
{
off()
}
def play()
{
on()
}
def setLevel(level, rate=0)
{
int pushlevel=level.toInteger()
if (pushlevel>12)
{
log.debug "$device.displayName too high level requested"
}
else
{
push(pushlevel)
}
}
//General
def installed() {
initialize()
}
def updated() {
initialize()
}
def initialize() {
}