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:
- 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.
- 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()
}