How to modify an existing SmartApp to start on a time rather than a button?

(First post. Apologies in advance!)

I’m brand new to SmartThings. I’ve got the v3 hub. I’ve just discovered SmartApps, and downloaded the Classic app alongside the STSC app.

I really want to use Bruce’s Slow Dimming SmartApp. I got it loaded into the IDE, and I can see it in the Classic app. I can set it up.

However. I don’t own a button. I can’t find a “Simulated/Virtual Momentary Button” in the IDE New Device list.

So my question can go either way:

  • Can I create a virtual momentary button, and I just don’t know what it’s called?
  • Can I modify the code so that it triggers off of a time of day? I don’t know how to code (or even what language the SmartApp codes are written in), so I would have to ask someone to please hold my hand and walk me through it.

If a virtual momentary button can be created, then to be honest, I’ll just set that button to trigger at a certain time of day.

Bruce’s Slow Dimming code (icon links removed due to new user restrictions…):

/**
     *  Slow Dimmer
     *
     *  Copyright 2015 Bruce Ravenel
     *
     *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
     *  in compliance with the License. You may obtain a copy of the License at:
     *
     *      http://www.apache.org/licenses/LICENSE-2.0
     *
     *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
     *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
     *  for the specific language governing permissions and limitations under the License.
     *
     */
    definition(
        name: "Slow Dimmer",
        namespace: "bravenel",
        author: "Bruce Ravenel",
        description: "Slowly reduce dim level",
        category: "My Apps",
        iconUrl: "1",
        iconX2Url: "2",
        iconX3Url: "3")
    
    
    preferences {
    	section("Select dimmers to slowly dim...") {
    		input "dimmers", "capability.switchLevel", title: "Which?", required: true, multiple: true
    	}
        
        section("Over how many minutes to dim...") {
        	input "minutes", "number", title: "Minutes?", required: true, multiple: false
        }
        
        section("Select momentary button to launch...") {
        	input "trigger", "capability.momentary", title: "Which?", required: true
        }
    }
    
    def installed() {
    	initialize()
    }
    
    def updated() {
    	unsubscribe()
    	initialize()
    }
    
    def initialize() {
    	subscribe(trigger, "switch.on", triggerHandler)
    }
    
def triggerHandler(evt) {
    if(dimmers[0].currentSwitch == "off") state.currentLevel = 0
    else state.currentLevel = dimmers[0].currentLevel
    if(minutes == 0) return
    state.dimStep = state.currentLevel / minutes
    state.dimLevel = state.currentLevel
    dimStep()
}

def dimStep() {
    if(state.currentLevel > 0) {
        state.dimLevel = state.dimLevel - state.dimStep
        state.currentLevel = state.dimLevel.toInteger()
    	dimmers.setLevel(state.currentLevel)
        runIn(60,dimStep)
    } else dimmers.off()
}

Looks to me like you could just change “capability.momentary” to “capability.switch” It just triggers when the switch is turned on. So nothing else would need to be changed and you can use a standard simulated switch. It only looks for a switch to be turned on so a normal switch should work as well, just need to turn it off so it can be triggered again.
You are right I don’t see a simulated monetary switch either. So just use the smart lighting to turn the switch on at whatever time and then turn it off again a few minutes later.

Okay, thanks!! I managed to get it functionally set up in the app. The automation itself seems to be working alright, too!

I have a lot to learn about the customization possibilities, but this has definitely helped me learn that it’s not going to be too awful!

You should look into webcore.

Oh interesting… I had seen a few other people mention webcore and pistons and things, but since I didn’t understand what they were saying, I assumed it was way out of my league.

The website implies that it’ll be decently easy, so I’ll definitely give this a look today!

© 2019 SmartThings, Inc. All Rights Reserved. Terms of Use | Privacy Policy

SmartThings; SmartApps®; Physical Graph; Hello, Home; and Hello, Smart Home are all trademarks of the SmartThings, Inc.