Momentary Button Tile for new v3 App

Apparently the traditional “momentary button tile” DH is no longer supported in the new v3 app, so I set out to build a new one. I took the base of the normal DH and just incorporated a few things I found other people doing. This new app is now sort of working with the new app, except for a few quirks:

  1. If you try to trigger off of it turning “on” then the automation never runs. You have to trigger off of it turning “off”, which always runs. For example, I tell my google home “home mode”, and it turns the virtual momentary device “on”. It then immediately turns itself off and triggers the automation.
  2. No history is logged in the history section of the device within the new v3 app, though I can see the events in the IDE for the device.

Anyway to fix the above two? I’m way out of my depth and surprised I even got it working at all to be honest.

/**
 *  Copyright 2015 SmartThings
 *
 *  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.
 *
 *  Momentary Button Tile v2
 *
 *  Author: SmartThings
 *
 *  Date: 2013-05-01
 */
metadata {
	definition (name: "Momentary Button Tile v2", namespace: "smartthings", author: "SmartThings", mnmn: "SmartThings", vid: "generic-switch", ocfDeviceType: 'oic.d.switch') {
		capability "Actuator"
		capability "Switch"
		capability "Momentary"
		capability "Sensor"
        capability "button"
	}

	// simulator metadata
	simulator {
	}

	// UI tile definitions
	tiles(scale: 2){
		multiAttributeTile(name:"switch", type: "generic", width: 6, height: 4, canChangeIcon: true){
			tileAttribute("device.switch", key: "PRIMARY_CONTROL") {
				attributeState("off", label: 'Push', action: "momentary.push", backgroundColor: "#ffffff", nextState: "on")
				attributeState("on", label: 'Push', action: "momentary.push", backgroundColor: "#00a0dc")
			}	
		}
		main "switch"
		details "switch"
	}
}

def parse(String description) {
}

def push() {
	sendEvent(name: "switch", value: "on", isStateChange: true, displayed: false)
	sendEvent(name: "switch", value: "off", isStateChange: true, displayed: false)
	sendEvent(name: "momentary", value: "pushed", isStateChange: true)
    sendEvent(name: "DeviceWatch-DeviceStatus", value: "online")
    sendEvent(name: "healthStatus", value: "online")
    sendEvent(name: "DeviceWatch-Enroll", value: [protocol: "cloud", scheme:"untracked"].encodeAsJson(), displayed: false)
}

def on() {
	push()
}

def off() {
	push()
}

Maybe try using one of the recent “button” as base and modify from there?

The “vid: generic-button” or “ocfDeviceType: x.com.st.d.remotecontroller” might be better than “generic-switch”…

You have to use switch so that it can be turned “on” by other automations or a google home. You can’t “press” buttons via other automations or integrations.

Well, that sucks. :disappointed_relieved:

A common reason for using virtual momentary buttons in the past was when you were using one to trigger some other event and you wanted it to turn itself off very quickly so it would be available for the next time you want to use it.

You can still do that with power allowance, but it has a minimum interval of one minute, which may be longer than some people want.

Just as an example, several years ago I was able to control volume by voice by having two harmony activities, One for volume up and one for volume down.

If I had to wait for one minute in between each volume adjustment, that would’ve been very annoying. “Volume up.“ Wait one minute. “Volume up.“ Wait one minute. Etc.

The biggest advantage of the momentary button tile was that it went on and then off almost immediately.

1 Like

See the old thread:

1 Like

I use this one and have had no problems with it yet :wink:
Maybe needs some update for compliancy ?
Momentary Button Tile - Normally on
*

  • Author: Damon Floyd
  • Date: 2015-09-08

Oh, hey Daven (saw your post on the other thread as well). So you’re using that DH with the new v3 app? And does it allow you to switch it “on” with an automation and can you trigger off of it switching on with an automation as well?

I use it as a momentary to trigger pistons and routines, they seem to be working just fine when I tested them yesterday. I have not tried setting it On from WebCore but assume it works backwards as well.
Busy with a new issue right now, I had a Scene set up and it just left my app for no reason. Then, again for no reason, my lighting group just left the app without my intervention as well.
Ha, the Scene just reappeared but the lighting group has run away.
I think the app is having a bad Friday.

I just tried out that DTH “Momentary Button Tile - Normally on” and unfortunately it does not work with the v3 app “automations”. History does in fact work, but automations won’t trigger of of it turning on or off. The code I posted above thankfully does work, even if history is slightly borked. I’d love help tweaking it so we can all have a working DTH to use with the new v3 app.

1 Like

Update - My modified DTH does indeed work with the new V3 app, but only with smartlighting as a trigger. Here are the specifics:

  • History does not work on the device page
  • Will not work as a “trigger” (“if”) of the new “automations” part of the v3 app.
  • It does work as an “action” (“then”) of the new “automations” app
  • SmartLighting (smartapp) can trigger off of this DTH, but you have to do it as a “switch” (not button), turned “on”.

Personally, I have a smartlighting automation for every mode. When the momentary button gets “turned on”, then the smartlighting automation triggers a scene.

1 Like

© 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.