After banging my head against this CLI thing for a couple weeks, I think I finally understand it. or I have gone insane. Hard to tell. Anyway, the following DTH works in both classic and new apps to display/change webcore global variables. This is a bit of an experiment to see if sharing actually works. Here is the DTH:
/*
Value tiles with adjustment capability-with new app support
*/
metadata {
definition (name: "Adjust Integer Values", namespace: "guxdude", author: "guxdude" ,"vid": "7f05b788-4020-3d65-9977-a76c6ebb049e","mnmn": "SmartThingsCommunity"
) {
capability "dictionaryfabric11101.adjustTextA"
capability "dictionaryfabric11101.adjustIntegerA"
capability "dictionaryfabric11101.adjustTextB"
capability "dictionaryfabric11101.adjustIntegerB"
capability "dictionaryfabric11101.adjustTextC"
capability "dictionaryfabric11101.adjustIntegerC"
capability "dictionaryfabric11101.adjustTextD"
capability "dictionaryfabric11101.adjustIntegerD"
capability "Health Check"
capability "Refresh"
attribute "GVstatus", "string"
// attribute "stepA", "number"
command "value1Up"
command "value1Down"
command "value2Up"
command "value2Down"
command "value3Up"
command "value3Down"
command "value4Up"
command "value4Down"
// command "changeStep", ["number"]
command ResetGV
} // End of definition
tiles(scale:2) {
valueTile("Label1", "labelA", width: 4, height: 1, decoration: "flat") {
state("val", label:'${currentValue}', foregroundColor: "#000000", backgroundColor: "#FFFFFF", defaultState: true )
}
valueTile("Blank11", "labelA", width: 1, height: 1, decoration: "flat") {
state("val", label:"", foregroundColor: "#000000", backgroundColor: "#FFFFFF", defaultState: true )
}
valueTile("Blank1", "labelA", width: 4, height: 1, decoration: "flat") {
state("val", label:"", foregroundColor: "#000000", backgroundColor: "#FFFFFF", defaultState: true )
}
valueTile("Value1", "valueA", width: 2, height: 2, decoration: "flat") {
state("val", label:'${currentValue}')
}
standardTile("value1Up", "valueA", width: 2, height: 2, canChangeIcon: false, decoration: "flat") {
state "default", label: '', action:"value1Up",
icon:"https://raw.githubusercontent.com/tonesto7/nest-manager/master/Images/Devices/heat_arrow_up.png"
state "", label: ''
}
standardTile("value1Down", "valueA", width: 2, height: 2, canChangeIcon: false, decoration: "flat") {
state "default", label:'', action:"value1Down",
icon:"https://raw.githubusercontent.com/tonesto7/nest-manager/master/Images/Devices/heat_arrow_down.png"
state "", label: ''
}
valueTile("Label2", "labelB", width: 4, height: 1, decoration: "flat") {
state("default", label:'${currentValue}', foregroundColor: "#000000", backgroundColor: "#FFFFFF" )
}
valueTile("Value2", "valueB", width: 2, height: 2, decoration: "flat") {
state("default", label:'${currentValue}'/*, foregroundColor: "#FFFFFF",
backgroundColors: [ [value: -1, color: "#FF0000"], [value: 0, color: "#000000"], [value: 1, color: "#00FF00"] ]*/)
}
standardTile("value2Up", "valueB", width: 2, height: 2, canChangeIcon: false, decoration: "flat") {
state "default", label: '', action:"value2Up",
icon:"https://raw.githubusercontent.com/tonesto7/nest-manager/master/Images/Devices/heat_arrow_up.png"
state "", label: ''
}
standardTile("value2Down", "valueB", width: 2, height: 2, canChangeIcon: false, decoration: "flat") {
state "default", label:'', action:"value2Down",
icon:"https://raw.githubusercontent.com/tonesto7/nest-manager/master/Images/Devices/heat_arrow_down.png"
state "", label: ''
}
valueTile("Label3", "labelC", width: 4, height: 1, decoration: "flat") {
state("default", label:'${currentValue}', foregroundColor: "#000000", backgroundColor: "#FFFFFF" )
}
valueTile("Value3", "valueC", width: 2, height: 2, decoration: "flat") {
state("default", label:'${currentValue}')
}
standardTile("value3Up", "valueC", width: 2, height: 2, canChangeIcon: false, decoration: "flat") {
state "default", label: '', action:"value3Up",
icon:"https://raw.githubusercontent.com/tonesto7/nest-manager/master/Images/Devices/heat_arrow_up.png"
state "", label: ''
}
standardTile("value3Down", "valueC", width: 2, height: 2, canChangeIcon: false, decoration: "flat") {
state "default", label:'', action:"value3Down",
icon:"https://raw.githubusercontent.com/tonesto7/nest-manager/master/Images/Devices/heat_arrow_down.png"
state "", label: ''
}
valueTile("Label4", "labelD", width: 4, height: 1, decoration: "flat") {
state("default", label:'${currentValue}', foregroundColor: "#000000", backgroundColor: "#FFFFFF" )
}
valueTile("Value4", "valueD", width: 2, height: 2, decoration: "flat") {
state("default", label:'${currentValue}')
}
standardTile("value4Up", "valueD", width: 2, height: 2, canChangeIcon: false, decoration: "flat") {
state "default", label: '', action:"value4Up",
icon:"https://raw.githubusercontent.com/tonesto7/nest-manager/master/Images/Devices/heat_arrow_up.png"
state "", label: ''
}
standardTile("value4Down", "valueD", width: 2, height: 2, canChangeIcon: false, decoration: "flat") {
state "default", label:'', action:"value4Down",
icon:"https://raw.githubusercontent.com/tonesto7/nest-manager/master/Images/Devices/heat_arrow_down.png"
state "", label: ''
}
// "Value1" will appear in the things view
main(["Value1"])
// these tiles will appear in the Device Details view
// (order is left-to-right, top-to-bottom)
details([
"Blank11","Label1","Blank11",
"value1Up","Value1","value1Down",
"Blank11","Blank1","Blank11",
"Blank11","Label2","Blank11",
"value2Up","Value2","value2Down",
"Blank11","Blank1","Blank11",
"Blank11","Label3","Blank11",
"value3Up","Value3","value3Down",
"Blank11","Blank1","Blank11",
"Blank11","Label4","Blank11",
"value4Up","Value4","value4Down",
"Blank11","Blank1","Blank11"])
} // End of tiles
preferences {
// input name: "GVup", type: "boolean", title: "Updated", description: "Settings updated", required: true, defaultValue: false
} // End of preferences
} // End of metadata
def installed() {
sendEvent(name: "valueA", value: 0, displayed: false)
sendEvent(name: "valueB", value: 0, displayed: false)
sendEvent(name: "valueC", value: 0, displayed: false)
sendEvent(name: "valueD", value: 0, displayed: false)
sendEvent(name: "labelA", value: "Value A", displayed: false)
sendEvent(name: "labelB", value: "Value B", displayed: false)
sendEvent(name: "labelC", value: "Value C", displayed: false)
sendEvent(name: "labelD", value: "Value D", displayed: false)
sendEvent(name: "GVstatus", value: "start", displayed: false, isStateChange: true)
}
def updated() {
sendEvent(name: "GVstatus", value: "update", displayed: false, isStateChange: true)
}
def setValueA(value) {
valueChange("valueA", value)
/*
sendEvent(name: "valueA", value: value, displayed: false)
sendEvent(name: "GVstatus", value: "valueA", displayed: false, isStateChange: true)
*/
}
def setValueB(value) {
valueChange("valueB", value)
/*
sendEvent(name: "valueB", value: value, displayed: false)
sendEvent(name: "GVstatus", value: "valueB", displayed: false, isStateChange: true)
*/
}
def setValueC(value) {
valueChange("valueC", value)
/*
sendEvent(name: "valueC", value: value, displayed: false)
sendEvent(name: "GVstatus", value: "valueC", displayed: false, isStateChange: true)
*/
}
def setValueD(value) {
valueChange("valueD", value)
/*
sendEvent(name: "valueD", value: value, displayed: false)
sendEvent(name: "GVstatus", value: "valueD", displayed: false, isStateChange: true)
*/
}
def setLabelA(value) {
textChange("labelA", value)
/*
sendEvent(name: "labelA", value: value, displayed: false)
sendEvent(name: "GVstatus", value: "labelA", displayed: false, isStateChange: true)
*/
}
def setLabelB(value) {
textChange("labelB", value)
}
def setLabelC(value) {
textChange("labelC", value)
}
def setLabelD(value) {
textChange("labelD", value)
}
def value1Up () {
def newVal = (device.currentValue("valueA").toInteger())+1
valueChange("valueA", newVal)
/*
def incVal = (device.currentValue("Increment").toInteger())
if (isTime1) {
timeChange("Value1",incVal)
} else {
valueChange("Value1",incVal)
}
*/
}
def value1Down () {
def newVal = (device.currentValue("valueA").toInteger())-1
valueChange("valueA", newVal)
}
def value2Up () {
def newVal = (device.currentValue("valueB").toInteger())+1
valueChange("valueB", newVal)
}
def value2Down () {
def newVal = (device.currentValue("valueB").toInteger())-1
valueChange("valueB", newVal)
}
def value3Up () {
def newVal = (device.currentValue("valueC").toInteger())+1
valueChange("valueC", newVal)
}
def value3Down () {
def newVal = (device.currentValue("valueC").toInteger())-1
valueChange("valueC", newVal)
}
def value4Up () {
def newVal = (device.currentValue("valueD").toInteger())+1
valueChange("valueD", newVal)
}
def value4Down () {
def newVal = (device.currentValue("valueD").toInteger())-1
valueChange("valueD", newVal)
}
def valueChange(String valString, Integer newval) {
// def targetVal = (device.currentValue(valString).toInteger())+offset
// reset to avoid losing sync with WebCoRE
ResetGV()
Logger("valueChange: ${valString} Target ${newval}")
sendEvent("name":valString, "value":newval, displayed: true)
sendEvent(name: "GVstatus", value: valString, displayed: false, isStateChange: true)
}
def textChange(String valString, String newval) {
Logger("valueChange: ${valString} Target ${newval}")
sendEvent("name":valString, "value":newval, displayed: true)
sendEvent(name: "GVstatus", value: valString, displayed: false, isStateChange: true)
}
//def changeStep(Integer newval) {
//valueA
//}
def ResetGV() {
sendEvent(name: "GVstatus", value: "clear", displayed: false, isStateChange: true)
}
def Logger(String logString) {
log.info(logString)
}
This is the piston for setting/updating the global variables from this device.
Once you copy, paste and publish the DTH, create a device using it. Then you will need to edit the piston to use your new device and the variables you want to view/change. Hope it is helpful.
EDIT: Forgot to mention, in order to add this device to webcore, you need to look under capability 2 ārefreshable devicesā. Also, note this only supports integer values at this time.
EDIT2: Very slight modification to the DTH to help avoid getting stuck if changing values too fast for webcore to keep up.