sendEvent to valueTile

tile
developers

#1

I have the following code in my Device Handler. All I am trying to do is send the value 4.5 to display on the valueTile. However, it does not update with the value defined in the command sendEvent. All the tile shows is " - -". Any help would be appreciated. Thanks!

metadata {
definition (
name: “valueDeviceTile”, namespace: “xyz”, author: “zyx”) {

	capability "Sensor"
}

tiles(scale: 2) {
	valueTile("tex", "device.tex", width: 2, height: 2) {
		state "default", label: '${currentValue}'
	}
}

}

def tex() {
sendEvent(name: “tex”, value: 4.5)
}

def parse(String description) {

}


(www.rboyapps.com - Make your home your butler!) #2

define attribute "tex", "string" in the metadata


#3

I tried that scenario and did again with no luck. still showing no value in the smartthings app. It’s as if the sendEvent is not updating the tile value?


(Allan) #4

Where are you calling tex() ?


#5

Allan - I think that is what i am missing. I don’t know how tex() should be called to initiate the value update. suggestions? Ideally i would like the program to call tex() when there is a value change.


(Allan) #6

How does it get updates would be the question. Is this a physical device or a virtual device? If physical it would probably be part of your parse function. If its virtual then there should be a function being called by something else (parent device, smartapp, etc). Something need to call a function that then does the sendEvent.


#7

For learning purposes I am trying to accomplish this using a Virtual device. later on I would like to connect to a physical device to update the value of a temperature, for example.

Is there something I can add to the code to enable a virtual device to make the call to sendEvent?


(Allan) #8

You can add a when updated so when you do a configure on the device and hit done it will run:

def updated() {
sendEvent(name: “tex”, value: 4.5)
}

http://docs.smartthings.com/en/latest/ref-docs/smartapp-ref.html


#9

works like a charm! Thanks!