Thanks in advance for any help. I have combined the smartthings shield, an arduino uno and a remote control for my bedroom overhead fan and light to create a smartthings controllable light and fan. The device handler and arduino code mimics a button press. While clicking the buttons within the app works well o turn on and off the lights and fan, I can not integrate the lights or fan into any routines or have it controlled y my Amazon echo. This is my first attempt at smartthings coding. Below is the device handler code. Any help or suggestions on what I may have done wrong would be greatly appreciated.
/*original code which I hijacked was…
- On/Off Shield (example)
- Author: urman
- Date: 2013-03-14
- Revision: 2014-07-10
- Capabilities:
- Switch
- Custom Attributes:
- button
- Custom Commands
- hello
- goodbyehello
*/
metadata {
definition (name: “Fan and Light Handler v4 add momentary press”, author: “jlevatino”) {
capability "Switch"
capability "Momentary"
command "lightToggle"
command "fanOff"
command "fanLow"
command "fanMed"
command “fanHigh”
//command "goodbye"
attribute “button”,“string”
}
tiles(scale: 2) {
standardTile(“switch”, “device.switch”, width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) {
state “lights”, label: ‘Light’, action: “lightToggle”, icon: “st.Lighting.light11”, backgroundColor: “#79b821”
}
standardTile(“lightToggleTile”, “push.momentary”, width: 3, height: 3, canChangeIcon: true, canChangeBackground: true) {
state “on”, label: ‘Light’, action: “lightToggle”, icon: “st.Lighting.light11”, backgroundColor: “#79b922”
//state “on2”, label: ‘Light’, action: “lightToggle”, icon: “st.Lighting.light11”, backgroundColor: “#79b888”, nextState:“on”
}
standardTile(“fanOffTile”, “device.button”, width: 3, height: 3, canChangeIcon: true, canChangeBackground: true) {
state “default”, label: ‘Off’, action: “fanOff”, icon: “st.Lighting.light24”, backgroundColor: “#FF0000”
}
standardTile(“fanLowTile”, “device.button”, width: 3, height: 3, canChangeIcon: true, canChangeBackground: true) {
state “default”, label: ‘Low’, action: “fanLow”, icon: “st.Lighting.light24”, backgroundColor: “#79b821”
}
standardTile(“fanMedTile”, “device.button”, width: 3, height: 3, canChangeIcon: true, canChangeBackground: true) {
state “default”, label: ‘Med’, action: “fanMed”, icon: “st.Lighting.light24”, backgroundColor: “#79b821”
}
standardTile(“fanHighTile”, “device.button”, width: 3, height: 3, canChangeIcon: true, canChangeBackground: true) {
state “default”, label: ‘High’, action: “fanHigh”, icon: “st.Lighting.light24”, backgroundColor: “#79b821”
}
main "switch"
details(["lightToggleTile","fanOffTile", "fanLowTile", "fanMedTile", "fanHighTile"])
}
simulator {
status "on": "catchall: 0104 0000 01 01 0040 00 0A21 00 00 0000 0A 00 0A6F6E"
status "off": "catchall: 0104 0000 01 01 0040 00 0A21 00 00 0000 0A 00 0A6F6666"
// reply messages
reply "raw 0x0 { 00 00 0a 0a 6f 6e }": "catchall: 0104 0000 01 01 0040 00 0A21 00 00 0000 0A 00 0A6F6E"
reply "raw 0x0 { 00 00 0a 0a 6f 66 66 }": "catchall: 0104 0000 01 01 0040 00 0A21 00 00 0000 0A 00 0A6F6666"
}
}
Map parse(String description) {
def value = zigbee.parse(description)?.text
def linkText = getLinkText(device)
def descriptionText = getDescriptionText(description, linkText, value)
def handlerName = value
def isStateChange = value != "ping"
def displayed = value && isStateChange
def result = [
value: value,
name: value in ["on","off"] ? "switch" : (value && value != "ping" ? "button" : null),
handlerName: handlerName,
linkText: linkText,
descriptionText: descriptionText,
isStateChange: isStateChange,
displayed: displayed
]
log.debug result.descriptionText
result
}
//def on() {
// zigbee.smartShield(text: “on”).format()
//}
//def off() {
// zigbee.smartShield(text: “off”).format()
//}
def lightToggleMain() {
log.debug "Lights"
zigbee.smartShield(text: “lightToggle”).format()
}
def lightToggle() {
log.debug "Lights"
zigbee.smartShield(text: “lightToggle”).format()
}
def fanOff() {
log.debug "Fan Off"
zigbee.smartShield(text: “fanOff”).format()
}
def fanLow() {
log.debug "Fan Low"
zigbee.smartShield(text: “fanLow”).format()
}
def fanMed() {
log.debug "Hello World!"
zigbee.smartShield(text: “fanMed”).format()
}
def fanHigh() {
log.debug "Hello World!"
zigbee.smartShield(text: “fanHigh”).format()
}
def parse(String description) {
log.debug “Parsing ‘${description}’”
// TODO: handle ‘switch’ attribute
// TODO: handle ‘button’ attribute
}