Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Plex Communicator Device
- *
- * Copyright 2018 Jake Tebbett (jebbett)
- *
- * 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.
- *
- * 2018-11-17 2.0 Updated to report playbackType Correctly
- * 2020-05-24 2.1 Updated to add track title
- */
- metadata {
- definition (name: "Plex Communicator Device", namespace: "jebbett", author: "jebbett") {
- capability "Music Player"
- attribute "playbackType", "string"
- attribute "status", "string"
- attribute "trackDescription", "string"
- //edition of original code from Jake Tebbett (05/18/21)
- attribute "Rating", "string"
- attribute "Season", "string"
- attribute "Episode", "string"
- attribute "Show", "string"
- attribute "Live", "bool"
- command "CustomCommand",["string"] ///********/05/20/21******* send commands to the server
- //end of edition
- }
- }
- preferences {
- input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: true ////****** no really need it
- }
- //addition
- def installed() {
- state.XPlexTargetClientIdentifier = device.deviceNetworkId /////*****store the XPlexTargetClientIdentifier /05/20/21
- }
- // External
- def playbackType(type) {
- sendEvent(name: "playbackType", value: type);
- //log.debug "Playback type set as $type"
- }
- def setPlayStatus(status){
- // Value needs to be playing, paused or stopped
- sendEvent(name: "status", value: status)
- log.debug "Status set to $status"
- }
- def setTitle(title) {
- sendEvent(name: "trackDescription", value: title);
- //log.debug "Title set as $title"
- }
- def play() {
- //sendEvent(name: "status", value: "playing");
- parent.sendCommand (state.XPlexTargetClientIdentifier,"/player/playback/play") //edition 05/20/21
- }
- def pause() {
- //sendEvent(name: "status", value: "paused");
- parent.sendCommand (state.XPlexTargetClientIdentifier,"/player/playback/pause") //edition 05/20/21
- }
- def stop() {
- //sendEvent(name: "status", value: "stopped");
- parent.sendCommand (state.XPlexTargetClientIdentifier,"/player/playback/stop") //edition 05/20/21
- }
- def previousTrack (){
- parent.sendCommand (state.XPlexTargetClientIdentifier,"/player/playback/skipPrevious") //edition 05/20/21
- }
- def nextTrack (){
- parent.sendCommand (state.XPlexTargetClientIdentifier,"/player/playback/skipNext") //edition 05/20/21
- }
- def setLevel(volumelevel){
- parent.sendCommand (state.XPlexTargetClientIdentifier,"/player/playback/setParameters?volume=${volumelevel}") //edition 05/20/21
- }
- def CustomCommand (cmd){
- parent.sendCommand (state.XPlexTargetClientIdentifier,cmd) //edition 05/20/21
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement