Skip to content

Instantly share code, notes, and snippets.

@steve28
Last active August 29, 2015 13:56
Show Gist options
  • Save steve28/9336695 to your computer and use it in GitHub Desktop.
Save steve28/9336695 to your computer and use it in GitHub Desktop.
/**
* Garage Door
*
* Author: Steve Sell
* Date: 2014-02-02
*/
metadata {
// Preferences
// tile definitions
tiles {
standardTile("leftDoor", "device.leftDoor", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) {
state "closed", label: 'Closed', action: "pushLeft", icon: "st.doors.garage.garage-closed", backgroundColor: "#79b821", nextState: "opening"
state "open", label: 'Open', action: "pushLeft", icon: "st.doors.garage.garage-open", backgroundColor: "#ffa81e", nextState: "closing"
state "opening", label: "Opening", icon: "st.doors.garage.garage-opening", backgroundColor: "89C2E8"
state "closing", label: "Closing", icon: "st.doors.garage.garage-closing", backgroundColor: "89C2E8"
}
standardTile("rightDoor", "device.rightDoor", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) {
state "closed", label: 'Closed', action: "pushRight", icon: "st.doors.garage.garage-closed", backgroundColor: "#79b821", nextState: "opening"
state "open", label: 'Open', action: "pushRight", icon: "st.doors.garage.garage-open", backgroundColor: "#ffa81e", nextState: "closing"
state "opening", label: "Opening", icon: "st.doors.garage.garage-opening", backgroundColor: "89C2E8"
state "closing", label: "Closing", icon: "st.doors.garage.garage-closing", backgroundColor: "89C2E8"
}
main (["leftDoor", "rightDoor"])
details(["leftDoor","rightDoor"])
}
}
Map parse(String description) {
def name = null
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 incoming_cmd = value.split()
if (incoming_cmd.size() > 1)
{
name = incoming_cmd[0]
value = incoming_cmd[1]
}
else
{
displayed = false
isStateChange = false
}
def result = [
value: value,
name: name,
handlerName: handlerName,
linkText: linkText,
descriptionText: descriptionText,
isStateChange: isStateChange,
displayed: displayed
]
log.debug result
result
}
def pushLeft() {
log.debug "Sending pushLeft"
zigbee.smartShield(text: "pushLeft").format()
}
def pushRight() {
log.debug "Sending pushRight"
zigbee.smartShield(text: "pushRight").format()
}
def poll() {
log.debug "Executing poll."
zigbee.smartShield(text: "poll").format()
}
def refresh() {
log.debug "Executing refresh"
zigbee.smartShield(text: "poll").format()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment