SmartThings Community

Button Press Counter?

(Steve) #1

Hi Everyone,

I’m using the momentary button tile device type and was wondering if anyone knows of an app that uses this button and has a counter for how many times it’s been pressed. I’m looking for it to count 1-5 and then reset back at 1.



Core should be able to do this.

(Don) #3

I agree with @JDRoberts CoRE can do this. I am using core to count the triggers on a motion sensor. You’ll just created a variable and then increment that variable by one with each trigger.

(Steve) #4

Thank you, I will try this.

(Don) #5

Here is what I have set up. Might give you ideas:

You’ll have to modify it and remove the sms portions. Also set up the if count greater than 5 (6) then set variable back to 0

(Steve) #6

Thank you. This seems complicated for what I’m trying to do. I think it may be easier to figure out the code to have the number of button presses represented on a tile.

I appreciate the suggestions!

(Don) #7

Ignore the back half, I was just too lazy to edit a picture on my phone to show you only 1st part. Just look at the first part where it uses a variable.

You could even just do 2 separate basic pistons.

One that increments the count by 1 every time your button is pushed.
Another that resets the variable to 0 when you reach 6.

If you go to the CoRE help topic they will probably even draw it out for you. They are very helpful in there.

(Robin) #8

Here is a basic example using CoRE. I’ve just showed the action. You can set any trigger you like in the ‘IF’ section:

I have placed an ‘@’ symbol at the start of the variable name so that it becomes a ‘global variable’. This means that other CoRE Pistons can see the variable and act upon the result as desired (send you SMS messages, flash lights, self destruct etc)

If you want the variable value to display in a device tile however, that’s a lot more complicated and requires a custom device handler.

(Steve) #9

Thank you. I was able to get this working. What is your suggestion for knowing what the current variable count is? Is SMS or Notification my best option?

(Robin) #10

I use SMS yes… You can quote the variable by putting it in brackets {@buttonpresses}

(Steve) #11

Thank you for all the suggestions. I was able to trial and error my way into getting this working with a custom device type.

I’m using this for an old pellet stove using microbot push. I just posted a separate thread about the microbots if anyone is interested.

(Matthias Ertl) #12

im looking for something simmilar, can you share your device handler with us / me ? thanks