Days since button push


#1

1) Give a description of the problem
I would like to keep track and even display days since a button was pushed. First, a virtual one and if it works well a real one in the future. Hopefully the no of days will be shown in app if possible.

2) What is the expected behaviour?
When button push
Start counter
Display time in days
If button push
Reset counter

3) What is happening/not happening?
How do I do this?


Timer piston for how long a device was used
#2

The age([device﹕attribute]) function will give you the length of time (in milliseconds) that a device has been in a given state. You can easily convert that to days.

I’m not sure what you mean by the number of days being “shown in the app.” What app?


#3

Awesome, I’ll have to test that out.

App : ST or ST Classic. I’d like to display the results in some way. Like a sensor can display temperature if it’s possible


#4

To display the value you would need a device dedicated to this. I suggest you use the ValueTiles device type created by @Robin

https://community.smartthings.com/t/release-value-tiles-dth-for-displaying-webcore-variables-stats-in-a-thing/117802


#5

This looks very good. I’ll check this out. Thank you for the help!


#6

@bthrock cant find device : attribute as a combo for the age parameter? am i entering this into global variables or directly into the value? sorry, im a bit of a noob at this.


#7

ive got it working, i have an indicator in ST app and im currently dividing milliseconds into minutes ( i think). But, i have to manually run the piston to make it refresh now. Is there a “best option” to have it update like once an hour or day?


#8

Add an ‘every’ loop timer to your piston. You can set the interval for every hour or whatever you like. Use the timer option when adding a statement:


#9

So this is what i ended up with, trying it out with 5 minutes and its working. Its monitoring the button and updating the tile, and i can see the result in ST classic!.

thank you for your help both of you.