Skip to content

Commit

Permalink
Added channels & volume
Browse files Browse the repository at this point in the history
  • Loading branch information
JZ-SmartThings committed May 5, 2017
1 parent 9020f9e commit 20ced5d
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions Devices/TVDevice/TVDevice.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* TVDevice v1.0.20170503
* TVDevice v1.0.20170504
*
* Source code can be found here: https://github.com/JZ-SmartThings/SmartThings/blob/master/Devices/TVDevice/TVDevice.groovy
*
Expand All @@ -24,6 +24,8 @@ metadata {
capability "Switch Level"
attribute "displayName", "string"
command "tvinput"
command "chanup"
command "chandown"
command "tvprev"
command "volup"
command "voldown"
Expand Down Expand Up @@ -71,6 +73,14 @@ metadata {
state "default", label: 'TV INPUT', action: "tvinput", icon: "st.Electronics.electronics6", backgroundColor: "#79b821", nextState: "trying"
state "trying", label: 'TRYING', action: "ResetTiles", icon: "st.Electronics.electronics6", backgroundColor: "#FFAA33"
}
standardTile("chanup", "device.chanup", width: 2, height: 2, canChangeIcon: true, canChangeBackground: true, decoration: "flat") {
state "default", label: 'CHAN UP', action: "chanup", icon: "st.custom.buttons.add-icon", backgroundColor: "#FF6600", nextState: "trying"
state "trying", label: 'TRYING', action: "ResetTiles", icon: "st.custom.buttons.add-icon", backgroundColor: "#FFAA33"
}
standardTile("chandown", "device.chandown", width: 2, height: 2, canChangeIcon: true, canChangeBackground: true, decoration: "flat") {
state "default", label:'CHAN DOWN' , action: "chandown", icon: "st.custom.buttons.subtract-icon", backgroundColor:"#53a7c0", nextState: "trying"
state "trying", label: 'TRYING', action: "ResetTiles", icon: "st.custom.buttons.subtract-icon", backgroundColor: "#FFAA33"
}
standardTile("tvprev", "device.switch", width: 2, height: 2, canChangeIcon: true, canChangeBackground: true, decoration: "flat") {
state "default", label: 'PREVIOUS', action: "tvprev", icon: "st.motion.motion.active", backgroundColor: "#79b821", nextState: "trying"
state "trying", label: 'TRYING', action: "ResetTiles", icon: "st.motion.motion.active", backgroundColor: "#FFAA33"
Expand All @@ -87,19 +97,21 @@ metadata {
state "default", label: 'MUTE', action: "tvmute", icon: "st.custom.sonos.muted", backgroundColor: "#9966CC", nextState: "trying"
state "trying", label: 'TRYING', action: "ResetTiles", icon: "st.custom.sonos.muted", backgroundColor: "#FFAA33"
}
controlTile("levelSliderControl", "device.level", "slider", height: 2, width: 6, inactiveLabel: false, range:"(1..4)") {
controlTile("levelSliderControl", "device.level", "slider", width: 6, height: 1, inactiveLabel: false, range:"(1..4)") {
state "level", label:'HDMI Input', action:"switch level.setLevel"
}

main "switch"
details(["displayName","levelSliderControl", "switchon", "switchoff", "tvinput", "tvprev", "volup", "voldown", "tvmute" ])
details(["displayName","levelSliderControl", "switchon", "switchoff", "tvinput", "chanup", "tvprev", "volup", "chandown", "tvmute", "voldown" ])
}
}

def ResetTiles() {
sendEvent(name: "switchon", value: "default", isStateChange: true)
sendEvent(name: "switchoff", value: "default", isStateChange: true)
sendEvent(name: "tvinput", value: "default", isStateChange: true)
sendEvent(name: "chanup", value: "default", isStateChange: true)
sendEvent(name: "chandown", value: "default", isStateChange: true)
sendEvent(name: "tvprev", value: "default", isStateChange: true)
sendEvent(name: "volup", value: "default", isStateChange: true)
sendEvent(name: "voldown", value: "default", isStateChange: true)
Expand All @@ -124,6 +136,12 @@ def off() {
def tvinput() {
runCmd("/ir?tv=input")
}
def chanup() {
runCmd("/ir?tv=chanup")
}
def chandown() {
runCmd("/ir?tv=chandown")
}
def tvprev() {
runCmd("/ir?tv=prev")
}
Expand Down Expand Up @@ -239,6 +257,14 @@ def parse(String description) {
sendEvent(name: "tvinput", value: "default", isStateChange: true)
whichTile = 'tvinput'
}
if (jsonlist."tv"=="chanup") {
sendEvent(name: "chanup", value: "default", isStateChange: true)
whichTile = 'chanup'
}
if (jsonlist."tv"=="chandown") {
sendEvent(name: "chandown", value: "default", isStateChange: true)
whichTile = 'chandown'
}
if (jsonlist."tv"=="prev") {
sendEvent(name: "tvprev", value: "default", isStateChange: true)
whichTile = 'tvprev'
Expand Down Expand Up @@ -284,6 +310,12 @@ def parse(String description) {
//sendEvent(name: "tvinput", value: "default", isStateChange: true)
def result = createEvent(name: "tvinput", value: "default", isStateChange: true)
return result
case 'chanup':
def result = createEvent(name: "chanup", value: "default", isStateChange: true)
return result
case 'chandown':
def result = createEvent(name: "chandown", value: "default", isStateChange: true)
return result
case 'tvprev':
//sendEvent(name: "tvprev", value: "default", isStateChange: true)
def result = createEvent(name: "tvprev", value: "default", isStateChange: true)
Expand Down

0 comments on commit 20ced5d

Please sign in to comment.