Skip to content

Instantly share code, notes, and snippets.

@joshualyon
Created March 18, 2015 14:29
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save joshualyon/3128356d1f17c3522cb6 to your computer and use it in GitHub Desktop.
Save joshualyon/3128356d1f17c3522cb6 to your computer and use it in GitHub Desktop.
/**
* Copyright 2014 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.
*
*/
metadata {
// Automatically generated. Make future change here.
definition (name: "Simulated Contact Sensor", namespace: "smartthings/testing", author: "bob") {
capability "Contact Sensor"
command "open"
command "close"
}
simulator {
status "open": "contact:open"
status "closed": "contact:closed"
}
tiles {
standardTile("contact", "device.contact", width: 2, height: 2) {
state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821", action: "open")
state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e", action: "close")
}
main "contact"
details "contact"
}
}
def parse(String description) {
def pair = description.split(":")
createEvent(name: pair[0].trim(), value: pair[1].trim())
}
def open() {
log.trace "open()"
sendEvent(name: "contact", value: "open")
}
def close() {
log.trace "close()"
sendEvent(name: "contact", value: "closed")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment