/*
* Wiim Media Player
*
* Licensed Virtual 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.
*
* Change History:
*
* Date Who What
* ---- --- ----
* 15Apr2024 John Williamson Initial attempt - epic fail
* 16Apr2024 John Williamson Fixed ignoreSSLIssues, added and tested all commands
*/
metadata {
definition (name: "Wiim Media Player", namespace: "John Williamson", author: "John Williamson") {
capability "Actuator"
command "preset", ["number"]
command "volumeUp"
command "volumeDown"
command "mute"
command "unmute"
command "stop"
command "pause"
command "seek", ["number"]
command "resume"
command "pausePlay"
command "setVolume", ["number"]
command "prev"
command "next"
command "playURL", ["string"]
command "playlist", ["string"]
command "getStatus"
attribute "volume", "number"
attribute "muted", "bool"
}
preferences {
input("ipAddress", "string", title: "Device IP Address", description: "IP address of Wiim device", required: true)
}
}
def sendHttpGetRequest(String requestURL) {
Map requestParams =
[
uri: requestURL,
ignoreSSLIssues: true
]
try {
httpGet(requestParams) { resp ->
//log.debug resp
if (resp != null) {
// success
//log.debug resp.data // uncomment to log the Get response data
} else {
// failure
}
}
}
catch (e) {
// exception thrown
log.error e
}
}
def preset(number) {
def url = "https://${ipAddress}/httpapi.asp?command=MCUKeyShortClick:${number}"
sendHttpGetRequest(url)
}
def volumeUp() {
def url = "https://${ipAddress}/httpapi.asp?command=setPlayerCmd:vol%2b%2b"
sendHttpGetRequest(url)
}
def volumeDown() {
def url = "https://${ipAddress}/httpapi.asp?command=setPlayerCmd:vol--"
sendHttpGetRequest(url)
}
def mute() {
def url = "https://${ipAddress}/httpapi.asp?command=setPlayerCmd:mute:1"
sendHttpGetRequest(url)
}
def unmute() {
def url = "https://${ipAddress}/httpapi.asp?command=setPlayerCmd:mute:0"
sendHttpGetRequest(url)
}
def stop() {
def url = "https://${ipAddress}/httpapi.asp?command=setPlayerCmd:stop"
sendHttpGetRequest(url)
}
def pause() {
def url = "https://${ipAddress}/httpapi.asp?command=setPlayerCmd:pause"
sendHttpGetRequest(url)
}
def resume() {
def url = "https://${ipAddress}/httpapi.asp?command=setPlayerCmd:resume"
sendHttpGetRequest(url)
}
def pausePlay() {
def url = "https://${ipAddress}/httpapi.asp?command=setPlayerCmd:onepause"
sendHttpGetRequest(url)
}
def setVolume(number) {
def url = "https://${ipAddress}/httpapi.asp?command=setPlayerCmd:vol:${number}"
sendHttpGetRequest(url)
}
def prev() {
def url = "https://${ipAddress}/httpapi.asp?command=setPlayerCmd:prev"
sendHttpGetRequest(url)
}
def next() {
def url = "https://${ipAddress}/httpapi.asp?command=setPlayerCmd:next"
sendHttpGetRequest(url)
}
def seek(number) {
def url = "https://${ipAddress}/httpapi.asp?command=setPlayerCmd:seek:${number}"
sendHttpGetRequest(url)
}
def playURL(string) {
def url = "https://${ipAddress}/httpapi.asp?command=setPlayerCmd:play:${string}"
sendHttpGetRequest(url)
}
def playlist(string) {
def url = "https://${ipAddress}/httpapi.asp?command=setPlayerCmd:m3u:play:${string}"
sendHttpGetRequest(url)
}
def getStatus() {
def url = "https://${ipAddress}/httpapi.asp?command=getPlayerStatus"
sendHttpGetRequest(url)
}