4 * Copyright 2015 obycode
6 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
7 * in compliance with the License. You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
12 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
13 * for the specific language governing permissions and limitations under the License.
17 definition (name: "Virtual Button", namespace: "com.obycode", author: "obycode") {
27 // TODO: define status and reply messages here
31 standardTile("button", "device.button", canChangeIcon: true, inactiveLabel: false, width: 2, height: 2) {
32 state "default", label: '', icon: "st.secondary.off", action: "push"
33 state "pressed", label: 'Pressed', icon: "st.illuminance.illuminance.dark", backgroundColor: "#66ccff", action: "release"
34 state "held", label: 'Held', icon: "st.illuminance.illuminance.light", backgroundColor: "#0066ff", action: "release"
42 // parse events into attributes
43 def parse(String description) {
44 log.debug "Parsing '${description}'"
45 if (description == "updated") {
46 sendEvent(name: "button", value: "released")
52 log.debug "Executing 'push'"
53 sendEvent(name: "button", value: "pushed", /*data: [buttonNumber: button], descriptionText: "$device.displayName button $button was pressed",*/ isStateChange: true)
57 log.debug "Executing 'hold'"
58 sendEvent(name: "button", value: "held", /*data: [buttonNumber: button], descriptionText: "$device.displayName button $button was held",*/ isStateChange: true)
62 log.debug "Executing 'release'"
63 sendEvent(name: "button", value: "default", /*data: [buttonNumber: button], descriptionText: "$device.displayName button $button was held",*/ isStateChange: true)