Virtual Device to show a numerical value

(Mike Caley) #1

I am trying to find a way to create a virtual device that will just show a numerical value. I plan to use webcore to change the value based on readings from other devices like an energy monitor.

I can do the webcore but can’t find a virtual device that will allow me to set a numerical value to it.

Any ideas

(JIm) #2

I use a simulated dimmer. That only has 0-100% so that may not work for you. Another thought is to use a simulated temperature sensor.

(Michael Deffendall) #3

Yes, I use the simulated temperature sensor and then I can set the value as high as I need. Although I’d hate to be in a room with a temperature of 200 degrees :grin:

(Robin) #4

Or just use my value tiles DTH:

(JIm) #5

Didn’t know you had that. That’s a great way. Thanks.

(Kevin) #6

@RobinWinbourne @tgauchat - Does this work with ActionTiles to show text in a tile (I think no because it’s not a SmartThings defined type?)?

(Robin) #7

It has the ‘switch’ attribute so will be detected by AT… not sure if it will display anything though?

(Mike Caley) #8

Both the simulated thermostat and the value tiles are both great solutions. Thanks.

What I want to do is have the numerical value displayed as a currency e.g. $2.34.
At the moment the value I am getting is a number with lots of decimal places after it.
So is there a way to change is to a currency value?

(Robin) #9

If you are using the value tiles DTH… you define the value string in webCoRE, so you can add any denominator you like.

You can normally hard code stuff into the tile as well, by changing the label, but the $ symbol might cause issues at it reflects a variable.

Try changing:



label:‘$ ${currentValue}’

( co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #10

Not yet… But it’s a popular Feature Request.

(JIm) #11

A door type DTH shows in AT as OPENING, OPEN, CLOSING, CLOSED. Maybe one could modify a DTH to use something like that. Might look a little funky, but get by until something else comes along.

(Robin) #12

Those 4 states are derived from the garage door capability and AFIK can’t be re-worded.

(JIm) #13

I have a garage door DTH that I modified some for my own use. Here is a partial part of it. I would think you could just change the sendEvent values to just about anything. then call the routine from a smartapp or some such. Maybe it wouldn’t work. I haven’t tried it so don’t know for sure.

def open() {
if (state.doorstat == null) {state.doorstat = 0}
log.debug "Door Stat is $state.doorstat"
switch(state.doorstat) {
state.doorstat = 1
sendEvent(name: “door”, value: “opening”)
sendEvent(name: “contact”, value: “opening”)

state.doorstat = 2

log.debug "Open Called"


def close() {
if (state.doorstat == null) {state.doorstat = 2}
log.debug "Door Stat is $state.doorstat"
switch(state.doorstat) {
state.doorstat = 3
sendEvent(name: “door”, value: “closing”)
sendEvent(name: “contact”, value: “closing”)

(JIm) #14

Ok, I just tried it. AT showed what I put in. So it will work. Like I said, not very elegant, but could get one by.

Robin, could you not take your value tile DTH, add in the door capability which could then be used to show the value in AT. Just a thought.

(Mike Caley) #15

Managed to get a string variable in webcore that includes a currency unit but when this is sent to value tiles it only includes the numerical value not the currency unit.
Any ideas?

(Mike Caley) #16

Also - how to round to 2 decimal places:
“£” + round(([Electricity Monitor : energy]-energyday)*0.135, 2)

(Robin) #18

That would be a very different device… so I made a new one: :sunglasses:

metadata {
	definition (name: "Simulated Garage Value Tile", namespace: "smartthings/testing", author: "Robin Winbourne") {
		capability "Actuator"
		capability "Door Control"
        capability "Garage Door Control"
		capability "Refresh"
		capability "Sensor"
        command "setText"
	tiles {
		standardTile("text", "device.door", width: 3, height: 3) {
			state("closed", label:'${currentValue}', icon:"st.Food & Dining.dining1", backgroundColor:"#FC030F")
		main "text"
def setText(param1) {
    sendEvent(name: "door", value: param1)

Results in this… but you can’t get rid of the ‘?’ I’m afraid :sob:


(Robin) #19

I’m guessing the £ symbol is not allowed in ST groovy… maybe try an emoji… I know they work. :moneybag:

Or if you know that particular tile will always display the currency… tweak the DTH itself:


( co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #20

Please add your Votes :+1: to the relevant Topic(s) in the ActionTiles Feedback Forum…

Here’s a couple I found offhand:

(Robin) #21

Terry, you basically reject the request in the first thread you linked to so not much point voting lol.

All it really needs is the ability to hide the icon (or lack of a recognised garage capability value being displayed as a ‘?’)… you already provide the option to hide the device name.

Better still, allow us to choose the position of an element so the value can be in the middle position.