Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Garage Door Device Type
/**
* Virtual Garage Door
*
* Copyright 2014 Daniel Ogorchock
*
* 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.
*
*/
metadata {
definition (name: "Virtual Garage Door", namespace: "ogiewon", author: "Daniel Ogorchock") {
capability "Actuator"
capability "Switch"
capability "Sensor"
capability "Contact Sensor"
attribute "garagedoor", "string"
command "open"
command "opening"
command "closing"
command "closed"
command "pushButton"
}
// simulator metadata
simulator {
}
// UI tile definitions
tiles {
standardTile("garagedoor", "device.garagedoor", width: 2, height: 2, canChangeIcon: true) {
state "closed", label: 'Closed', action: "pushButton", icon: "st.doors.garage.garage-closed", backgroundColor: "#79b821", nextState: "opening"
state "open", label: 'Open', action: "pushButton", icon: "st.doors.garage.garage-open", backgroundColor: "#ffa81e", nextState: "closing"
state "opening", label: 'Opening', action: "pushButton", icon: "st.doors.garage.garage-opening", backgroundColor: "89C2E8", nextState: "opening"
state "closing", label: 'Closing', action: "pushButton", icon: "st.doors.garage.garage-closing", backgroundColor: "89C2E8", nextState: "closing"
}
standardTile("contact", "device.contact", width: 1, height: 1) {
state("open", label:'${name}', icon:"st.doors.garage.garage-open", backgroundColor:"#ffa81e")
state("closed", label:'${name}', icon:"st.doors.garage.garage-closed", backgroundColor:"#79b821")
}
main (["garagedoor", "contact"])
details (["garagedoor", "contact"])
}
}
def parse(String description) {
}
def open() {
sendEvent(name: "garagedoor", value: "open")
sendEvent(name: "contact", value: "open")
}
def opening() {
sendEvent(name: "garagedoor", value: "opening")
}
def closing() {
sendEvent(name: "garagedoor", value: "closing")
}
def closed() {
sendEvent(name: "garagedoor", value: "closed")
sendEvent(name: "contact", value: "closed")
}
def pushButton() {
sendEvent(name: "garagedoor", value: "pushbutton")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment