Not sure how to explain but is it posible to have to momentry push buttons within one device handle. been playing with the code but its the first time i have even looked at it so its a very step learning curve. basically i need a device type that lets me click on 2 seperate buttons within it. this is then linked to mqtt sending an on and off command. i cant use a switch as i have no way of knowing the current state, hence the 2 buttons.
the code below is what i have been hacking about at learning. where i have put PUSH1 this is what i would like to do for that button and then push is the other. just have no idea how or if even possible
/**
* 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
*
* Author: SmartThings
*
* Date: 2013-05-01
*/
metadata {
definition (name: "Momentary Button Tile", namespace: "smartthings", author: "SmartThings") {
capability "Actuator"
capability "Switch"
capability "Momentary"
capability "Sensor"
capability "Switch Level"
}
// simulator metadata
simulator {
}
// UI tile definitions
tiles {
standardTile("switch1", "device.switch", width: 6, height: 4, canChangeIcon: true) {
state "off", label: 'Turn off', action: "momentary.push1", backgroundColor: "#ffffff"
}
}
tiles(scale: 2) {
multiAttributeTile(name:"switch", type: "lighting", width: 6, height: 4, canChangeIcon: true){
tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
attributeState "on", label:'Turn On', action:"momentary.push", icon:"http://cdn.device-icons.smartthings.com/Lighting/light10-icn@2x.png", backgroundColor:"#79b821"
}
tileAttribute ("device.level", key: "SLIDER_CONTROL") {
attributeState "level", action:"switch level.setLevel", range:"(5..32)"
}
}
}
main "switch"
details(["switch1", "level","switch"])
}
preferences {
input name: "room", type: "text", title: "room number", description: "Enter room number", required: true, displayDuringSetup: true
input name: "devicenumber", type: "text", title: "device number", description: "Enter device number", required: true, displayDuringSetup: true
}
def parse(String description) {
}
def push() {
sendEvent(name: "switch", value: "100,!R${room}D${devicenumber}F1", isStateChange: true, display: false)
}
def push1() {
dEvent(name: "switch", value: "100,!R${room}D${devicenumber}F0", isStateChange: true, display: false)
}
def setLevel(value) {
if (value == 0) {
sendEvent(name: "switch", value: "100,!R${room}D${devicenumber}F0", isStateChange: true, display: false)
} else {
sendEvent(name: "switch", value: "100,!R${room}D${devicenumber}FdP${value}", isStateChange: true, display: false)
sendEvent(name: "switch", value: "onee ${value}" )
sendEvent(name: "level", value: '${value}')
}
}
def on() {
push()
}
def off() {
push()
}