Simple Timer Switch


#1

Looking for feedback. I created a simple timer switch for my whole house fan. It is designed to turn on if I am home and I press the button on my phone. Then turn off after 20 minutes. Did I miss anything in the code or does it look right. I tested it and it appears to work, but I am so new to this I always like a second set of eyes.


#2

That looks awkward to me but if it works then you may be ok. You should be using the switch as the trigger to turn the outlet on and off. No need to turn the switch off, just the outlet.


#3

The switch is a virtual switch I created to give me a button to push to activate this piston.


#4

You should use the “momentary button tile” virtual device instead of a virtual switch. Basically it’s a virtual switch that has de-bounce built in to make it act like a button.


#5

Ok, that makes sense.


#6

Ok, but I have no idea how to create a “momentary button tile”. Can you explain or send me a link to where I can find it.


#7

Here’s the DTH.


#8

You should be able to go in your SmartThings IDE and just edit your current Simulated Switch. You can change it into a “Momentary Button Tile” and click on Update… No Device Handler needed, and your piston code would be ‘cleaner’, since you would no longer have to send the off command.

temp

Or the lazy way is to make a command in your piston to simply turn back off the Simulated Switch to prepare it for the next trigger. (which is how you did it in your original post above)


#9

Thank you very much